Commit b17859b568

joachimschmidt557 <joachim.schmidt557@outlook.com>
2020-11-11 23:29:18
stage2 AArch64: add Linux Hello World test
1 parent 5b92d0e
Changed files (1)
test
test/stage2/aarch64.zig
@@ -6,6 +6,11 @@ const macos_aarch64 = std.zig.CrossTarget{
     .os_tag = .macos,
 };
 
+const linux_aarch64 = std.zig.CrossTarget{
+    .cpu_arch = .aarch64,
+    .os_tag = .linux,
+};
+
 pub fn addCases(ctx: *TestContext) !void {
     // TODO enable when we add codesigning to the self-hosted linker
     // related to #6971
@@ -112,4 +117,44 @@ pub fn addCases(ctx: *TestContext) !void {
             \\
         );
     }
+
+    {
+        var case = ctx.exe("hello world", linux_aarch64);
+        // Regular old hello world
+        case.addCompareOutput(
+            \\export fn _start() noreturn {
+            \\    print();
+            \\    exit();
+            \\}
+            \\
+            \\fn doNothing() void {}
+            \\
+            \\fn answer() u64 {
+            \\    return 0x1234abcd1234abcd;
+            \\}
+            \\
+            \\fn print() void {
+            \\    asm volatile ("svc #0"
+            \\        :
+            \\        : [number] "{x8}" (64),
+            \\          [arg1] "{x0}" (1),
+            \\          [arg2] "{x1}" (@ptrToInt("Hello, World!\n")),
+            \\          [arg3] "{x2}" ("Hello, World!\n".len)
+            \\        : "memory", "cc"
+            \\    );
+            \\}
+            \\
+            \\fn exit() noreturn {
+            \\    asm volatile ("svc #0"
+            \\        :
+            \\        : [number] "{x8}" (93),
+            \\          [arg1] "{x0}" (0)
+            \\        : "memory", "cc"
+            \\    );
+            \\    unreachable;
+            \\}
+        ,
+            "Hello, World!\n",
+        );
+    }
 }