mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 07:03:11 +00:00
std: add a couple of tests to valgrind module
This commit is contained in:
parent
7d582d0a00
commit
d870a68e68
@ -99,6 +99,10 @@ pub fn runningOnValgrind() usize {
|
|||||||
return doClientRequestExpr(0, .RunningOnValgrind, 0, 0, 0, 0, 0);
|
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
|
/// 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
|
/// a JITter or some such, since it provides a way to make sure valgrind will
|
||||||
/// retranslate the invalidated area. Returns no value.
|
/// 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 memcheck = @import("valgrind/memcheck.zig");
|
||||||
pub const callgrind = @import("valgrind/callgrind.zig");
|
pub const callgrind = @import("valgrind/callgrind.zig");
|
||||||
|
|
||||||
|
test "" {
|
||||||
|
_ = @import("valgrind/memcheck.zig");
|
||||||
|
_ = @import("valgrind/callgrind.zig");
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
const std = @import("../std.zig");
|
const std = @import("../std.zig");
|
||||||
|
const testing = std.testing;
|
||||||
const valgrind = std.valgrind;
|
const valgrind = std.valgrind;
|
||||||
|
|
||||||
pub const MemCheckClientRequest = extern enum {
|
pub const MemCheckClientRequest = extern enum {
|
||||||
@ -142,6 +143,18 @@ pub fn countLeaks() CountResult {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "countLeaks" {
|
||||||
|
testing.expectEqual(
|
||||||
|
@as(CountResult, .{
|
||||||
|
.leaked = 0,
|
||||||
|
.dubious = 0,
|
||||||
|
.reachable = 0,
|
||||||
|
.suppressed = 0,
|
||||||
|
}),
|
||||||
|
countLeaks(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn countLeakBlocks() CountResult {
|
pub fn countLeakBlocks() CountResult {
|
||||||
var res: CountResult = .{
|
var res: CountResult = .{
|
||||||
.leaked = 0,
|
.leaked = 0,
|
||||||
@ -160,6 +173,18 @@ pub fn countLeakBlocks() CountResult {
|
|||||||
return res;
|
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
|
/// Get the validity data for addresses zza and copy it
|
||||||
/// into the provided zzvbits array. Return values:
|
/// into the provided zzvbits array. Return values:
|
||||||
/// 0 if not running on valgrind
|
/// 0 if not running on valgrind
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user