| ... | ... | @@ -17,97 +17,60 @@ pub fn addCases(ctx: *TestContext) !void { |
| 17 | 17 | |
| 18 | 18 | // Regular old hello world |
| 19 | 19 | case.addCompareOutput( |
| 20 | \\extern "c" fn write(usize, usize, usize) void; |
| 21 | \\extern "c" fn exit(usize) noreturn; |
| 22 | \\ |
| 20 | 23 | \\export fn _start() noreturn { |
| 21 | 24 | \\ print(); |
| 22 | 25 | \\ |
| 23 | | \\ exit(); |
| 26 | \\ exit(0); |
| 24 | 27 | \\} |
| 25 | 28 | \\ |
| 26 | 29 | \\fn print() void { |
| 27 | | \\ asm volatile ("svc #0x80" |
| 28 | | \\ : |
| 29 | | \\ : [number] "{x16}" (4), |
| 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; |
| 30 | \\ const msg = @ptrToInt("Hello, World!\n"); |
| 31 | \\ const len = 14; |
| 32 | \\ write(1, msg, len); |
| 46 | 33 | \\} |
| 47 | 34 | , |
| 48 | 35 | "Hello, World!\n", |
| 49 | 36 | ); |
| 37 | |
| 50 | 38 | // Now change the message only |
| 51 | 39 | case.addCompareOutput( |
| 40 | \\extern "c" fn write(usize, usize, usize) void; |
| 41 | \\extern "c" fn exit(usize) noreturn; |
| 42 | \\ |
| 52 | 43 | \\export fn _start() noreturn { |
| 53 | 44 | \\ print(); |
| 54 | 45 | \\ |
| 55 | | \\ exit(); |
| 46 | \\ exit(0); |
| 56 | 47 | \\} |
| 57 | 48 | \\ |
| 58 | 49 | \\fn print() void { |
| 59 | | \\ asm volatile ("svc #0x80" |
| 60 | | \\ : |
| 61 | | \\ : [number] "{x16}" (4), |
| 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; |
| 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); |
| 78 | 53 | \\} |
| 79 | 54 | , |
| 80 | 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 | 58 | // Now we print it twice. |
| 83 | 59 | case.addCompareOutput( |
| 60 | \\extern "c" fn write(usize, usize, usize) void; |
| 61 | \\extern "c" fn exit(usize) noreturn; |
| 62 | \\ |
| 84 | 63 | \\export fn _start() noreturn { |
| 85 | 64 | \\ print(); |
| 86 | 65 | \\ print(); |
| 87 | 66 | \\ |
| 88 | | \\ exit(); |
| 67 | \\ exit(0); |
| 89 | 68 | \\} |
| 90 | 69 | \\ |
| 91 | 70 | \\fn print() void { |
| 92 | | \\ asm volatile ("svc #0x80" |
| 93 | | \\ : |
| 94 | | \\ : [number] "{x16}" (4), |
| 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; |
| 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); |
| 111 | 74 | \\} |
| 112 | 75 | , |
| 113 | 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 | 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 | 167 | var case = ctx.exe("only libc exit", macos_aarch64); |
| 223 | 168 | |