| author | |
| committer | |
| log | d870a68e680242d130dcecef1f1ccc0969f326c0 |
| tree | d88b974a5f7e5f1f8519938aa31ca3bb092bd575 |
| parent | 7d582d0a00f2111f68409666c74705910bb82fdd |
| signature |
2 files changed, 34 insertions(+), 0 deletions(-)
lib/std/valgrind.zig+9| ... | @@ -99,6 +99,10 @@ pub fn runningOnValgrind() usize { | ... | @@ -99,6 +99,10 @@ pub fn runningOnValgrind() usize { |
| 99 | return doClientRequestExpr(0, .RunningOnValgrind, 0, 0, 0, 0, 0); | 99 | return doClientRequestExpr(0, .RunningOnValgrind, 0, 0, 0, 0, 0); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | test "works whether running on valgrind or not" { | ||
| 103 | _ = runningOnValgrind(); | ||
| 104 | } | ||
| 105 | |||
| 102 | /// Discard translation of code in the slice qzz. Useful if you are debugging | 106 | /// Discard translation of code in the slice qzz. Useful if you are debugging |
| 103 | /// a JITter or some such, since it provides a way to make sure valgrind will | 107 | /// a JITter or some such, since it provides a way to make sure valgrind will |
| 104 | /// retranslate the invalidated area. Returns no value. | 108 | /// retranslate the invalidated area. Returns no value. |
| ... | @@ -266,3 +270,8 @@ pub fn monitorCommand(command: [*]u8) bool { | ... | @@ -266,3 +270,8 @@ pub fn monitorCommand(command: [*]u8) bool { |
| 266 | 270 | ||
| 267 | pub const memcheck = @import("valgrind/memcheck.zig"); | 271 | pub const memcheck = @import("valgrind/memcheck.zig"); |
| 268 | pub const callgrind = @import("valgrind/callgrind.zig"); | 272 | pub const callgrind = @import("valgrind/callgrind.zig"); |
| 273 | |||
| 274 | test "" { | ||
| 275 | _ = @import("valgrind/memcheck.zig"); | ||
| 276 | _ = @import("valgrind/callgrind.zig"); | ||
| 277 | } |
lib/std/valgrind/memcheck.zig+25| ... | @@ -1,4 +1,5 @@ | ... | @@ -1,4 +1,5 @@ |
| 1 | const std = @import("../std.zig"); | 1 | const std = @import("../std.zig"); |
| 2 | const testing = std.testing; | ||
| 2 | const valgrind = std.valgrind; | 3 | const valgrind = std.valgrind; |
| 3 | 4 | ||
| 4 | pub const MemCheckClientRequest = extern enum { | 5 | pub const MemCheckClientRequest = extern enum { |
| ... | @@ -142,6 +143,18 @@ pub fn countLeaks() CountResult { | ... | @@ -142,6 +143,18 @@ pub fn countLeaks() CountResult { |
| 142 | return res; | 143 | return res; |
| 143 | } | 144 | } |
| 144 | 145 | ||
| 146 | test "countLeaks" { | ||
| 147 | testing.expectEqual( | ||
| 148 | @as(CountResult, .{ | ||
| 149 | .leaked = 0, | ||
| 150 | .dubious = 0, | ||
| 151 | .reachable = 0, | ||
| 152 | .suppressed = 0, | ||
| 153 | }), | ||
| 154 | countLeaks(), | ||
| 155 | ); | ||
| 156 | } | ||
| 157 | |||
| 145 | pub fn countLeakBlocks() CountResult { | 158 | pub fn countLeakBlocks() CountResult { |
| 146 | var res: CountResult = .{ | 159 | var res: CountResult = .{ |
| 147 | .leaked = 0, | 160 | .leaked = 0, |
| ... | @@ -160,6 +173,18 @@ pub fn countLeakBlocks() CountResult { | ... | @@ -160,6 +173,18 @@ pub fn countLeakBlocks() CountResult { |
| 160 | return res; | 173 | return res; |
| 161 | } | 174 | } |
| 162 | 175 | ||
| 176 | test "countLeakBlocks" { | ||
| 177 | testing.expectEqual( | ||
| 178 | @as(CountResult, .{ | ||
| 179 | .leaked = 0, | ||
| 180 | .dubious = 0, | ||
| 181 | .reachable = 0, | ||
| 182 | .suppressed = 0, | ||
| 183 | }), | ||
| 184 | countLeakBlocks(), | ||
| 185 | ); | ||
| 186 | } | ||
| 187 | |||
| 163 | /// Get the validity data for addresses zza and copy it | 188 | /// Get the validity data for addresses zza and copy it |
| 164 | /// into the provided zzvbits array. Return values: | 189 | /// into the provided zzvbits array. Return values: |
| 165 | /// 0 if not running on valgrind | 190 | /// 0 if not running on valgrind |