mirror of
https://github.com/ziglang/zig.git
synced 2025-12-27 16:43:07 +00:00
Merge pull request #10341 from ziglang/stage2-tests
stage2: refactor x86_64 and macOS tests
This commit is contained in:
commit
e45680cab5
@ -1635,7 +1635,7 @@ fn genBinMathOpMir(
|
||||
.tag = mir_tag,
|
||||
.ops = (Mir.Ops{
|
||||
.reg1 = registerAlias(dst_reg, @intCast(u32, abi_size)),
|
||||
.reg2 = .ebp,
|
||||
.reg2 = registerAlias(.rbp, @intCast(u32, abi_size)),
|
||||
.flags = 0b01,
|
||||
}).encode(),
|
||||
.data = .{ .imm = -@intCast(i32, adj_off) },
|
||||
@ -1666,7 +1666,7 @@ fn genBinMathOpMir(
|
||||
.tag = mir_tag,
|
||||
.ops = (Mir.Ops{
|
||||
.reg1 = registerAlias(src_reg, @intCast(u32, abi_size)),
|
||||
.reg2 = .ebp,
|
||||
.reg2 = registerAlias(.rbp, @intCast(u32, abi_size)),
|
||||
.flags = 0b10,
|
||||
}).encode(),
|
||||
.data = .{ .imm = -@intCast(i32, adj_off) },
|
||||
@ -2839,7 +2839,7 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro
|
||||
.tag = .mov,
|
||||
.ops = (Mir.Ops{
|
||||
.reg1 = registerAlias(reg, @intCast(u32, abi_size)),
|
||||
.reg2 = .ebp,
|
||||
.reg2 = registerAlias(.rbp, @intCast(u32, abi_size)),
|
||||
.flags = 0b10,
|
||||
}).encode(),
|
||||
.data = .{ .imm = -@intCast(i32, adj_off) },
|
||||
@ -3060,7 +3060,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
|
||||
.tag = .mov,
|
||||
.ops = (Mir.Ops{
|
||||
.reg1 = registerAlias(reg, @intCast(u32, abi_size)),
|
||||
.reg2 = .ebp,
|
||||
.reg2 = registerAlias(.rbp, @intCast(u32, abi_size)),
|
||||
.flags = 0b01,
|
||||
}).encode(),
|
||||
.data = .{ .imm = ioff },
|
||||
|
||||
@ -4823,8 +4823,7 @@ fn allocateAtom(self: *MachO, atom: *Atom, new_atom_size: u64, alignment: u64, m
|
||||
// should be deleted because the atom that it points to has grown to take up
|
||||
// more of the extra capacity.
|
||||
if (!big_atom.freeListEligible(self.*)) {
|
||||
const bl = free_list.swapRemove(i);
|
||||
bl.deinit(self.base.allocator);
|
||||
_ = free_list.swapRemove(i);
|
||||
} else {
|
||||
i += 1;
|
||||
}
|
||||
|
||||
1837
test/cases.zig
1837
test/cases.zig
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,18 @@
|
||||
const std = @import("std");
|
||||
const CrossTarget = std.zig.CrossTarget;
|
||||
const TestContext = @import("../../src/test.zig").TestContext;
|
||||
|
||||
const linux_aarch64 = std.zig.CrossTarget{
|
||||
const linux_aarch64 = CrossTarget{
|
||||
.cpu_arch = .aarch64,
|
||||
.os_tag = .linux,
|
||||
};
|
||||
const macos_aarch64 = CrossTarget{
|
||||
.cpu_arch = .aarch64,
|
||||
.os_tag = .macos,
|
||||
};
|
||||
|
||||
pub fn addCases(ctx: *TestContext) !void {
|
||||
// Linux tests
|
||||
{
|
||||
var case = ctx.exe("linux_aarch64 hello world", linux_aarch64);
|
||||
// Regular old hello world
|
||||
@ -97,4 +103,118 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
"Hello, World!\n",
|
||||
);
|
||||
}
|
||||
|
||||
// macOS tests
|
||||
{
|
||||
var case = ctx.exe("hello world with updates", macos_aarch64);
|
||||
case.addError("", &[_][]const u8{
|
||||
":99:9: error: struct 'tmp.tmp' has no member named 'main'",
|
||||
});
|
||||
|
||||
// Incorrect return type
|
||||
case.addError(
|
||||
\\pub export fn main() noreturn {
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
":2:1: error: expected noreturn, found void",
|
||||
});
|
||||
|
||||
// Regular old hello world
|
||||
case.addCompareOutput(
|
||||
\\extern fn write(usize, usize, usize) usize;
|
||||
\\extern fn exit(usize) noreturn;
|
||||
\\
|
||||
\\pub export fn main() noreturn {
|
||||
\\ print();
|
||||
\\
|
||||
\\ exit(0);
|
||||
\\}
|
||||
\\
|
||||
\\fn print() void {
|
||||
\\ const msg = @ptrToInt("Hello, World!\n");
|
||||
\\ const len = 14;
|
||||
\\ _ = write(1, msg, len);
|
||||
\\}
|
||||
,
|
||||
"Hello, World!\n",
|
||||
);
|
||||
|
||||
// Now using start.zig without an explicit extern exit fn
|
||||
case.addCompareOutput(
|
||||
\\extern fn write(usize, usize, usize) usize;
|
||||
\\
|
||||
\\pub fn main() void {
|
||||
\\ print();
|
||||
\\}
|
||||
\\
|
||||
\\fn print() void {
|
||||
\\ const msg = @ptrToInt("Hello, World!\n");
|
||||
\\ const len = 14;
|
||||
\\ _ = write(1, msg, len);
|
||||
\\}
|
||||
,
|
||||
"Hello, World!\n",
|
||||
);
|
||||
|
||||
// Print it 4 times and force growth and realloc.
|
||||
case.addCompareOutput(
|
||||
\\extern 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);
|
||||
\\}
|
||||
,
|
||||
\\Hello, World!
|
||||
\\Hello, World!
|
||||
\\Hello, World!
|
||||
\\Hello, World!
|
||||
\\
|
||||
);
|
||||
|
||||
// Print it once, and change the message.
|
||||
case.addCompareOutput(
|
||||
\\extern 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);
|
||||
\\}
|
||||
,
|
||||
"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(
|
||||
\\extern 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);
|
||||
\\}
|
||||
,
|
||||
\\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.
|
||||
\\
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,154 +0,0 @@
|
||||
const std = @import("std");
|
||||
const TestContext = @import("../../src/test.zig").TestContext;
|
||||
|
||||
const archs = [2]std.Target.Cpu.Arch{
|
||||
.aarch64, .x86_64,
|
||||
};
|
||||
|
||||
pub fn addCases(ctx: *TestContext) !void {
|
||||
for (archs) |arch| {
|
||||
const target: std.zig.CrossTarget = .{
|
||||
.cpu_arch = arch,
|
||||
.os_tag = .macos,
|
||||
};
|
||||
{
|
||||
var case = ctx.exe("darwin hello world with updates", target);
|
||||
case.addError("", &[_][]const u8{
|
||||
":99:9: error: struct 'tmp.tmp' has no member named 'main'",
|
||||
});
|
||||
|
||||
// Incorrect return type
|
||||
case.addError(
|
||||
\\pub export fn main() noreturn {
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
":2:1: error: expected noreturn, found void",
|
||||
});
|
||||
|
||||
// Regular old hello world
|
||||
case.addCompareOutput(
|
||||
\\extern fn write(usize, usize, usize) usize;
|
||||
\\extern fn exit(usize) noreturn;
|
||||
\\
|
||||
\\pub export fn main() noreturn {
|
||||
\\ print();
|
||||
\\
|
||||
\\ exit(0);
|
||||
\\}
|
||||
\\
|
||||
\\fn print() void {
|
||||
\\ const msg = @ptrToInt("Hello, World!\n");
|
||||
\\ const len = 14;
|
||||
\\ _ = write(1, msg, len);
|
||||
\\}
|
||||
,
|
||||
"Hello, World!\n",
|
||||
);
|
||||
|
||||
// Now using start.zig without an explicit extern exit fn
|
||||
case.addCompareOutput(
|
||||
\\extern fn write(usize, usize, usize) usize;
|
||||
\\
|
||||
\\pub fn main() void {
|
||||
\\ print();
|
||||
\\}
|
||||
\\
|
||||
\\fn print() void {
|
||||
\\ const msg = @ptrToInt("Hello, World!\n");
|
||||
\\ const len = 14;
|
||||
\\ _ = write(1, msg, len);
|
||||
\\}
|
||||
,
|
||||
"Hello, World!\n",
|
||||
);
|
||||
|
||||
// Print it 4 times and force growth and realloc.
|
||||
case.addCompareOutput(
|
||||
\\extern 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);
|
||||
\\}
|
||||
,
|
||||
\\Hello, World!
|
||||
\\Hello, World!
|
||||
\\Hello, World!
|
||||
\\Hello, World!
|
||||
\\
|
||||
);
|
||||
|
||||
// Print it once, and change the message.
|
||||
case.addCompareOutput(
|
||||
\\extern 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);
|
||||
\\}
|
||||
,
|
||||
"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(
|
||||
\\extern 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);
|
||||
\\}
|
||||
,
|
||||
\\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.
|
||||
\\
|
||||
);
|
||||
}
|
||||
{
|
||||
var case = ctx.exe("corner case - update existing, singular TextBlock", target);
|
||||
|
||||
// This test case also covers an infrequent scenario where the string table *may* be relocated
|
||||
// into the position preceeding the symbol table which results in a dyld error.
|
||||
case.addCompareOutput(
|
||||
\\extern fn exit(usize) noreturn;
|
||||
\\
|
||||
\\pub export fn main() noreturn {
|
||||
\\ exit(0);
|
||||
\\}
|
||||
,
|
||||
"",
|
||||
);
|
||||
|
||||
case.addCompareOutput(
|
||||
\\extern fn exit(usize) noreturn;
|
||||
\\extern fn write(usize, usize, usize) usize;
|
||||
\\
|
||||
\\pub export fn main() noreturn {
|
||||
\\ _ = write(1, @ptrToInt("Hey!\n"), 5);
|
||||
\\ exit(0);
|
||||
\\}
|
||||
,
|
||||
"Hey!\n",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
1976
test/stage2/x86_64.zig
Normal file
1976
test/stage2/x86_64.zig
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user