diff options
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/valgrind.zig | 9 | ||||
| -rw-r--r-- | lib/std/valgrind/memcheck.zig | 25 |
2 files changed, 34 insertions, 0 deletions
diff --git a/lib/std/valgrind.zig b/lib/std/valgrind.zig index 131b8a9f4d..ffdce1b729 100644 --- a/lib/std/valgrind.zig +++ b/lib/std/valgrind.zig @@ -99,6 +99,10 @@ pub fn runningOnValgrind() usize { return doClientRequestExpr(0, .RunningOnValgrind, 0, 0, 0, 0, 0); } +test "works whether running on valgrind or not" { + _ = runningOnValgrind(); +} + /// Discard translation of code in the slice qzz. Useful if you are debugging /// a JITter or some such, since it provides a way to make sure valgrind will /// retranslate the invalidated area. Returns no value. @@ -266,3 +270,8 @@ pub fn monitorCommand(command: [*]u8) bool { pub const memcheck = @import("valgrind/memcheck.zig"); pub const callgrind = @import("valgrind/callgrind.zig"); + +test "" { + _ = @import("valgrind/memcheck.zig"); + _ = @import("valgrind/callgrind.zig"); +} diff --git a/lib/std/valgrind/memcheck.zig b/lib/std/valgrind/memcheck.zig index 4c0268e98a..a15a6cca0e 100644 --- a/lib/std/valgrind/memcheck.zig +++ b/lib/std/valgrind/memcheck.zig @@ -1,4 +1,5 @@ const std = @import("../std.zig"); +const testing = std.testing; const valgrind = std.valgrind; pub const MemCheckClientRequest = extern enum { @@ -142,6 +143,18 @@ pub fn countLeaks() CountResult { return res; } +test "countLeaks" { + testing.expectEqual( + @as(CountResult, .{ + .leaked = 0, + .dubious = 0, + .reachable = 0, + .suppressed = 0, + }), + countLeaks(), + ); +} + pub fn countLeakBlocks() CountResult { var res: CountResult = .{ .leaked = 0, @@ -160,6 +173,18 @@ pub fn countLeakBlocks() CountResult { return res; } +test "countLeakBlocks" { + testing.expectEqual( + @as(CountResult, .{ + .leaked = 0, + .dubious = 0, + .reachable = 0, + .suppressed = 0, + }), + countLeakBlocks(), + ); +} + /// Get the validity data for addresses zza and copy it /// into the provided zzvbits array. Return values: /// 0 if not running on valgrind |
