| ... | @@ -17,97 +17,60 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -17,97 +17,60 @@ pub fn addCases(ctx: *TestContext) !void { |
| 17 | | 17 | |
| 18 | // Regular old hello world | 18 | // Regular old hello world |
| 19 | case.addCompareOutput( | 19 | case.addCompareOutput( |
| | 20 | \\extern "c" fn write(usize, usize, usize) void; |
| | 21 | \\extern "c" fn exit(usize) noreturn; |
| | 22 | \\ |
| 20 | \\export fn _start() noreturn { | 23 | \\export fn _start() noreturn { |
| 21 | \\ print(); | 24 | \\ print(); |
| 22 | \\ | 25 | \\ |
| 23 | \\ exit(); | 26 | \\ exit(0); |
| 24 | \\} | 27 | \\} |
| 25 | \\ | 28 | \\ |
| 26 | \\fn print() void { | 29 | \\fn print() void { |
| 27 | \\ asm volatile ("svc #0x80" | 30 | \\ const msg = @ptrToInt("Hello, World!\n"); |
| 28 | \\ : | 31 | \\ const len = 14; |
| 29 | \\ : [number] "{x16}" (4), | 32 | \\ write(1, msg, len); |
| 30 | \\ [arg1] "{x0}" (1), | | |
| 31 | \\ [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), | | |
| 32 | \\ [arg3] "{x2}" (14) | | |
| 33 | \\ : "memory" | | |
| 34 | \\ ); | | |
| 35 | \\ return; | | |
| 36 | \\} | | |
| 37 | \\ | | |
| 38 | \\fn exit() noreturn { | | |
| 39 | \\ asm volatile ("svc #0x80" | | |
| 40 | \\ : | | |
| 41 | \\ : [number] "{x16}" (1), | | |
| 42 | \\ [arg1] "{x0}" (0) | | |
| 43 | \\ : "memory" | | |
| 44 | \\ ); | | |
| 45 | \\ unreachable; | | |
| 46 | \\} | 33 | \\} |
| 47 | , | 34 | , |
| 48 | "Hello, World!\n", | 35 | "Hello, World!\n", |
| 49 | ); | 36 | ); |
| | 37 | |
| 50 | // Now change the message only | 38 | // Now change the message only |
| 51 | case.addCompareOutput( | 39 | case.addCompareOutput( |
| | 40 | \\extern "c" fn write(usize, usize, usize) void; |
| | 41 | \\extern "c" fn exit(usize) noreturn; |
| | 42 | \\ |
| 52 | \\export fn _start() noreturn { | 43 | \\export fn _start() noreturn { |
| 53 | \\ print(); | 44 | \\ print(); |
| 54 | \\ | 45 | \\ |
| 55 | \\ exit(); | 46 | \\ exit(0); |
| 56 | \\} | 47 | \\} |
| 57 | \\ | 48 | \\ |
| 58 | \\fn print() void { | 49 | \\fn print() void { |
| 59 | \\ asm volatile ("svc #0x80" | 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"); |
| 60 | \\ : | 51 | \\ const len = 104; |
| 61 | \\ : [number] "{x16}" (4), | 52 | \\ write(1, msg, len); |
| 62 | \\ [arg1] "{x0}" (1), | | |
| 63 | \\ [arg2] "{x1}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), | | |
| 64 | \\ [arg3] "{x2}" (104) | | |
| 65 | \\ : "memory" | | |
| 66 | \\ ); | | |
| 67 | \\ return; | | |
| 68 | \\} | | |
| 69 | \\ | | |
| 70 | \\fn exit() noreturn { | | |
| 71 | \\ asm volatile ("svc #0x80" | | |
| 72 | \\ : | | |
| 73 | \\ : [number] "{x16}" (1), | | |
| 74 | \\ [arg1] "{x0}" (0) | | |
| 75 | \\ : "memory" | | |
| 76 | \\ ); | | |
| 77 | \\ unreachable; | | |
| 78 | \\} | 53 | \\} |
| 79 | , | 54 | , |
| 80 | "What is up? This is a longer message that will force the data to be relocated in virtual address space.\n", | 55 | "What is up? This is a longer message that will force the data to be relocated in virtual address space.\n", |
| 81 | ); | 56 | ); |
| | 57 | |
| 82 | // Now we print it twice. | 58 | // Now we print it twice. |
| 83 | case.addCompareOutput( | 59 | case.addCompareOutput( |
| | 60 | \\extern "c" fn write(usize, usize, usize) void; |
| | 61 | \\extern "c" fn exit(usize) noreturn; |
| | 62 | \\ |
| 84 | \\export fn _start() noreturn { | 63 | \\export fn _start() noreturn { |
| 85 | \\ print(); | 64 | \\ print(); |
| 86 | \\ print(); | 65 | \\ print(); |
| 87 | \\ | 66 | \\ |
| 88 | \\ exit(); | 67 | \\ exit(0); |
| 89 | \\} | 68 | \\} |
| 90 | \\ | 69 | \\ |
| 91 | \\fn print() void { | 70 | \\fn print() void { |
| 92 | \\ asm volatile ("svc #0x80" | 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"); |
| 93 | \\ : | 72 | \\ const len = 104; |
| 94 | \\ : [number] "{x16}" (4), | 73 | \\ write(1, msg, len); |
| 95 | \\ [arg1] "{x0}" (1), | | |
| 96 | \\ [arg2] "{x1}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), | | |
| 97 | \\ [arg3] "{x2}" (104) | | |
| 98 | \\ : "memory" | | |
| 99 | \\ ); | | |
| 100 | \\ return; | | |
| 101 | \\} | | |
| 102 | \\ | | |
| 103 | \\fn exit() noreturn { | | |
| 104 | \\ asm volatile ("svc #0x80" | | |
| 105 | \\ : | | |
| 106 | \\ : [number] "{x16}" (1), | | |
| 107 | \\ [arg1] "{x0}" (0) | | |
| 108 | \\ : "memory" | | |
| 109 | \\ ); | | |
| 110 | \\ unreachable; | | |
| 111 | \\} | 74 | \\} |
| 112 | , | 75 | , |
| 113 | \\What is up? This is a longer message that will force the data to be relocated in virtual address space. | 76 | \\What is up? This is a longer message that will force the data to be relocated in virtual address space. |
| ... | @@ -200,24 +163,6 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -200,24 +163,6 @@ pub fn addCases(ctx: *TestContext) !void { |
| 200 | ); | 163 | ); |
| 201 | } | 164 | } |
| 202 | | 165 | |
| 203 | { | | |
| 204 | var case = ctx.exe("hello world linked to libc", macos_aarch64); | | |
| 205 | | | |
| 206 | // TODO rewrite this test once we handle more int conversions and return args. | | |
| 207 | case.addCompareOutput( | | |
| 208 | \\extern "c" fn write(usize, usize, usize) void; | | |
| 209 | \\extern "c" fn exit(usize) noreturn; | | |
| 210 | \\ | | |
| 211 | \\export fn _start() noreturn { | | |
| 212 | \\ write(1, @ptrToInt("Hello,"), 6); | | |
| 213 | \\ write(1, @ptrToInt(" World!\n,"), 8); | | |
| 214 | \\ exit(0); | | |
| 215 | \\} | | |
| 216 | , | | |
| 217 | "Hello, World!\n", | | |
| 218 | ); | | |
| 219 | } | | |
| 220 | | | |
| 221 | { | 166 | { |
| 222 | var case = ctx.exe("only libc exit", macos_aarch64); | 167 | var case = ctx.exe("only libc exit", macos_aarch64); |
| 223 | | 168 | |