zig/test/behavior/bugs/10138.zig
Jakub Konka 8d5acf7693 test: recursively walk dir with tests
Prune incremental tests by moving non-incremental behavior tests to
behavior test suite instead.
2022-04-28 18:35:01 +02:00

35 lines
790 B
Zig

const std = @import("std");
const builtin = @import("builtin");
test "registers get overwritten when ignoring return" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.cpu.arch != .x86_64 or builtin.os.tag != .linux) return error.SkipZigTest;
const fd = open();
_ = write(fd, "a", 1);
_ = close(fd);
}
fn open() usize {
return 42;
}
fn write(fd: usize, a: [*]const u8, len: usize) usize {
return syscall4(.WRITE, fd, @ptrToInt(a), len);
}
fn syscall4(n: enum { WRITE }, a: usize, b: usize, c: usize) usize {
_ = n;
_ = a;
_ = b;
_ = c;
return 23;
}
fn close(fd: usize) usize {
if (fd != 42)
unreachable;
return 0;
}