test: migrate riscv64 incremental tests

This commit is contained in:
Jakub Konka 2022-04-27 23:06:11 +02:00
parent 8e05e6a1ed
commit 7e17cbbda5
4 changed files with 48 additions and 34 deletions

View File

@ -12,7 +12,6 @@ pub fn addCases(ctx: *TestContext) !void {
try @import("stage2/arm.zig").addCases(ctx);
try @import("stage2/aarch64.zig").addCases(ctx);
try @import("stage2/llvm.zig").addCases(ctx);
try @import("stage2/riscv64.zig").addCases(ctx);
try @import("stage2/plan9.zig").addCases(ctx);
try @import("stage2/x86_64.zig").addCases(ctx);
try @import("stage2/sparcv9.zig").addCases(ctx);

View File

@ -0,0 +1,21 @@
pub fn main() void {
print();
}
fn print() void {
asm volatile ("ecall"
:
: [number] "{a7}" (64),
[arg1] "{a0}" (1),
[arg2] "{a1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{a2}" ("Hello, World!\n".len),
: "rcx", "r11", "memory"
);
return;
}
// run
// target=riscv64-linux
//
// Hello, World!
//

View File

@ -0,0 +1,27 @@
pub fn main() void {
print();
print();
print();
print();
}
fn print() void {
asm volatile ("ecall"
:
: [number] "{a7}" (64),
[arg1] "{a0}" (1),
[arg2] "{a1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{a2}" ("Hello, World!\n".len),
: "rcx", "r11", "memory"
);
return;
}
// run
// target=riscv64-linux
//
// Hello, World!
// Hello, World!
// Hello, World!
// Hello, World!
//

View File

@ -1,33 +0,0 @@
const std = @import("std");
const TestContext = @import("../../src/test.zig").TestContext;
const linux_riscv64 = std.zig.CrossTarget{
.cpu_arch = .riscv64,
.os_tag = .linux,
};
pub fn addCases(ctx: *TestContext) !void {
{
var case = ctx.exe("riscv64 hello world", linux_riscv64);
// Regular old hello world
case.addCompareOutput(
\\pub fn main() void {
\\ print();
\\}
\\
\\fn print() void {
\\ asm volatile ("ecall"
\\ :
\\ : [number] "{a7}" (64),
\\ [arg1] "{a0}" (1),
\\ [arg2] "{a1}" (@ptrToInt("Hello, World!\n")),
\\ [arg3] "{a2}" ("Hello, World!\n".len)
\\ : "rcx", "r11", "memory"
\\ );
\\ return;
\\}
,
"Hello, World!\n",
);
}
}