Unify incremental test cases and disable many

The self-hosted aarch64 backend is not currently functional due to the
Liveness changes. A previous commit disabled aarch64 on the behavior
tests; this commit disables it and arm for the test cases. Moreover, all
incremental test cases have been unified into shared cross-platform
cases, which can be gradually enabled as the backends improve.
This commit is contained in:
mlugg 2023-04-19 14:17:48 +01:00
parent 52fe2ebee8
commit b3f9fe6d04
No known key found for this signature in database
GPG key ID: 58978E823BDE3EF9
157 changed files with 304 additions and 1386 deletions

View file

@ -1,26 +0,0 @@
pub fn main() void {
foo(123);
}
fn foo(x: u64) void {
if (x > 42) {
print();
}
}
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"
);
}
// run
// target=aarch64-linux
//
// Hello, World!
//

View file

@ -1,25 +0,0 @@
pub fn main() void {
foo(true);
}
fn foo(x: bool) void {
if (x) {
print();
}
}
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"
);
}
// run
//
// Hello, World!
//

View file

@ -1,31 +0,0 @@
pub export fn _start() noreturn {
print();
exit(0);
}
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(ret: usize) noreturn {
asm volatile ("svc #0"
:
: [number] "{x8}" (93),
[arg1] "{x0}" (ret),
: "memory", "cc"
);
unreachable;
}
// run
// target=aarch64-linux
//
// Hello, World!
//

View file

@ -1,36 +0,0 @@
pub export fn _start() noreturn {
print();
print();
print();
print();
exit(0);
}
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(ret: usize) noreturn {
asm volatile ("svc #0"
:
: [number] "{x8}" (93),
[arg1] "{x0}" (ret),
: "memory", "cc"
);
unreachable;
}
// run
//
// Hello, World!
// Hello, World!
// Hello, World!
// Hello, World!
//

View file

@ -1,21 +0,0 @@
pub fn main() void {
print();
print();
}
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"
);
}
// run
//
// Hello, World!
// Hello, World!
//

View file

@ -1,22 +0,0 @@
extern "c" fn write(usize, usize, usize) usize;
pub fn main() void {
print();
print();
print();
print();
}
fn print() void {
const msg = @ptrToInt("Hello, World!\n");
const len = 14;
_ = write(1, msg, len);
}
// run
//
// Hello, World!
// Hello, World!
// Hello, World!
// Hello, World!
//

View file

@ -1,16 +0,0 @@
extern "c" fn write(usize, usize, usize) usize;
pub fn main() void {
print();
}
fn print() void {
const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
const len = 104;
_ = write(1, msg, len);
}
// run
//
// What is up? This is a longer message that will force the data to be relocated in virtual address space.
//

View file

@ -1,18 +0,0 @@
extern "c" fn write(usize, usize, usize) usize;
pub fn main() void {
print();
print();
}
fn print() void {
const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
const len = 104;
_ = write(1, msg, len);
}
// run
//
// 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.
//

View file

@ -0,0 +1,17 @@
const std = @import("std");
pub fn main() void {
print(2, 4);
print(1, 7);
}
fn print(a: u32, b: u32) void {
const str = "123456789";
const len = a + b;
_ = std.os.write(1, str[0..len]) catch {};
}
// run
// target=x86_64-linux,x86_64-macos
//
// 12345612345678

View file

@ -0,0 +1,16 @@
const std = @import("std");
pub fn main() void {
print(10, 5);
print(4, 3);
}
fn print(a: u32, b: u32) void {
const str = "123456789";
const len = a - b;
_ = std.os.write(1, str[0..len]) catch {};
}
// run
//
// 123451

View file

@ -0,0 +1,16 @@
const std = @import("std");
pub fn main() void {
print(8, 9);
print(3, 7);
}
fn print(a: u32, b: u32) void {
const str = "123456789";
const len = a & b;
_ = std.os.write(1, str[0..len]) catch {};
}
// run
//
// 12345678123

View file

@ -0,0 +1,16 @@
const std = @import("std");
pub fn main() void {
print(4, 2);
print(3, 7);
}
fn print(a: u32, b: u32) void {
const str = "123456789";
const len = a | b;
_ = std.os.write(1, str[0..len]) catch {};
}
// run
//
// 1234561234567

View file

@ -0,0 +1,16 @@
const std = @import("std");
pub fn main() void {
print(42, 42);
print(3, 5);
}
fn print(a: u32, b: u32) void {
const str = "123456789";
const len = a ^ b;
_ = std.os.write(1, str[0..len]) catch {};
}
// run
//
// 123456

View file

@ -1,21 +0,0 @@
pub fn main() void {
print(2, 4);
print(1, 7);
}
fn print(a: u32, b: u32) void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg3] "{r2}" (a + b),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("123456789")),
: "memory"
);
return;
}
// run
// target=arm-linux
//
// 12345612345678

View file

@ -1,20 +0,0 @@
pub fn main() void {
print(10, 5);
print(4, 3);
}
fn print(a: u32, b: u32) void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg3] "{r2}" (a - b),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("123456789")),
: "memory"
);
return;
}
// run
//
// 123451

View file

@ -1,20 +0,0 @@
pub fn main() void {
print(8, 9);
print(3, 7);
}
fn print(a: u32, b: u32) void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg3] "{r2}" (a & b),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("123456789")),
: "memory"
);
return;
}
// run
//
// 12345678123

View file

@ -1,20 +0,0 @@
pub fn main() void {
print(4, 2);
print(3, 7);
}
fn print(a: u32, b: u32) void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg3] "{r2}" (a | b),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("123456789")),
: "memory"
);
return;
}
// run
//
// 1234561234567

View file

@ -1,20 +0,0 @@
pub fn main() void {
print(42, 42);
print(3, 5);
}
fn print(a: u32, b: u32) void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg3] "{r2}" (a ^ b),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("123456789")),
: "memory"
);
return;
}
// run
//
// 123456

View file

@ -1,21 +0,0 @@
pub fn main() void {
foo() catch print();
}
fn foo() anyerror!void {}
fn print() void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{r2}" ("Hello, World!\n".len),
: "memory"
);
return;
}
// run
// target=arm-linux
//

View file

@ -1,24 +0,0 @@
pub fn main() void {
foo() catch print();
}
fn foo() anyerror!void {
return error.Test;
}
fn print() void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{r2}" ("Hello, World!\n".len),
: "memory"
);
return;
}
// run
//
// Hello, World!
//

View file

@ -1,44 +0,0 @@
const PrintFn = *const fn () void;
pub fn main() void {
var printFn: PrintFn = stopSayingThat;
var i: u32 = 0;
while (i < 4) : (i += 1) printFn();
printFn = moveEveryZig;
printFn();
}
fn stopSayingThat() void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("Hello, my name is Inigo Montoya; you killed my father, prepare to die.\n")),
[arg3] "{r2}" ("Hello, my name is Inigo Montoya; you killed my father, prepare to die.\n".len),
: "memory"
);
return;
}
fn moveEveryZig() void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("All your codebase are belong to us\n")),
[arg3] "{r2}" ("All your codebase are belong to us\n".len),
: "memory"
);
return;
}
// run
// target=arm-linux
//
// Hello, my name is Inigo Montoya; you killed my father, prepare to die.
// Hello, my name is Inigo Montoya; you killed my father, prepare to die.
// Hello, my name is Inigo Montoya; you killed my father, prepare to die.
// Hello, my name is Inigo Montoya; you killed my father, prepare to die.
// All your codebase are belong to us
//

View file

@ -1,32 +0,0 @@
pub export fn _start() noreturn {
print();
exit();
}
fn print() void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{r2}" (14),
: "memory"
);
return;
}
fn exit() noreturn {
asm volatile ("svc #0"
:
: [number] "{r7}" (1),
[arg1] "{r0}" (0),
: "memory"
);
unreachable;
}
// run
// target=arm-linux
//
// Hello, World!
//

View file

@ -1,37 +0,0 @@
pub export fn _start() noreturn {
print();
print();
print();
print();
exit();
}
fn print() void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{r2}" (14),
: "memory"
);
return;
}
fn exit() noreturn {
asm volatile ("svc #0"
:
: [number] "{r7}" (1),
[arg1] "{r0}" (0),
: "memory"
);
unreachable;
}
// run
//
// Hello, World!
// Hello, World!
// Hello, World!
// Hello, World!
//

View file

@ -1,22 +0,0 @@
pub fn main() void {
print();
print();
}
fn print() void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{r2}" (14),
: "memory"
);
return;
}
// run
//
// Hello, World!
// Hello, World!
//

View file

@ -1,28 +0,0 @@
pub fn main() void {
print(id(14));
}
fn id(x: u32) u32 {
return x;
}
// TODO: The parameters to the asm statement in print() had to
// be in a specific order because otherwise the write to r0
// would overwrite the len parameter which resides in r0
fn print(len: u32) void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg3] "{r2}" (len),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("Hello, World!\n")),
: "memory"
);
return;
}
// run
// target=arm-linux
//
// Hello, World!
//

View file

@ -1,40 +0,0 @@
pub fn main() void {
printNumberHex(0x00000000);
printNumberHex(0xaaaaaaaa);
printNumberHex(0xdeadbeef);
printNumberHex(0x31415926);
}
fn printNumberHex(x: u32) void {
var i: u5 = 28;
while (true) : (i -= 4) {
const digit = (x >> i) & 0xf;
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("0123456789abcdef") + digit),
[arg3] "{r2}" (1),
: "memory"
);
if (i == 0) break;
}
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("\n")),
[arg3] "{r2}" (1),
: "memory"
);
}
// run
// target=arm-linux
//
// 00000000
// aaaaaaaa
// deadbeef
// 31415926
//

View file

@ -11,5 +11,5 @@ pub fn assert(ok: bool) void {
}
// run
// target=x86_64-linux
//
// target=x86_64-macos,x86_64-linux
// link_libc=true

View file

@ -0,0 +1,20 @@
const builtin = @import("builtin");
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
for ("hello") |_| print();
}
fn print() void {
_ = write(1, @ptrToInt("hello\n"), 6);
}
// run
//
// hello
// hello
// hello
// hello
// hello
//

View file

@ -1,4 +1,4 @@
extern "c" fn write(usize, usize, usize) usize;
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
var i: u32 = 0;

View file

@ -1,4 +1,4 @@
extern "c" fn write(usize, usize, usize) usize;
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
var i: u32 = 0;

View file

@ -5,5 +5,5 @@ pub fn main() void {
}
// run
// target=x86_64-linux,x86_64-macos,aarch64-linux,aarch64-macos
// target=x86_64-linux,x86_64-macos
//

View file

@ -6,7 +6,8 @@ pub fn main() void {
// error
// output_mode=Exe
// target=x86_64-linux
// target=x86_64-macos,x86_64-linux
// link_libc=true
//
// :4:19: error: store to comptime variable depends on runtime condition
// :4:11: note: runtime condition here

View file

@ -1,4 +1,4 @@
extern "c" fn write(usize, usize, usize) usize;
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
comptime var len: u32 = 5;

View file

@ -1,4 +1,4 @@
extern "c" fn write(usize, usize, usize) usize;
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
comptime var i: u64 = 2;

View file

@ -0,0 +1,23 @@
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
foo(123);
}
fn foo(x: u64) void {
if (x > 42) {
print();
}
}
fn print() void {
const str = "Hello, World!\n";
_ = write(1, @ptrToInt(str.ptr), ptr.len);
}
// run
// target=x86_64-linux,x86_64-macos
// link_libc=true
//
// Hello, World!
//

View file

@ -0,0 +1,25 @@
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
foo(true);
}
fn foo(x: bool) void {
if (x) {
print();
print();
} else {
print();
}
}
fn print() void {
const str = "Hello, World!\n";
_ = write(1, @ptrToInt(str.ptr), ptr.len);
}
// run
//
// Hello, World!
// Hello, World!
//

15
test/cases/errors.0.zig Normal file
View file

@ -0,0 +1,15 @@
const std = @import("std");
pub fn main() void {
foo() catch print();
}
fn foo() anyerror!void {}
fn print() void {
_ = std.os.write(1, "Hello, World!\n") catch {};
}
// run
// target=x86_64-macos
//

18
test/cases/errors.1.zig Normal file
View file

@ -0,0 +1,18 @@
const std = @import("std");
pub fn main() void {
foo() catch print();
}
fn foo() anyerror!void {
return error.Test;
}
fn print() void {
_ = std.os.write(1, "Hello, World!\n") catch {};
}
// run
//
// Hello, World!
//

5
test/cases/exit.zig Normal file
View file

@ -0,0 +1,5 @@
pub fn main() void {}
// run
// target=x86_64-linux,x86_64-macos,x86_64-windows,x86_64-plan9
//

View file

@ -0,0 +1,30 @@
const std = @import("std");
const PrintFn = *const fn () void;
pub fn main() void {
var printFn: PrintFn = stopSayingThat;
var i: u32 = 0;
while (i < 4) : (i += 1) printFn();
printFn = moveEveryZig;
printFn();
}
fn stopSayingThat() void {
_ = std.os.write(1, "Hello, my name is Inigo Montoya; you killed my father, prepare to die.\n") catch {};
}
fn moveEveryZig() void {
_ = std.os.write(1, "All your codebase are belong to us\n") catch {};
}
// run
// target=x86_64-macos
//
// Hello, my name is Inigo Montoya; you killed my father, prepare to die.
// Hello, my name is Inigo Montoya; you killed my father, prepare to die.
// Hello, my name is Inigo Montoya; you killed my father, prepare to die.
// Hello, my name is Inigo Montoya; you killed my father, prepare to die.
// All your codebase are belong to us
//

View file

@ -1,5 +1,6 @@
// error
// output_mode=Exe
// target=aarch64-macos
// target=x86_64-linux,x86_64-macos
// link_libc=true
//
// :?:?: error: root struct of file 'tmp' has no member named 'main'

View file

@ -1,5 +1,5 @@
extern "c" fn write(usize, usize, usize) usize;
extern "c" fn exit(usize) noreturn;
extern "c" fn write(c_int, usize, usize) usize;
extern "c" fn exit(c_int) noreturn;
pub export fn main() noreturn {
print();

View file

@ -1,4 +1,4 @@
extern "c" fn write(usize, usize, usize) usize;
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
print();

View file

@ -1,4 +1,4 @@
extern "c" fn write(usize, usize, usize) usize;
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
print();

View file

@ -1,4 +1,4 @@
extern "c" fn write(usize, usize, usize) usize;
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
print();

View file

@ -1,4 +1,6 @@
extern "c" fn write(usize, usize, usize) usize;
const builtin = @import("builtin");
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
print();

View file

@ -33,6 +33,8 @@ fn assert(ok: bool) void {
if (!ok) unreachable;
}
// TODO: enable this for native backend
// run
// backend=llvm
// target=aarch64-linux,aarch64-macos
//

View file

@ -0,0 +1,7 @@
pub export fn _start() noreturn {
while (true) {}
}
// run
// target=x86_64-linux,x86_64-macos
//

View file

@ -0,0 +1,8 @@
pub export fn _start() noreturn {
var dummy: u32 = 10;
_ = dummy;
while (true) {}
}
// run
//

View file

@ -0,0 +1,20 @@
const std = @import("std");
pub fn main() void {
print(id(14));
}
fn id(x: u32) u32 {
return x;
}
fn print(len: u32) void {
const str = "Hello, World!\n";
_ = std.os.write(1, str[0..len]) catch {};
}
// run
// target=x86_64-macos
//
// Hello, World!
//

View file

@ -1,5 +0,0 @@
pub fn main() void {}
// run
// target=x86_64-plan9
//

View file

@ -1,28 +0,0 @@
pub fn main() void {
const str = "Hello World!\n";
asm volatile (
\\push $0
\\push %%r10
\\push %%r11
\\push $1
\\push $0
\\syscall
\\pop %%r11
\\pop %%r11
\\pop %%r11
\\pop %%r11
\\pop %%r11
:
// pwrite
: [syscall_number] "{rbp}" (51),
[hey] "{r11}" (@ptrToInt(str)),
[strlen] "{r10}" (str.len),
: "rcx", "rbp", "r11", "memory"
);
}
// run
// target=x86_64-plan9
//
// Hello World
//

View file

@ -1,11 +0,0 @@
const std = @import("std");
pub fn main() void {
const str = "Hello World!\n";
_ = std.os.plan9.pwrite(1, str, str.len, 0);
}
// run
// target=x86_64-plan9
//
// Hello World
//

28
test/cases/print_u32s.zig Normal file
View file

@ -0,0 +1,28 @@
const std = @import("std");
pub fn main() void {
printNumberHex(0x00000000);
printNumberHex(0xaaaaaaaa);
printNumberHex(0xdeadbeef);
printNumberHex(0x31415926);
}
fn printNumberHex(x: u32) void {
const digit_chars = "0123456789abcdef";
var i: u5 = 28;
while (true) : (i -= 4) {
const digit = (x >> i) & 0xf;
_ = std.os.write(1, &.{digit_chars[digit]}) catch {};
if (i == 0) break;
}
_ = std.os.write(1, "\n") catch {};
}
// run
// target=x86_64-macos
//
// 00000000
// aaaaaaaa
// deadbeef
// 31415926
//

Some files were not shown because too many files have changed in this diff Show more