| ... | @@ -0,0 +1,115 @@ |
| 1 | const std = @import("std"); |
| 2 | const TestContext = @import("../../src/test.zig").TestContext; |
| 3 | |
| 4 | const macos_aarch64 = std.zig.CrossTarget{ |
| 5 | .cpu_arch = .aarch64, |
| 6 | .os_tag = .macos, |
| 7 | }; |
| 8 | |
| 9 | pub fn addCases(ctx: *TestContext) !void { |
| 10 | // TODO enable when we add codesigning to the self-hosted linker |
| 11 | // related to #6971 |
| 12 | if (false) { |
| 13 | var case = ctx.exe("hello world with updates", macos_aarch64); |
| 14 | |
| 15 | // Regular old hello world |
| 16 | case.addCompareOutput( |
| 17 | \\export fn _start() noreturn { |
| 18 | \\ print(); |
| 19 | \\ |
| 20 | \\ exit(); |
| 21 | \\} |
| 22 | \\ |
| 23 | \\fn print() void { |
| 24 | \\ asm volatile ("svc #0x80" |
| 25 | \\ : |
| 26 | \\ : [number] "{x16}" (4), |
| 27 | \\ [arg1] "{x0}" (1), |
| 28 | \\ [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), |
| 29 | \\ [arg3] "{x2}" (14) |
| 30 | \\ : "memory" |
| 31 | \\ ); |
| 32 | \\ return; |
| 33 | \\} |
| 34 | \\ |
| 35 | \\fn exit() noreturn { |
| 36 | \\ asm volatile ("svc #0x80" |
| 37 | \\ : |
| 38 | \\ : [number] "{x16}" (1), |
| 39 | \\ [arg1] "{x0}" (0) |
| 40 | \\ : "memory" |
| 41 | \\ ); |
| 42 | \\ unreachable; |
| 43 | \\} |
| 44 | , |
| 45 | "Hello, World!\n", |
| 46 | ); |
| 47 | // Now change the message only |
| 48 | case.addCompareOutput( |
| 49 | \\export fn _start() noreturn { |
| 50 | \\ print(); |
| 51 | \\ |
| 52 | \\ exit(); |
| 53 | \\} |
| 54 | \\ |
| 55 | \\fn print() void { |
| 56 | \\ asm volatile ("svc #0x80" |
| 57 | \\ : |
| 58 | \\ : [number] "{x16}" (4), |
| 59 | \\ [arg1] "{x0}" (1), |
| 60 | \\ [arg2] "{x1}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), |
| 61 | \\ [arg3] "{x2}" (104) |
| 62 | \\ : "memory" |
| 63 | \\ ); |
| 64 | \\ return; |
| 65 | \\} |
| 66 | \\ |
| 67 | \\fn exit() noreturn { |
| 68 | \\ asm volatile ("svc #0x80" |
| 69 | \\ : |
| 70 | \\ : [number] "{x16}" (1), |
| 71 | \\ [arg1] "{x0}" (0) |
| 72 | \\ : "memory" |
| 73 | \\ ); |
| 74 | \\ unreachable; |
| 75 | \\} |
| 76 | , |
| 77 | "What is up? This is a longer message that will force the data to be relocated in virtual address space.\n", |
| 78 | ); |
| 79 | // Now we print it twice. |
| 80 | case.addCompareOutput( |
| 81 | \\export fn _start() noreturn { |
| 82 | \\ print(); |
| 83 | \\ print(); |
| 84 | \\ |
| 85 | \\ exit(); |
| 86 | \\} |
| 87 | \\ |
| 88 | \\fn print() void { |
| 89 | \\ asm volatile ("svc #0x80" |
| 90 | \\ : |
| 91 | \\ : [number] "{x16}" (4), |
| 92 | \\ [arg1] "{x0}" (1), |
| 93 | \\ [arg2] "{x1}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), |
| 94 | \\ [arg3] "{x2}" (104) |
| 95 | \\ : "memory" |
| 96 | \\ ); |
| 97 | \\ return; |
| 98 | \\} |
| 99 | \\ |
| 100 | \\fn exit() noreturn { |
| 101 | \\ asm volatile ("svc #0x80" |
| 102 | \\ : |
| 103 | \\ : [number] "{x16}" (1), |
| 104 | \\ [arg1] "{x0}" (0) |
| 105 | \\ : "memory" |
| 106 | \\ ); |
| 107 | \\ unreachable; |
| 108 | \\} |
| 109 | , |
| 110 | \\What is up? This is a longer message that will force the data to be relocated in virtual address space. |
| 111 | \\What is up? This is a longer message that will force the data to be relocated in virtual address space. |
| 112 | \\ |
| 113 | ); |
| 114 | } |
| 115 | } |