aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2020-11-11 15:36:47 +0100
committerJakub Konka <kubkon@jakubkonka.com>2020-11-11 15:36:47 +0100
commit5b92d0ea45af155a7d3d70aff56301e4c0aee338 (patch)
treed062ef64406588c597f149a3d0e1efc61094c56a /test
parenta6bc19ea2a2fb99ee7f09dd451b889b6a5d7f388 (diff)
downloadzig-5b92d0ea45af155a7d3d70aff56301e4c0aee338.tar.gz
zig-5b92d0ea45af155a7d3d70aff56301e4c0aee338.zip
stage2 aarch64: add macOS incremental test
Diffstat (limited to 'test')
-rw-r--r--test/stage2/aarch64.zig115
-rw-r--r--test/stage2/test.zig1
2 files changed, 116 insertions, 0 deletions
diff --git a/test/stage2/aarch64.zig b/test/stage2/aarch64.zig
new file mode 100644
index 0000000000..48cf7700c1
--- /dev/null
+++ b/test/stage2/aarch64.zig
@@ -0,0 +1,115 @@
+const std = @import("std");
+const TestContext = @import("../../src/test.zig").TestContext;
+
+const macos_aarch64 = std.zig.CrossTarget{
+ .cpu_arch = .aarch64,
+ .os_tag = .macos,
+};
+
+pub fn addCases(ctx: *TestContext) !void {
+ // TODO enable when we add codesigning to the self-hosted linker
+ // related to #6971
+ if (false) {
+ var case = ctx.exe("hello world with updates", macos_aarch64);
+
+ // Regular old hello world
+ case.addCompareOutput(
+ \\export fn _start() noreturn {
+ \\ print();
+ \\
+ \\ exit();
+ \\}
+ \\
+ \\fn print() void {
+ \\ asm volatile ("svc #0x80"
+ \\ :
+ \\ : [number] "{x16}" (4),
+ \\ [arg1] "{x0}" (1),
+ \\ [arg2] "{x1}" (@ptrToInt("Hello, World!\n")),
+ \\ [arg3] "{x2}" (14)
+ \\ : "memory"
+ \\ );
+ \\ return;
+ \\}
+ \\
+ \\fn exit() noreturn {
+ \\ asm volatile ("svc #0x80"
+ \\ :
+ \\ : [number] "{x16}" (1),
+ \\ [arg1] "{x0}" (0)
+ \\ : "memory"
+ \\ );
+ \\ unreachable;
+ \\}
+ ,
+ "Hello, World!\n",
+ );
+ // Now change the message only
+ case.addCompareOutput(
+ \\export fn _start() noreturn {
+ \\ print();
+ \\
+ \\ exit();
+ \\}
+ \\
+ \\fn print() void {
+ \\ asm volatile ("svc #0x80"
+ \\ :
+ \\ : [number] "{x16}" (4),
+ \\ [arg1] "{x0}" (1),
+ \\ [arg2] "{x1}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")),
+ \\ [arg3] "{x2}" (104)
+ \\ : "memory"
+ \\ );
+ \\ return;
+ \\}
+ \\
+ \\fn exit() noreturn {
+ \\ asm volatile ("svc #0x80"
+ \\ :
+ \\ : [number] "{x16}" (1),
+ \\ [arg1] "{x0}" (0)
+ \\ : "memory"
+ \\ );
+ \\ unreachable;
+ \\}
+ ,
+ "What is up? This is a longer message that will force the data to be relocated in virtual address space.\n",
+ );
+ // Now we print it twice.
+ case.addCompareOutput(
+ \\export fn _start() noreturn {
+ \\ print();
+ \\ print();
+ \\
+ \\ exit();
+ \\}
+ \\
+ \\fn print() void {
+ \\ asm volatile ("svc #0x80"
+ \\ :
+ \\ : [number] "{x16}" (4),
+ \\ [arg1] "{x0}" (1),
+ \\ [arg2] "{x1}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")),
+ \\ [arg3] "{x2}" (104)
+ \\ : "memory"
+ \\ );
+ \\ return;
+ \\}
+ \\
+ \\fn exit() noreturn {
+ \\ asm volatile ("svc #0x80"
+ \\ :
+ \\ : [number] "{x16}" (1),
+ \\ [arg1] "{x0}" (0)
+ \\ : "memory"
+ \\ );
+ \\ unreachable;
+ \\}
+ ,
+ \\What is up? This is a longer message that will force the data to be relocated in virtual address space.
+ \\What is up? This is a longer message that will force the data to be relocated in virtual address space.
+ \\
+ );
+ }
+}
diff --git a/test/stage2/test.zig b/test/stage2/test.zig
index 51bde87ab0..032838eaf9 100644
--- a/test/stage2/test.zig
+++ b/test/stage2/test.zig
@@ -31,6 +31,7 @@ pub fn addCases(ctx: *TestContext) !void {
try @import("cbe.zig").addCases(ctx);
try @import("spu-ii.zig").addCases(ctx);
try @import("arm.zig").addCases(ctx);
+ try @import("aarch64.zig").addCases(ctx);
{
var case = ctx.exe("hello world with updates", linux_x64);