authorgravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2019-11-17 14:16:09+11:00
committergravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2019-11-17 14:16:09+11:00
logd870a68e680242d130dcecef1f1ccc0969f326c0
treed88b974a5f7e5f1f8519938aa31ca3bb092bd575
parent7d582d0a00f2111f68409666c74705910bb82fdd
signaturelock-open Commit is signed but in an unrecognized format.

std: add a couple of tests to valgrind module


2 files changed, 34 insertions(+), 0 deletions(-)

lib/std/valgrind.zig+9
......@@ -99,6 +99,10 @@ pub fn runningOnValgrind() usize {
9999 return doClientRequestExpr(0, .RunningOnValgrind, 0, 0, 0, 0, 0);
100100}
101101
102test "works whether running on valgrind or not" {
103 _ = runningOnValgrind();
104}
105
102106/// Discard translation of code in the slice qzz. Useful if you are debugging
103107/// a JITter or some such, since it provides a way to make sure valgrind will
104108/// retranslate the invalidated area. Returns no value.
......@@ -266,3 +270,8 @@ pub fn monitorCommand(command: [*]u8) bool {
266270
267271pub const memcheck = @import("valgrind/memcheck.zig");
268272pub const callgrind = @import("valgrind/callgrind.zig");
273
274test "" {
275 _ = @import("valgrind/memcheck.zig");
276 _ = @import("valgrind/callgrind.zig");
277}
lib/std/valgrind/memcheck.zig+25
......@@ -1,4 +1,5 @@
11const std = @import("../std.zig");
2const testing = std.testing;
23const valgrind = std.valgrind;
34
45pub const MemCheckClientRequest = extern enum {
......@@ -142,6 +143,18 @@ pub fn countLeaks() CountResult {
142143 return res;
143144}
144145
146test "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
145158pub fn countLeakBlocks() CountResult {
146159 var res: CountResult = .{
147160 .leaked = 0,
......@@ -160,6 +173,18 @@ pub fn countLeakBlocks() CountResult {
160173 return res;
161174}
162175
176test "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
163188/// Get the validity data for addresses zza and copy it
164189/// into the provided zzvbits array. Return values:
165190/// 0 if not running on valgrind