mirror of
https://github.com/ziglang/zig.git
synced 2024-11-17 01:23:54 +00:00
0f26120377
- more support for linux, android, freebsd, netbsd, openbsd, dragonfly - centralize musl utils; musl logic is no longer intertwined with csu - fix musl compilation to build crti/crtn for full archs list - fix openbsd to support `zig build-lib -dynamic` - initial dragonfly linking success (with a warning) ancillary: - fix emutls (openbsd) tests to use `try`
205 lines
5.0 KiB
Zig
205 lines
5.0 KiB
Zig
const std = @import("std");
|
|
const os = std.os;
|
|
const tests = @import("tests.zig");
|
|
|
|
pub fn addCases(cases: *tests.StackTracesContext) void {
|
|
cases.addCase(.{
|
|
.name = "return",
|
|
.source =
|
|
\\pub fn main() !void {
|
|
\\ return error.TheSkyIsFalling;
|
|
\\}
|
|
,
|
|
.Debug = .{
|
|
.expect =
|
|
\\error: TheSkyIsFalling
|
|
\\source.zig:2:5: [address] in main (test)
|
|
\\ return error.TheSkyIsFalling;
|
|
\\ ^
|
|
\\
|
|
,
|
|
},
|
|
.ReleaseSafe = .{
|
|
.exclude_os = .{
|
|
.windows, // segfault
|
|
},
|
|
.expect =
|
|
\\error: TheSkyIsFalling
|
|
\\source.zig:2:5: [address] in [function]
|
|
\\ return error.TheSkyIsFalling;
|
|
\\ ^
|
|
\\
|
|
,
|
|
},
|
|
.ReleaseFast = .{
|
|
.expect =
|
|
\\error: TheSkyIsFalling
|
|
\\
|
|
,
|
|
},
|
|
.ReleaseSmall = .{
|
|
.expect =
|
|
\\error: TheSkyIsFalling
|
|
\\
|
|
,
|
|
},
|
|
});
|
|
|
|
cases.addCase(.{
|
|
.name = "try return",
|
|
.source =
|
|
\\fn foo() !void {
|
|
\\ return error.TheSkyIsFalling;
|
|
\\}
|
|
\\
|
|
\\pub fn main() !void {
|
|
\\ try foo();
|
|
\\}
|
|
,
|
|
.Debug = .{
|
|
.expect =
|
|
\\error: TheSkyIsFalling
|
|
\\source.zig:2:5: [address] in foo (test)
|
|
\\ return error.TheSkyIsFalling;
|
|
\\ ^
|
|
\\source.zig:6:5: [address] in main (test)
|
|
\\ try foo();
|
|
\\ ^
|
|
\\
|
|
,
|
|
},
|
|
.ReleaseSafe = .{
|
|
.exclude_os = .{
|
|
.windows, // segfault
|
|
},
|
|
.expect =
|
|
\\error: TheSkyIsFalling
|
|
\\source.zig:2:5: [address] in [function]
|
|
\\ return error.TheSkyIsFalling;
|
|
\\ ^
|
|
\\source.zig:6:5: [address] in [function]
|
|
\\ try foo();
|
|
\\ ^
|
|
\\
|
|
,
|
|
},
|
|
.ReleaseFast = .{
|
|
.expect =
|
|
\\error: TheSkyIsFalling
|
|
\\
|
|
,
|
|
},
|
|
.ReleaseSmall = .{
|
|
.expect =
|
|
\\error: TheSkyIsFalling
|
|
\\
|
|
,
|
|
},
|
|
});
|
|
|
|
cases.addCase(.{
|
|
.name = "try try return return",
|
|
.source =
|
|
\\fn foo() !void {
|
|
\\ try bar();
|
|
\\}
|
|
\\
|
|
\\fn bar() !void {
|
|
\\ return make_error();
|
|
\\}
|
|
\\
|
|
\\fn make_error() !void {
|
|
\\ return error.TheSkyIsFalling;
|
|
\\}
|
|
\\
|
|
\\pub fn main() !void {
|
|
\\ try foo();
|
|
\\}
|
|
,
|
|
.Debug = .{
|
|
.expect =
|
|
\\error: TheSkyIsFalling
|
|
\\source.zig:10:5: [address] in make_error (test)
|
|
\\ return error.TheSkyIsFalling;
|
|
\\ ^
|
|
\\source.zig:6:5: [address] in bar (test)
|
|
\\ return make_error();
|
|
\\ ^
|
|
\\source.zig:2:5: [address] in foo (test)
|
|
\\ try bar();
|
|
\\ ^
|
|
\\source.zig:14:5: [address] in main (test)
|
|
\\ try foo();
|
|
\\ ^
|
|
\\
|
|
,
|
|
},
|
|
.ReleaseSafe = .{
|
|
.exclude_os = .{
|
|
.windows, // segfault
|
|
},
|
|
.expect =
|
|
\\error: TheSkyIsFalling
|
|
\\source.zig:10:5: [address] in [function]
|
|
\\ return error.TheSkyIsFalling;
|
|
\\ ^
|
|
\\source.zig:6:5: [address] in [function]
|
|
\\ return make_error();
|
|
\\ ^
|
|
\\source.zig:2:5: [address] in [function]
|
|
\\ try bar();
|
|
\\ ^
|
|
\\source.zig:14:5: [address] in [function]
|
|
\\ try foo();
|
|
\\ ^
|
|
\\
|
|
,
|
|
},
|
|
.ReleaseFast = .{
|
|
.expect =
|
|
\\error: TheSkyIsFalling
|
|
\\
|
|
,
|
|
},
|
|
.ReleaseSmall = .{
|
|
.expect =
|
|
\\error: TheSkyIsFalling
|
|
\\
|
|
,
|
|
},
|
|
});
|
|
|
|
cases.addCase(.{
|
|
.exclude_os = .{
|
|
.openbsd, // integer overflow
|
|
.windows,
|
|
},
|
|
.name = "dumpCurrentStackTrace",
|
|
.source =
|
|
\\const std = @import("std");
|
|
\\
|
|
\\fn bar() void {
|
|
\\ std.debug.dumpCurrentStackTrace(@returnAddress());
|
|
\\}
|
|
\\fn foo() void {
|
|
\\ bar();
|
|
\\}
|
|
\\pub fn main() u8 {
|
|
\\ foo();
|
|
\\ return 1;
|
|
\\}
|
|
,
|
|
.Debug = .{
|
|
.expect =
|
|
\\source.zig:7:8: [address] in foo (test)
|
|
\\ bar();
|
|
\\ ^
|
|
\\source.zig:10:8: [address] in main (test)
|
|
\\ foo();
|
|
\\ ^
|
|
\\
|
|
,
|
|
},
|
|
});
|
|
}
|