| author | |
| committer | |
| log | 0e56d4cc02ce1a09670bf6c50149cb59fd80e9d1 |
| tree | 9ec36a2dd1d00394b252bdf8520edbfcea8fdb44 |
| parent | 5d4401ceec60bb9865569e359f923a16657a7304 |
3 files changed, 116 insertions(+), 220 deletions(-)
test/stage2/aarch64.zig-110| ... | @@ -1,84 +1,12 @@ | ... | @@ -1,84 +1,12 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const TestContext = @import("../../src/test.zig").TestContext; | 2 | const TestContext = @import("../../src/test.zig").TestContext; |
| 3 | 3 | ||
| 4 | const macos_aarch64 = std.zig.CrossTarget{ | ||
| 5 | .cpu_arch = .aarch64, | ||
| 6 | .os_tag = .macos, | ||
| 7 | }; | ||
| 8 | |||
| 9 | const linux_aarch64 = std.zig.CrossTarget{ | 4 | const linux_aarch64 = std.zig.CrossTarget{ |
| 10 | .cpu_arch = .aarch64, | 5 | .cpu_arch = .aarch64, |
| 11 | .os_tag = .linux, | 6 | .os_tag = .linux, |
| 12 | }; | 7 | }; |
| 13 | 8 | ||
| 14 | pub fn addCases(ctx: *TestContext) !void { | 9 | pub fn addCases(ctx: *TestContext) !void { |
| 15 | { | ||
| 16 | var case = ctx.exe("hello world with updates", macos_aarch64); | ||
| 17 | |||
| 18 | // Regular old hello world | ||
| 19 | case.addCompareOutput( | ||
| 20 | \\extern "c" fn write(usize, usize, usize) void; | ||
| 21 | \\extern "c" fn exit(usize) noreturn; | ||
| 22 | \\ | ||
| 23 | \\export fn _start() noreturn { | ||
| 24 | \\ print(); | ||
| 25 | \\ | ||
| 26 | \\ exit(0); | ||
| 27 | \\} | ||
| 28 | \\ | ||
| 29 | \\fn print() void { | ||
| 30 | \\ const msg = @ptrToInt("Hello, World!\n"); | ||
| 31 | \\ const len = 14; | ||
| 32 | \\ write(1, msg, len); | ||
| 33 | \\} | ||
| 34 | , | ||
| 35 | "Hello, World!\n", | ||
| 36 | ); | ||
| 37 | |||
| 38 | // Now change the message only | ||
| 39 | case.addCompareOutput( | ||
| 40 | \\extern "c" fn write(usize, usize, usize) void; | ||
| 41 | \\extern "c" fn exit(usize) noreturn; | ||
| 42 | \\ | ||
| 43 | \\export fn _start() noreturn { | ||
| 44 | \\ print(); | ||
| 45 | \\ | ||
| 46 | \\ exit(0); | ||
| 47 | \\} | ||
| 48 | \\ | ||
| 49 | \\fn print() void { | ||
| 50 | \\ const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); | ||
| 51 | \\ const len = 104; | ||
| 52 | \\ write(1, msg, len); | ||
| 53 | \\} | ||
| 54 | , | ||
| 55 | "What is up? This is a longer message that will force the data to be relocated in virtual address space.\n", | ||
| 56 | ); | ||
| 57 | |||
| 58 | // Now we print it twice. | ||
| 59 | case.addCompareOutput( | ||
| 60 | \\extern "c" fn write(usize, usize, usize) void; | ||
| 61 | \\extern "c" fn exit(usize) noreturn; | ||
| 62 | \\ | ||
| 63 | \\export fn _start() noreturn { | ||
| 64 | \\ print(); | ||
| 65 | \\ print(); | ||
| 66 | \\ | ||
| 67 | \\ exit(0); | ||
| 68 | \\} | ||
| 69 | \\ | ||
| 70 | \\fn print() void { | ||
| 71 | \\ const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); | ||
| 72 | \\ const len = 104; | ||
| 73 | \\ write(1, msg, len); | ||
| 74 | \\} | ||
| 75 | , | ||
| 76 | \\What is up? This is a longer message that will force the data to be relocated in virtual address space. | ||
| 77 | \\What is up? This is a longer message that will force the data to be relocated in virtual address space. | ||
| 78 | \\ | ||
| 79 | ); | ||
| 80 | } | ||
| 81 | |||
| 82 | { | 10 | { |
| 83 | var case = ctx.exe("linux_aarch64 hello world", linux_aarch64); | 11 | var case = ctx.exe("linux_aarch64 hello world", linux_aarch64); |
| 84 | // Regular old hello world | 12 | // Regular old hello world |
| ... | @@ -119,28 +47,6 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -119,28 +47,6 @@ pub fn addCases(ctx: *TestContext) !void { |
| 119 | ); | 47 | ); |
| 120 | } | 48 | } |
| 121 | 49 | ||
| 122 | { | ||
| 123 | var case = ctx.exe("exit fn taking argument", macos_aarch64); | ||
| 124 | |||
| 125 | case.addCompareOutput( | ||
| 126 | \\export fn _start() noreturn { | ||
| 127 | \\ exit(0); | ||
| 128 | \\} | ||
| 129 | \\ | ||
| 130 | \\fn exit(ret: usize) noreturn { | ||
| 131 | \\ asm volatile ("svc #0x80" | ||
| 132 | \\ : | ||
| 133 | \\ : [number] "{x16}" (1), | ||
| 134 | \\ [arg1] "{x0}" (ret) | ||
| 135 | \\ : "memory" | ||
| 136 | \\ ); | ||
| 137 | \\ unreachable; | ||
| 138 | \\} | ||
| 139 | , | ||
| 140 | "", | ||
| 141 | ); | ||
| 142 | } | ||
| 143 | |||
| 144 | { | 50 | { |
| 145 | var case = ctx.exe("exit fn taking argument", linux_aarch64); | 51 | var case = ctx.exe("exit fn taking argument", linux_aarch64); |
| 146 | 52 | ||
| ... | @@ -162,20 +68,4 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -162,20 +68,4 @@ pub fn addCases(ctx: *TestContext) !void { |
| 162 | "", | 68 | "", |
| 163 | ); | 69 | ); |
| 164 | } | 70 | } |
| 165 | |||
| 166 | { | ||
| 167 | var case = ctx.exe("only libc exit", macos_aarch64); | ||
| 168 | |||
| 169 | // This test case covers an infrequent scenarion where the string table *may* be relocated | ||
| 170 | // into the position preceeding the symbol table which results in a dyld error. | ||
| 171 | case.addCompareOutput( | ||
| 172 | \\extern "c" fn exit(usize) noreturn; | ||
| 173 | \\ | ||
| 174 | \\export fn _start() noreturn { | ||
| 175 | \\ exit(0); | ||
| 176 | \\} | ||
| 177 | , | ||
| 178 | "", | ||
| 179 | ); | ||
| 180 | } | ||
| 181 | } | 71 | } |
test/stage2/darwin.zig created+115| ... | @@ -0,0 +1,115 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const TestContext = @import("../../src/test.zig").TestContext; | ||
| 3 | |||
| 4 | const archs = [2]std.Target.Cpu.Arch{ | ||
| 5 | .aarch64, .x86_64, | ||
| 6 | }; | ||
| 7 | |||
| 8 | pub fn addCases(ctx: *TestContext) !void { | ||
| 9 | for (archs) |arch| { | ||
| 10 | const target: std.zig.CrossTarget = .{ | ||
| 11 | .cpu_arch = arch, | ||
| 12 | .os_tag = .macos, | ||
| 13 | }; | ||
| 14 | { | ||
| 15 | var case = ctx.exe("hello world with updates", target); | ||
| 16 | case.addError("", &[_][]const u8{"error: no entry point found"}); | ||
| 17 | |||
| 18 | // Incorrect return type | ||
| 19 | case.addError( | ||
| 20 | \\export fn _start() noreturn { | ||
| 21 | \\} | ||
| 22 | , &[_][]const u8{":2:1: error: expected noreturn, found void"}); | ||
| 23 | |||
| 24 | // Regular old hello world | ||
| 25 | case.addCompareOutput( | ||
| 26 | \\extern "c" fn write(usize, usize, usize) usize; | ||
| 27 | \\extern "c" fn exit(usize) noreturn; | ||
| 28 | \\ | ||
| 29 | \\export fn _start() noreturn { | ||
| 30 | \\ print(); | ||
| 31 | \\ | ||
| 32 | \\ exit(0); | ||
| 33 | \\} | ||
| 34 | \\ | ||
| 35 | \\fn print() void { | ||
| 36 | \\ const msg = @ptrToInt("Hello, World!\n"); | ||
| 37 | \\ const len = 14; | ||
| 38 | \\ _ = write(1, msg, len); | ||
| 39 | \\} | ||
| 40 | , | ||
| 41 | "Hello, World!\n", | ||
| 42 | ); | ||
| 43 | |||
| 44 | // Now change the message only | ||
| 45 | case.addCompareOutput( | ||
| 46 | \\extern "c" fn write(usize, usize, usize) usize; | ||
| 47 | \\extern "c" fn exit(usize) noreturn; | ||
| 48 | \\ | ||
| 49 | \\export fn _start() noreturn { | ||
| 50 | \\ print(); | ||
| 51 | \\ | ||
| 52 | \\ exit(0); | ||
| 53 | \\} | ||
| 54 | \\ | ||
| 55 | \\fn print() void { | ||
| 56 | \\ const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); | ||
| 57 | \\ const len = 104; | ||
| 58 | \\ _ = write(1, msg, len); | ||
| 59 | \\} | ||
| 60 | , | ||
| 61 | "What is up? This is a longer message that will force the data to be relocated in virtual address space.\n", | ||
| 62 | ); | ||
| 63 | |||
| 64 | // Now we print it twice. | ||
| 65 | case.addCompareOutput( | ||
| 66 | \\extern "c" fn write(usize, usize, usize) usize; | ||
| 67 | \\extern "c" fn exit(usize) noreturn; | ||
| 68 | \\ | ||
| 69 | \\export fn _start() noreturn { | ||
| 70 | \\ print(); | ||
| 71 | \\ print(); | ||
| 72 | \\ | ||
| 73 | \\ exit(0); | ||
| 74 | \\} | ||
| 75 | \\ | ||
| 76 | \\fn print() void { | ||
| 77 | \\ const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); | ||
| 78 | \\ const len = 104; | ||
| 79 | \\ _ = write(1, msg, len); | ||
| 80 | \\} | ||
| 81 | , | ||
| 82 | \\What is up? This is a longer message that will force the data to be relocated in virtual address space. | ||
| 83 | \\What is up? This is a longer message that will force the data to be relocated in virtual address space. | ||
| 84 | \\ | ||
| 85 | ); | ||
| 86 | } | ||
| 87 | { | ||
| 88 | var case = ctx.exe("corner case - update existing, singular TextBlock", target); | ||
| 89 | |||
| 90 | // This test case also covers an infrequent scenarion where the string table *may* be relocated | ||
| 91 | // into the position preceeding the symbol table which results in a dyld error. | ||
| 92 | case.addCompareOutput( | ||
| 93 | \\extern "c" fn exit(usize) noreturn; | ||
| 94 | \\ | ||
| 95 | \\export fn _start() noreturn { | ||
| 96 | \\ exit(0); | ||
| 97 | \\} | ||
| 98 | , | ||
| 99 | "", | ||
| 100 | ); | ||
| 101 | |||
| 102 | case.addCompareOutput( | ||
| 103 | \\extern "c" fn exit(usize) noreturn; | ||
| 104 | \\extern "c" fn write(usize, usize, usize) usize; | ||
| 105 | \\ | ||
| 106 | \\export fn _start() noreturn { | ||
| 107 | \\ _ = write(1, @ptrToInt("Hey!\n"), 5); | ||
| 108 | \\ exit(0); | ||
| 109 | \\} | ||
| 110 | , | ||
| 111 | "Hey!\n", | ||
| 112 | ); | ||
| 113 | } | ||
| 114 | } | ||
| 115 | } | ||
test/stage2/test.zig+1-110| ... | @@ -11,11 +11,6 @@ const linux_x64 = std.zig.CrossTarget{ | ... | @@ -11,11 +11,6 @@ const linux_x64 = std.zig.CrossTarget{ |
| 11 | .os_tag = .linux, | 11 | .os_tag = .linux, |
| 12 | }; | 12 | }; |
| 13 | 13 | ||
| 14 | const macos_x64 = std.zig.CrossTarget{ | ||
| 15 | .cpu_arch = .x86_64, | ||
| 16 | .os_tag = .macos, | ||
| 17 | }; | ||
| 18 | |||
| 19 | const linux_riscv64 = std.zig.CrossTarget{ | 14 | const linux_riscv64 = std.zig.CrossTarget{ |
| 20 | .cpu_arch = .riscv64, | 15 | .cpu_arch = .riscv64, |
| 21 | .os_tag = .linux, | 16 | .os_tag = .linux, |
| ... | @@ -28,6 +23,7 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -28,6 +23,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 28 | try @import("aarch64.zig").addCases(ctx); | 23 | try @import("aarch64.zig").addCases(ctx); |
| 29 | try @import("llvm.zig").addCases(ctx); | 24 | try @import("llvm.zig").addCases(ctx); |
| 30 | try @import("wasm.zig").addCases(ctx); | 25 | try @import("wasm.zig").addCases(ctx); |
| 26 | try @import("darwin.zig").addCases(ctx); | ||
| 31 | 27 | ||
| 32 | { | 28 | { |
| 33 | var case = ctx.exe("hello world with updates", linux_x64); | 29 | var case = ctx.exe("hello world with updates", linux_x64); |
| ... | @@ -141,95 +137,6 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -141,95 +137,6 @@ pub fn addCases(ctx: *TestContext) !void { |
| 141 | ); | 137 | ); |
| 142 | } | 138 | } |
| 143 | 139 | ||
| 144 | { | ||
| 145 | var case = ctx.exe("hello world with updates", macos_x64); | ||
| 146 | case.addError("", &[_][]const u8{"error: no entry point found"}); | ||
| 147 | |||
| 148 | // Incorrect return type | ||
| 149 | case.addError( | ||
| 150 | \\export fn _start() noreturn { | ||
| 151 | \\} | ||
| 152 | , &[_][]const u8{":2:1: error: expected noreturn, found void"}); | ||
| 153 | |||
| 154 | // Regular old hello world | ||
| 155 | case.addCompareOutput( | ||
| 156 | \\extern "c" fn write(usize, usize, usize) usize; | ||
| 157 | \\extern "c" fn exit(usize) noreturn; | ||
| 158 | \\ | ||
| 159 | \\export fn _start() noreturn { | ||
| 160 | \\ print(); | ||
| 161 | \\ | ||
| 162 | \\ exit(0); | ||
| 163 | \\} | ||
| 164 | \\ | ||
| 165 | \\fn print() void { | ||
| 166 | \\ const msg = @ptrToInt("Hello, World!\n"); | ||
| 167 | \\ const len = 14; | ||
| 168 | \\ const nwritten = write(1, msg, len); | ||
| 169 | \\ assert(nwritten == len); | ||
| 170 | \\} | ||
| 171 | \\ | ||
| 172 | \\fn assert(ok: bool) void { | ||
| 173 | \\ if (!ok) unreachable; // assertion failure | ||
| 174 | \\} | ||
| 175 | , | ||
| 176 | "Hello, World!\n", | ||
| 177 | ); | ||
| 178 | |||
| 179 | // Now change the message only | ||
| 180 | case.addCompareOutput( | ||
| 181 | \\extern "c" fn write(usize, usize, usize) usize; | ||
| 182 | \\extern "c" fn exit(usize) noreturn; | ||
| 183 | \\ | ||
| 184 | \\export fn _start() noreturn { | ||
| 185 | \\ print(); | ||
| 186 | \\ | ||
| 187 | \\ exit(0); | ||
| 188 | \\} | ||
| 189 | \\ | ||
| 190 | \\fn print() void { | ||
| 191 | \\ const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); | ||
| 192 | \\ const len = 104; | ||
| 193 | \\ const nwritten = write(1, msg, len); | ||
| 194 | \\ assert(nwritten == len); | ||
| 195 | \\} | ||
| 196 | \\ | ||
| 197 | \\fn assert(ok: bool) void { | ||
| 198 | \\ if (!ok) unreachable; // assertion failure | ||
| 199 | \\} | ||
| 200 | , | ||
| 201 | "What is up? This is a longer message that will force the data to be relocated in virtual address space.\n", | ||
| 202 | ); | ||
| 203 | |||
| 204 | // Now we print it twice. | ||
| 205 | case.addCompareOutput( | ||
| 206 | \\extern "c" fn write(usize, usize, usize) usize; | ||
| 207 | \\extern "c" fn exit(usize) noreturn; | ||
| 208 | \\ | ||
| 209 | \\export fn _start() noreturn { | ||
| 210 | \\ print(); | ||
| 211 | \\ print(); | ||
| 212 | \\ | ||
| 213 | \\ exit(0); | ||
| 214 | \\} | ||
| 215 | \\ | ||
| 216 | \\fn print() void { | ||
| 217 | \\ const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); | ||
| 218 | \\ const len = 104; | ||
| 219 | \\ const nwritten = write(1, msg, len); | ||
| 220 | \\ assert(nwritten == len); | ||
| 221 | \\} | ||
| 222 | \\ | ||
| 223 | \\fn assert(ok: bool) void { | ||
| 224 | \\ if (!ok) unreachable; // assertion failure | ||
| 225 | \\} | ||
| 226 | , | ||
| 227 | \\What is up? This is a longer message that will force the data to be relocated in virtual address space. | ||
| 228 | \\What is up? This is a longer message that will force the data to be relocated in virtual address space. | ||
| 229 | \\ | ||
| 230 | ); | ||
| 231 | } | ||
| 232 | |||
| 233 | { | 140 | { |
| 234 | var case = ctx.exe("riscv64 hello world", linux_riscv64); | 141 | var case = ctx.exe("riscv64 hello world", linux_riscv64); |
| 235 | // Regular old hello world | 142 | // Regular old hello world |
| ... | @@ -1446,22 +1353,6 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -1446,22 +1353,6 @@ pub fn addCases(ctx: *TestContext) !void { |
| 1446 | \\} | 1353 | \\} |
| 1447 | , &[_][]const u8{":8:10: error: evaluation exceeded 1000 backwards branches"}); | 1354 | , &[_][]const u8{":8:10: error: evaluation exceeded 1000 backwards branches"}); |
| 1448 | } | 1355 | } |
| 1449 | |||
| 1450 | { | ||
| 1451 | var case = ctx.exe("only libc exit", macos_x64); | ||
| 1452 | |||
| 1453 | // This test case covers an infrequent scenarion where the string table *may* be relocated | ||
| 1454 | // into the position preceeding the symbol table which results in a dyld error. | ||
| 1455 | case.addCompareOutput( | ||
| 1456 | \\extern "c" fn exit(usize) noreturn; | ||
| 1457 | \\ | ||
| 1458 | \\export fn _start() noreturn { | ||
| 1459 | \\ exit(0); | ||
| 1460 | \\} | ||
| 1461 | , | ||
| 1462 | "", | ||
| 1463 | ); | ||
| 1464 | } | ||
| 1465 | { | 1356 | { |
| 1466 | var case = ctx.exe("orelse at comptime", linux_x64); | 1357 | var case = ctx.exe("orelse at comptime", linux_x64); |
| 1467 | case.addCompareOutput( | 1358 | case.addCompareOutput( |