authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-04-28 00:26:30+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-04-28 18:35:01+02:00
log495bb12e6a5b5783fa14cc08c2c940ee60b80607
treeb24cfd90268c57570bcfe4a9a243c4f333cd1f63
parented51a5d02af58b3d11b555233781d71e6bde60af

test: migrate plan9 and sparcv9 incremental tests


7 files changed, 70 insertions(+), 96 deletions(-)

test/cases.zig-2
......@@ -10,9 +10,7 @@ pub fn addCases(ctx: *TestContext) !void {
1010 try @import("compile_errors.zig").addCases(ctx);
1111 try @import("stage2/cbe.zig").addCases(ctx);
1212 try @import("stage2/llvm.zig").addCases(ctx);
13 try @import("stage2/plan9.zig").addCases(ctx);
1413 try @import("stage2/x86_64.zig").addCases(ctx);
15 try @import("stage2/sparcv9.zig").addCases(ctx);
1614 // https://github.com/ziglang/zig/issues/10968
1715 //try @import("stage2/nvptx.zig").addCases(ctx);
1816}
test/incremental/plan9/exit.zig created+5
......@@ -0,0 +1,5 @@
1pub fn main() void {}
2
3// run
4// target=x86_64-plan9,aarch64-plan9
5//
test/incremental/plan9/hello_world_with_updates.0.zig created+28
......@@ -0,0 +1,28 @@
1pub fn main() void {
2 const str = "Hello World!\n";
3 asm volatile (
4 \\push $0
5 \\push %%r10
6 \\push %%r11
7 \\push $1
8 \\push $0
9 \\syscall
10 \\pop %%r11
11 \\pop %%r11
12 \\pop %%r11
13 \\pop %%r11
14 \\pop %%r11
15 :
16 // pwrite
17 : [syscall_number] "{rbp}" (51),
18 [hey] "{r11}" (@ptrToInt(str)),
19 [strlen] "{r10}" (str.len),
20 : "rcx", "rbp", "r11", "memory"
21 );
22}
23
24// run
25// target=x86_64-plan9
26//
27// Hello World
28//
test/incremental/plan9/hello_world_with_updates.1.zig created+10
......@@ -0,0 +1,10 @@
1const std = @import("std");
2pub fn main() void {
3 const str = "Hello World!\n";
4 _ = std.os.plan9.pwrite(1, str, str.len, 0);
5}
6
7// run
8//
9// Hello World
10//
test/incremental/sparcv9-linux/hello_world.zig created+27
......@@ -0,0 +1,27 @@
1const msg = "Hello, World!\n";
2
3pub export fn _start() noreturn {
4 asm volatile ("ta 0x6d"
5 :
6 : [number] "{g1}" (4),
7 [arg1] "{o0}" (1),
8 [arg2] "{o1}" (@ptrToInt(msg)),
9 [arg3] "{o2}" (msg.len),
10 : "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7", "memory"
11 );
12
13 asm volatile ("ta 0x6d"
14 :
15 : [number] "{g1}" (1),
16 [arg1] "{o0}" (0),
17 : "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7", "memory"
18 );
19
20 unreachable;
21}
22
23// run
24// target=sparcv9-linux
25//
26// Hello, World!
27//
test/stage2/plan9.zig deleted-55
......@@ -1,55 +0,0 @@
1const std = @import("std");
2const TestContext = @import("../../src/test.zig").TestContext;
3
4pub fn addCases(ctx: *TestContext) !void {
5 const x64: std.zig.CrossTarget = .{
6 .cpu_arch = .x86_64,
7 .os_tag = .plan9,
8 };
9 const aarch64: std.zig.CrossTarget = .{
10 .cpu_arch = .aarch64,
11 .os_tag = .plan9,
12 };
13 {
14 var case = ctx.exe("plan9: exiting correctly x64", x64);
15 case.addCompareOutput("pub fn main() void {}", "");
16 }
17 {
18 var case = ctx.exe("plan9: exiting correctly arm", aarch64);
19 case.addCompareOutput("pub fn main() void {}", "");
20 }
21 {
22 var case = ctx.exe("plan9: hello world", x64);
23 case.addCompareOutput(
24 \\pub fn main() void {
25 \\ const str = "Hello World!\n";
26 \\ asm volatile (
27 \\ \\push $0
28 \\ \\push %%r10
29 \\ \\push %%r11
30 \\ \\push $1
31 \\ \\push $0
32 \\ \\syscall
33 \\ \\pop %%r11
34 \\ \\pop %%r11
35 \\ \\pop %%r11
36 \\ \\pop %%r11
37 \\ \\pop %%r11
38 \\ :
39 \\ // pwrite
40 \\ : [syscall_number] "{rbp}" (51),
41 \\ [hey] "{r11}" (@ptrToInt(str)),
42 \\ [strlen] "{r10}" (str.len)
43 \\ : "rcx", "rbp", "r11", "memory"
44 \\ );
45 \\}
46 , "Hello World\n");
47 case.addCompareOutput(
48 \\const std = @import("std");
49 \\pub fn main() void {
50 \\ const str = "Hello World!\n";
51 \\ _ = std.os.plan9.pwrite(1, str, str.len, 0);
52 \\}
53 , "Hello World\n");
54 }
55}
test/stage2/sparcv9.zig deleted-39
......@@ -1,39 +0,0 @@
1const std = @import("std");
2const TestContext = @import("../../src/test.zig").TestContext;
3
4const linux_sparcv9 = std.zig.CrossTarget{
5 .cpu_arch = .sparcv9,
6 .os_tag = .linux,
7};
8
9pub fn addCases(ctx: *TestContext) !void {
10 {
11 var case = ctx.exe("sparcv9 hello world", linux_sparcv9);
12 // Regular old hello world
13 case.addCompareOutput(
14 \\const msg = "Hello, World!\n";
15 \\
16 \\pub export fn _start() noreturn {
17 \\ asm volatile ("ta 0x6d"
18 \\ :
19 \\ : [number] "{g1}" (4),
20 \\ [arg1] "{o0}" (1),
21 \\ [arg2] "{o1}" (@ptrToInt(msg)),
22 \\ [arg3] "{o2}" (msg.len)
23 \\ : "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7", "memory"
24 \\ );
25 \\
26 \\ asm volatile ("ta 0x6d"
27 \\ :
28 \\ : [number] "{g1}" (1),
29 \\ [arg1] "{o0}" (0)
30 \\ : "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7", "memory"
31 \\ );
32 \\
33 \\ unreachable;
34 \\}
35 ,
36 "Hello, World!\n",
37 );
38 }
39}