Skip to content

Commit b95af2b

Browse files
committed
unwind test: make it less brittle with expected failures
1 parent 3b5a943 commit b95af2b

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

test/standalone/stack_iterator/unwind.zig

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,18 @@ var skip_frames: AddrArray = undefined;
3030
const expect_signal_frame_overflow =
3131
(native_arch == .arm and link_libc); // loops above main()
3232

33-
// not reliably loopy?
34-
// ((native_arch == .aarch64 or
35-
// native_arch == .aarch64_be) and !link_libc); // loops on first step
36-
3733
// Getting the backtrace inside the signal handler (with the ucontext_t)
3834
// does not contain the expected content on some systems:
3935
const expect_signal_frame_useless =
4036
(native_arch == .x86_64 and link_libc and builtin.abi.isGnu()) or // stuck on pthread_kill?
4137
(native_arch == .x86_64 and link_libc and builtin.abi.isMusl() and builtin.omit_frame_pointer) or // immediately confused backtrace
42-
//((native_arch == .aarch64 or
43-
// native_arch == .aarch64_be) and link_libc) or // loops on first step -- not reliably loopy?
4438
(native_arch == .riscv64 and link_libc) or // `ucontext_t` not defined yet
4539
native_arch == .mips or
4640
native_arch == .mipsel or
4741
native_arch == .mips64 or
4842
native_arch == .mips64el or
4943
native_arch == .powerpc64 or
50-
native_arch == .powerpc64le; // loops on first step
44+
native_arch == .powerpc64le;
5145

5246
// Signal handler to test backtraces from the given signal context.
5347
fn testFromSigUrg(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void {
@@ -249,14 +243,13 @@ pub fn main() !void {
249243
}
250244

251245
if (signal_frames.len == signal_frames.capacity()) {
252-
std.debug.print("signal_frames contains too many frames: {}\n", .{signal_frames.len});
253-
fail_count += 1;
254-
}
255-
256-
if (expect_signal_frame_overflow) {
257-
// The signal_frames backtrace overflows. Ignore this for now.
258-
try testing.expectEqual(1, fail_count);
259-
fail_count = 0;
246+
if (expect_signal_frame_overflow) {
247+
// The signal_frames backtrace overflows. Ignore this for now.
248+
std.debug.print("(expected) signal_frames overflow: {}\n", .{signal_frames.len});
249+
} else {
250+
std.debug.print("signal_frames contains too many frames: {}\n", .{signal_frames.len});
251+
fail_count += 1;
252+
}
260253
}
261254

262255
var found = false;
@@ -276,7 +269,6 @@ pub fn main() !void {
276269
found = true;
277270
}
278271
}
279-
//try testing.expectEqual(found, true);
280272
if (!found) {
281273
std.debug.print("full_frames[...] does not include expected[0..4]\n", .{});
282274
fail_count += 1;
@@ -294,12 +286,10 @@ pub fn main() !void {
294286
found = true;
295287
}
296288
}
297-
//try testing.expectEqual(found, true);
298-
if (expect_signal_frame_useless) {
299-
std.debug.print("(expected) signal_frames[...] does not include expected[0..4]\n", .{});
300-
try testing.expectEqual(false, found);
301-
} else {
302-
if (!found) {
289+
if (!found) {
290+
if (expect_signal_frame_useless) {
291+
std.debug.print("(expected) signal_frames[...] does not include expected[0..4]\n", .{});
292+
} else {
303293
std.debug.print("signal_frames[...] does not include expected[0..4]\n", .{});
304294
fail_count += 1;
305295
}

0 commit comments

Comments
 (0)