mirror of
https://github.com/ziglang/zig.git
synced 2026-02-20 00:08:56 +00:00
Merge pull request #15277 from ziglang/tests
add CI test coverage for more target combinations
This commit is contained in:
commit
b0186f3100
21
build.zig
21
build.zig
@ -85,9 +85,7 @@ pub fn build(b: *std.Build) !void {
|
||||
const skip_cross_glibc = b.option(bool, "skip-cross-glibc", "Main test suite skips builds that require cross glibc") orelse false;
|
||||
const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false;
|
||||
const skip_single_threaded = b.option(bool, "skip-single-threaded", "Main test suite skips tests that are single-threaded") orelse false;
|
||||
const skip_stage1 = b.option(bool, "skip-stage1", "Main test suite skips stage1 compile error tests") orelse false;
|
||||
const skip_run_translated_c = b.option(bool, "skip-run-translated-c", "Main test suite skips run-translated-c tests") orelse false;
|
||||
const skip_stage2_tests = b.option(bool, "skip-stage2-tests", "Main test suite skips self-hosted compiler tests") orelse false;
|
||||
|
||||
const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;
|
||||
|
||||
@ -187,9 +185,7 @@ pub fn build(b: *std.Build) !void {
|
||||
const compile_step = b.step("compile", "Build the self-hosted compiler");
|
||||
compile_step.dependOn(&exe.step);
|
||||
|
||||
if (!skip_stage2_tests) {
|
||||
test_step.dependOn(&exe.step);
|
||||
}
|
||||
test_step.dependOn(&exe.step);
|
||||
|
||||
exe.single_threaded = single_threaded;
|
||||
|
||||
@ -360,7 +356,6 @@ pub fn build(b: *std.Build) !void {
|
||||
test_cases_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots);
|
||||
test_cases_options.addOption(bool, "skip_non_native", skip_non_native);
|
||||
test_cases_options.addOption(bool, "skip_cross_glibc", skip_cross_glibc);
|
||||
test_cases_options.addOption(bool, "skip_stage1", skip_stage1);
|
||||
test_cases_options.addOption(bool, "have_llvm", enable_llvm);
|
||||
test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k);
|
||||
test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky);
|
||||
@ -416,7 +411,7 @@ pub fn build(b: *std.Build) !void {
|
||||
|
||||
const test_cases_step = b.step("test-cases", "Run the main compiler test cases");
|
||||
try tests.addCases(b, test_cases_step, test_filter, check_case_exe);
|
||||
if (!skip_stage2_tests) test_step.dependOn(test_cases_step);
|
||||
test_step.dependOn(test_cases_step);
|
||||
|
||||
test_step.dependOn(tests.addModuleTests(b, .{
|
||||
.test_filter = test_filter,
|
||||
@ -428,8 +423,6 @@ pub fn build(b: *std.Build) !void {
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_cross_glibc = skip_cross_glibc,
|
||||
.skip_libc = skip_libc,
|
||||
.skip_stage1 = skip_stage1,
|
||||
.skip_stage2 = skip_stage2_tests,
|
||||
.max_rss = 1 * 1024 * 1024 * 1024,
|
||||
}));
|
||||
|
||||
@ -443,8 +436,6 @@ pub fn build(b: *std.Build) !void {
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_cross_glibc = skip_cross_glibc,
|
||||
.skip_libc = true,
|
||||
.skip_stage1 = skip_stage1,
|
||||
.skip_stage2 = true, // TODO get all these passing
|
||||
}));
|
||||
|
||||
test_step.dependOn(tests.addModuleTests(b, .{
|
||||
@ -457,8 +448,6 @@ pub fn build(b: *std.Build) !void {
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_cross_glibc = skip_cross_glibc,
|
||||
.skip_libc = true,
|
||||
.skip_stage1 = skip_stage1,
|
||||
.skip_stage2 = true, // TODO get all these passing
|
||||
}));
|
||||
|
||||
test_step.dependOn(tests.addCompareOutputTests(b, test_filter, optimization_modes));
|
||||
@ -466,11 +455,11 @@ pub fn build(b: *std.Build) !void {
|
||||
b,
|
||||
optimization_modes,
|
||||
enable_macos_sdk,
|
||||
skip_stage2_tests,
|
||||
false,
|
||||
enable_symlinks_windows,
|
||||
));
|
||||
test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release));
|
||||
test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, skip_stage2_tests, enable_symlinks_windows));
|
||||
test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, false, enable_symlinks_windows));
|
||||
test_step.dependOn(tests.addStackTraceTests(b, test_filter, optimization_modes));
|
||||
test_step.dependOn(tests.addCliTests(b));
|
||||
test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, optimization_modes));
|
||||
@ -489,8 +478,6 @@ pub fn build(b: *std.Build) !void {
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_cross_glibc = skip_cross_glibc,
|
||||
.skip_libc = skip_libc,
|
||||
.skip_stage1 = skip_stage1,
|
||||
.skip_stage2 = true, // TODO get all these passing
|
||||
// I observed a value of 3398275072 on my M1, and multiplied by 1.1 to
|
||||
// get this amount:
|
||||
.max_rss = 3738102579,
|
||||
|
||||
@ -6,7 +6,8 @@ pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal el
|
||||
/// Determines the symbol's visibility to other objects.
|
||||
/// For WebAssembly this allows the symbol to be resolved to other modules, but will not
|
||||
/// export it to the host runtime.
|
||||
pub const visibility: std.builtin.SymbolVisibility = if (builtin.target.isWasm()) .hidden else .default;
|
||||
pub const visibility: std.builtin.SymbolVisibility =
|
||||
if (builtin.target.isWasm() and linkage != .Internal) .hidden else .default;
|
||||
pub const want_aeabi = switch (builtin.abi) {
|
||||
.eabi,
|
||||
.eabihf,
|
||||
|
||||
@ -454,6 +454,10 @@ pub const ExecutableOptions = struct {
|
||||
optimize: std.builtin.Mode = .Debug,
|
||||
linkage: ?CompileStep.Linkage = null,
|
||||
max_rss: usize = 0,
|
||||
link_libc: ?bool = null,
|
||||
single_threaded: ?bool = null,
|
||||
use_llvm: ?bool = null,
|
||||
use_lld: ?bool = null,
|
||||
};
|
||||
|
||||
pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {
|
||||
@ -466,6 +470,10 @@ pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {
|
||||
.kind = .exe,
|
||||
.linkage = options.linkage,
|
||||
.max_rss = options.max_rss,
|
||||
.link_libc = options.link_libc,
|
||||
.single_threaded = options.single_threaded,
|
||||
.use_llvm = options.use_llvm,
|
||||
.use_lld = options.use_lld,
|
||||
});
|
||||
}
|
||||
|
||||
@ -475,6 +483,10 @@ pub const ObjectOptions = struct {
|
||||
target: CrossTarget,
|
||||
optimize: std.builtin.Mode,
|
||||
max_rss: usize = 0,
|
||||
link_libc: ?bool = null,
|
||||
single_threaded: ?bool = null,
|
||||
use_llvm: ?bool = null,
|
||||
use_lld: ?bool = null,
|
||||
};
|
||||
|
||||
pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {
|
||||
@ -485,6 +497,10 @@ pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {
|
||||
.optimize = options.optimize,
|
||||
.kind = .obj,
|
||||
.max_rss = options.max_rss,
|
||||
.link_libc = options.link_libc,
|
||||
.single_threaded = options.single_threaded,
|
||||
.use_llvm = options.use_llvm,
|
||||
.use_lld = options.use_lld,
|
||||
});
|
||||
}
|
||||
|
||||
@ -495,6 +511,10 @@ pub const SharedLibraryOptions = struct {
|
||||
target: CrossTarget,
|
||||
optimize: std.builtin.Mode,
|
||||
max_rss: usize = 0,
|
||||
link_libc: ?bool = null,
|
||||
single_threaded: ?bool = null,
|
||||
use_llvm: ?bool = null,
|
||||
use_lld: ?bool = null,
|
||||
};
|
||||
|
||||
pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {
|
||||
@ -507,6 +527,10 @@ pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {
|
||||
.target = options.target,
|
||||
.optimize = options.optimize,
|
||||
.max_rss = options.max_rss,
|
||||
.link_libc = options.link_libc,
|
||||
.single_threaded = options.single_threaded,
|
||||
.use_llvm = options.use_llvm,
|
||||
.use_lld = options.use_lld,
|
||||
});
|
||||
}
|
||||
|
||||
@ -517,6 +541,10 @@ pub const StaticLibraryOptions = struct {
|
||||
optimize: std.builtin.Mode,
|
||||
version: ?std.builtin.Version = null,
|
||||
max_rss: usize = 0,
|
||||
link_libc: ?bool = null,
|
||||
single_threaded: ?bool = null,
|
||||
use_llvm: ?bool = null,
|
||||
use_lld: ?bool = null,
|
||||
};
|
||||
|
||||
pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {
|
||||
@ -529,6 +557,10 @@ pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {
|
||||
.target = options.target,
|
||||
.optimize = options.optimize,
|
||||
.max_rss = options.max_rss,
|
||||
.link_libc = options.link_libc,
|
||||
.single_threaded = options.single_threaded,
|
||||
.use_llvm = options.use_llvm,
|
||||
.use_lld = options.use_lld,
|
||||
});
|
||||
}
|
||||
|
||||
@ -541,6 +573,10 @@ pub const TestOptions = struct {
|
||||
max_rss: usize = 0,
|
||||
filter: ?[]const u8 = null,
|
||||
test_runner: ?[]const u8 = null,
|
||||
link_libc: ?bool = null,
|
||||
single_threaded: ?bool = null,
|
||||
use_llvm: ?bool = null,
|
||||
use_lld: ?bool = null,
|
||||
};
|
||||
|
||||
pub fn addTest(b: *Build, options: TestOptions) *CompileStep {
|
||||
@ -553,6 +589,10 @@ pub fn addTest(b: *Build, options: TestOptions) *CompileStep {
|
||||
.max_rss = options.max_rss,
|
||||
.filter = options.filter,
|
||||
.test_runner = options.test_runner,
|
||||
.link_libc = options.link_libc,
|
||||
.single_threaded = options.single_threaded,
|
||||
.use_llvm = options.use_llvm,
|
||||
.use_lld = options.use_lld,
|
||||
});
|
||||
}
|
||||
|
||||
@ -639,8 +679,7 @@ pub fn addRunArtifact(b: *Build, exe: *CompileStep) *RunStep {
|
||||
run_step.addArtifactArg(exe);
|
||||
|
||||
if (exe.kind == .@"test") {
|
||||
run_step.stdio = .zig_test;
|
||||
run_step.addArgs(&.{"--listen=-"});
|
||||
run_step.enableTestRunnerMode();
|
||||
}
|
||||
|
||||
if (exe.vcpkg_bin_path) |path| {
|
||||
|
||||
@ -63,7 +63,7 @@ emit_llvm_ir: EmitOption = .default,
|
||||
// so it is not an EmitOption for now.
|
||||
emit_h: bool = false,
|
||||
bundle_compiler_rt: ?bool = null,
|
||||
single_threaded: ?bool = null,
|
||||
single_threaded: ?bool,
|
||||
stack_protector: ?bool = null,
|
||||
disable_stack_probing: bool,
|
||||
disable_sanitize_c: bool,
|
||||
@ -101,8 +101,8 @@ link_objects: ArrayList(LinkObject),
|
||||
include_dirs: ArrayList(IncludeDir),
|
||||
c_macros: ArrayList([]const u8),
|
||||
installed_headers: ArrayList(*Step),
|
||||
is_linking_libc: bool = false,
|
||||
is_linking_libcpp: bool = false,
|
||||
is_linking_libc: bool,
|
||||
is_linking_libcpp: bool,
|
||||
vcpkg_bin_path: ?[]const u8 = null,
|
||||
|
||||
/// This may be set in order to override the default install directory
|
||||
@ -207,8 +207,8 @@ force_undefined_symbols: std.StringHashMap(void),
|
||||
stack_size: ?u64 = null,
|
||||
|
||||
want_lto: ?bool = null,
|
||||
use_llvm: ?bool = null,
|
||||
use_lld: ?bool = null,
|
||||
use_llvm: ?bool,
|
||||
use_lld: ?bool,
|
||||
|
||||
/// This is an advanced setting that can change the intent of this CompileStep.
|
||||
/// If this slice has nonzero length, it means that this CompileStep exists to
|
||||
@ -287,6 +287,10 @@ pub const Options = struct {
|
||||
max_rss: usize = 0,
|
||||
filter: ?[]const u8 = null,
|
||||
test_runner: ?[]const u8 = null,
|
||||
link_libc: ?bool = null,
|
||||
single_threaded: ?bool = null,
|
||||
use_llvm: ?bool = null,
|
||||
use_lld: ?bool = null,
|
||||
};
|
||||
|
||||
pub const Kind = enum {
|
||||
@ -412,6 +416,12 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep {
|
||||
.output_dirname_source = GeneratedFile{ .step = &self.step },
|
||||
|
||||
.target_info = target_info,
|
||||
|
||||
.is_linking_libc = options.link_libc orelse false,
|
||||
.is_linking_libcpp = false,
|
||||
.single_threaded = options.single_threaded,
|
||||
.use_llvm = options.use_llvm,
|
||||
.use_lld = options.use_lld,
|
||||
};
|
||||
|
||||
if (self.kind == .lib) {
|
||||
|
||||
@ -140,6 +140,11 @@ pub fn setName(self: *RunStep, name: []const u8) void {
|
||||
self.rename_step_with_output_arg = false;
|
||||
}
|
||||
|
||||
pub fn enableTestRunnerMode(rs: *RunStep) void {
|
||||
rs.stdio = .zig_test;
|
||||
rs.addArgs(&.{"--listen=-"});
|
||||
}
|
||||
|
||||
pub fn addArtifactArg(self: *RunStep, artifact: *CompileStep) void {
|
||||
self.argv.append(Arg{ .artifact = artifact }) catch @panic("OOM");
|
||||
self.step.dependOn(&artifact.step);
|
||||
|
||||
@ -104,11 +104,9 @@ pub fn receiveMessage(s: *Server) !InMessage.Header {
|
||||
const buf = fifo.readableSlice(0);
|
||||
assert(fifo.readableLength() == buf.len);
|
||||
if (buf.len >= @sizeOf(Header)) {
|
||||
const header = @ptrCast(*align(1) const Header, buf[0..@sizeOf(Header)]);
|
||||
// workaround for https://github.com/ziglang/zig/issues/14904
|
||||
const bytes_len = bswap_and_workaround_u32(&header.bytes_len);
|
||||
// workaround for https://github.com/ziglang/zig/issues/14904
|
||||
const tag = bswap_and_workaround_tag(&header.tag);
|
||||
const bytes_len = bswap_and_workaround_u32(buf[4..][0..4]);
|
||||
const tag = bswap_and_workaround_tag(buf[0..][0..4]);
|
||||
|
||||
if (buf.len - @sizeOf(Header) >= bytes_len) {
|
||||
fifo.discard(@sizeOf(Header));
|
||||
@ -281,14 +279,12 @@ fn bswap_u32_array(slice: []u32) void {
|
||||
}
|
||||
|
||||
/// workaround for https://github.com/ziglang/zig/issues/14904
|
||||
fn bswap_and_workaround_u32(x: *align(1) const u32) u32 {
|
||||
const bytes_ptr = @ptrCast(*const [4]u8, x);
|
||||
fn bswap_and_workaround_u32(bytes_ptr: *const [4]u8) u32 {
|
||||
return std.mem.readIntLittle(u32, bytes_ptr);
|
||||
}
|
||||
|
||||
/// workaround for https://github.com/ziglang/zig/issues/14904
|
||||
fn bswap_and_workaround_tag(x: *align(1) const InMessage.Tag) InMessage.Tag {
|
||||
const bytes_ptr = @ptrCast(*const [4]u8, x);
|
||||
fn bswap_and_workaround_tag(bytes_ptr: *const [4]u8) InMessage.Tag {
|
||||
const int = std.mem.readIntLittle(u32, bytes_ptr);
|
||||
return @intToEnum(InMessage.Tag, int);
|
||||
}
|
||||
|
||||
@ -209,6 +209,12 @@ test "atomicrmw with floats" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
|
||||
if (builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test.c:34929:7: error: address argument to atomic operation must be a pointer to integer or pointer ('zig_f32 *' (aka 'float *') invalid
|
||||
// when compiling with -std=c99 -pedantic
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if ((builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) and
|
||||
builtin.cpu.arch == .aarch64)
|
||||
{
|
||||
|
||||
@ -11,6 +11,10 @@ test "export a function twice" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test.c: error: aliases are not supported on darwin
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
// If it exports the function correctly, `test_func` and `testFunc` will points to the same address.
|
||||
try expectEqual(test_func(), other_file.testFunc());
|
||||
|
||||
@ -1313,6 +1313,16 @@ test "cast f16 to wider types" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .windows and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
var x: f16 = 1234.0;
|
||||
@ -1339,6 +1349,11 @@ test "cast f128 to narrower types" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
var x: f128 = 1234.0;
|
||||
@ -1429,6 +1444,11 @@ test "coerce between pointers of compatible differently-named floats" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
const F = switch (@typeInfo(c_longdouble).Float.bits) {
|
||||
16 => f16,
|
||||
32 => f32,
|
||||
|
||||
@ -542,6 +542,11 @@ test "another, possibly redundant, @fabs test" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
try testFabsLegacy(f128, 12.0);
|
||||
comptime try testFabsLegacy(f128, 12.0);
|
||||
try testFabsLegacy(f64, 12.0);
|
||||
@ -586,6 +591,11 @@ test "a third @fabs test, surely there should not be three fabs tests" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
inline for ([_]type{ f16, f32, f64, f80, f128, c_longdouble }) |T| {
|
||||
// normals
|
||||
try expect(@fabs(@as(T, 1.0)) == 1.0);
|
||||
@ -688,6 +698,11 @@ test "@floor f128" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
try testFloorLegacy(f128, 12.0);
|
||||
comptime try testFloorLegacy(f128, 12.0);
|
||||
}
|
||||
@ -778,6 +793,11 @@ test "@ceil f128" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
try testCeilLegacy(f128, 12.0);
|
||||
comptime try testCeilLegacy(f128, 12.0);
|
||||
}
|
||||
@ -874,6 +894,11 @@ test "@trunc f128" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
try testTruncLegacy(f128, 12.0);
|
||||
comptime try testTruncLegacy(f128, 12.0);
|
||||
}
|
||||
@ -992,6 +1017,11 @@ test "negation f128" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
var a: f128 = 1;
|
||||
@ -1035,6 +1065,11 @@ test "comptime fixed-width float zero divided by zero produces NaN" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
inline for (.{ f16, f32, f64, f80, f128 }) |F| {
|
||||
try expect(math.isNan(@as(F, 0) / @as(F, 0)));
|
||||
}
|
||||
|
||||
@ -622,6 +622,11 @@ test "f128" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
try test_f128();
|
||||
comptime try test_f128();
|
||||
}
|
||||
@ -1299,6 +1304,11 @@ test "remainder division" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
comptime try remdiv(f16);
|
||||
comptime try remdiv(f32);
|
||||
comptime try remdiv(f64);
|
||||
@ -1330,6 +1340,11 @@ test "float remainder division using @rem" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
comptime try frem(f16);
|
||||
comptime try frem(f32);
|
||||
comptime try frem(f64);
|
||||
@ -1372,6 +1387,11 @@ test "float modulo division using @mod" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
comptime try fmod(f16);
|
||||
comptime try fmod(f32);
|
||||
comptime try fmod(f64);
|
||||
@ -1445,6 +1465,11 @@ test "@round f128" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
try testRound(f128, 12.0);
|
||||
comptime try testRound(f128, 12.0);
|
||||
}
|
||||
@ -1490,6 +1515,11 @@ test "NaN comparison" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
try testNanEqNan(f16);
|
||||
try testNanEqNan(f32);
|
||||
try testNanEqNan(f64);
|
||||
@ -1562,6 +1592,12 @@ test "signed zeros are represented properly" {
|
||||
if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64 and
|
||||
builtin.zig_backend == .stage2_c)
|
||||
{
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
|
||||
@ -75,6 +75,11 @@ test "@mulAdd f128" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
comptime try testMulAdd128();
|
||||
try testMulAdd128();
|
||||
}
|
||||
@ -203,6 +208,11 @@ test "vector f128" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
comptime try vector128();
|
||||
try vector128();
|
||||
}
|
||||
|
||||
@ -103,6 +103,11 @@ test "vector float operators" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| {
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
|
||||
@ -50,6 +50,11 @@ test "float widening" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
var a: f16 = 12.34;
|
||||
var b: f32 = a;
|
||||
var c: f64 = b;
|
||||
@ -77,6 +82,11 @@ test "float widening f16 to f128" {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
|
||||
// TODO: test is failing
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
var x: f16 = 12.34;
|
||||
var y: f128 = x;
|
||||
try expect(x == y);
|
||||
|
||||
277
test/tests.zig
277
test/tests.zig
@ -22,12 +22,12 @@ pub const CompareOutputContext = @import("src/CompareOutput.zig");
|
||||
pub const StackTracesContext = @import("src/StackTrace.zig");
|
||||
|
||||
const TestTarget = struct {
|
||||
target: CrossTarget = @as(CrossTarget, .{}),
|
||||
target: CrossTarget = .{},
|
||||
optimize_mode: std.builtin.OptimizeMode = .Debug,
|
||||
link_libc: bool = false,
|
||||
single_threaded: bool = false,
|
||||
disable_native: bool = false,
|
||||
backend: ?std.builtin.CompilerBackend = null,
|
||||
link_libc: ?bool = null,
|
||||
single_threaded: ?bool = null,
|
||||
use_llvm: ?bool = null,
|
||||
use_lld: ?bool = null,
|
||||
};
|
||||
|
||||
const test_targets = blk: {
|
||||
@ -43,13 +43,47 @@ const test_targets = blk: {
|
||||
.{
|
||||
.single_threaded = true,
|
||||
},
|
||||
.{
|
||||
.optimize_mode = .ReleaseFast,
|
||||
},
|
||||
.{
|
||||
.link_libc = true,
|
||||
.optimize_mode = .ReleaseFast,
|
||||
},
|
||||
.{
|
||||
.optimize_mode = .ReleaseFast,
|
||||
.single_threaded = true,
|
||||
},
|
||||
|
||||
.{
|
||||
.optimize_mode = .ReleaseSafe,
|
||||
},
|
||||
.{
|
||||
.link_libc = true,
|
||||
.optimize_mode = .ReleaseSafe,
|
||||
},
|
||||
.{
|
||||
.optimize_mode = .ReleaseSafe,
|
||||
.single_threaded = true,
|
||||
},
|
||||
|
||||
.{
|
||||
.optimize_mode = .ReleaseSmall,
|
||||
},
|
||||
.{
|
||||
.link_libc = true,
|
||||
.optimize_mode = .ReleaseSmall,
|
||||
},
|
||||
.{
|
||||
.optimize_mode = .ReleaseSmall,
|
||||
.single_threaded = true,
|
||||
},
|
||||
|
||||
.{
|
||||
.target = .{
|
||||
.ofmt = .c,
|
||||
},
|
||||
.link_libc = true,
|
||||
.backend = .stage2_c,
|
||||
},
|
||||
.{
|
||||
.target = .{
|
||||
@ -57,22 +91,24 @@ const test_targets = blk: {
|
||||
.os_tag = .linux,
|
||||
.abi = .none,
|
||||
},
|
||||
.backend = .stage2_x86_64,
|
||||
.use_llvm = false,
|
||||
.use_lld = false,
|
||||
},
|
||||
.{
|
||||
.target = .{
|
||||
.cpu_arch = .aarch64,
|
||||
.os_tag = .linux,
|
||||
},
|
||||
.backend = .stage2_aarch64,
|
||||
.use_llvm = false,
|
||||
.use_lld = false,
|
||||
},
|
||||
.{
|
||||
.target = .{
|
||||
.cpu_arch = .wasm32,
|
||||
.os_tag = .wasi,
|
||||
},
|
||||
.single_threaded = true,
|
||||
.backend = .stage2_wasm,
|
||||
.use_llvm = false,
|
||||
.use_lld = false,
|
||||
},
|
||||
// https://github.com/ziglang/zig/issues/13623
|
||||
//.{
|
||||
@ -80,7 +116,8 @@ const test_targets = blk: {
|
||||
// .cpu_arch = .arm,
|
||||
// .os_tag = .linux,
|
||||
// },
|
||||
// .backend = .stage2_arm,
|
||||
// .use_llvm = false,
|
||||
// .use_lld = false,
|
||||
//},
|
||||
// https://github.com/ziglang/zig/issues/13623
|
||||
//.{
|
||||
@ -88,7 +125,8 @@ const test_targets = blk: {
|
||||
// .arch_os_abi = "arm-linux-none",
|
||||
// .cpu_features = "generic+v8a",
|
||||
// }) catch unreachable,
|
||||
// .backend = .stage2_arm,
|
||||
// .use_llvm = false,
|
||||
// .use_lld = false,
|
||||
//},
|
||||
.{
|
||||
.target = .{
|
||||
@ -96,7 +134,8 @@ const test_targets = blk: {
|
||||
.os_tag = .macos,
|
||||
.abi = .none,
|
||||
},
|
||||
.backend = .stage2_aarch64,
|
||||
.use_llvm = false,
|
||||
.use_lld = false,
|
||||
},
|
||||
.{
|
||||
.target = .{
|
||||
@ -104,7 +143,8 @@ const test_targets = blk: {
|
||||
.os_tag = .macos,
|
||||
.abi = .none,
|
||||
},
|
||||
.backend = .stage2_x86_64,
|
||||
.use_llvm = false,
|
||||
.use_lld = false,
|
||||
},
|
||||
.{
|
||||
.target = .{
|
||||
@ -112,7 +152,8 @@ const test_targets = blk: {
|
||||
.os_tag = .windows,
|
||||
.abi = .gnu,
|
||||
},
|
||||
.backend = .stage2_x86_64,
|
||||
.use_llvm = false,
|
||||
.use_lld = false,
|
||||
},
|
||||
|
||||
.{
|
||||
@ -121,7 +162,6 @@ const test_targets = blk: {
|
||||
.os_tag = .wasi,
|
||||
},
|
||||
.link_libc = false,
|
||||
.single_threaded = true,
|
||||
},
|
||||
.{
|
||||
.target = .{
|
||||
@ -129,7 +169,6 @@ const test_targets = blk: {
|
||||
.os_tag = .wasi,
|
||||
},
|
||||
.link_libc = true,
|
||||
.single_threaded = true,
|
||||
},
|
||||
|
||||
.{
|
||||
@ -413,43 +452,6 @@ const test_targets = blk: {
|
||||
},
|
||||
.link_libc = true,
|
||||
},
|
||||
|
||||
// Do the release tests last because they take a long time
|
||||
.{
|
||||
.optimize_mode = .ReleaseFast,
|
||||
},
|
||||
.{
|
||||
.link_libc = true,
|
||||
.optimize_mode = .ReleaseFast,
|
||||
},
|
||||
.{
|
||||
.optimize_mode = .ReleaseFast,
|
||||
.single_threaded = true,
|
||||
},
|
||||
|
||||
.{
|
||||
.optimize_mode = .ReleaseSafe,
|
||||
},
|
||||
.{
|
||||
.link_libc = true,
|
||||
.optimize_mode = .ReleaseSafe,
|
||||
},
|
||||
.{
|
||||
.optimize_mode = .ReleaseSafe,
|
||||
.single_threaded = true,
|
||||
},
|
||||
|
||||
.{
|
||||
.optimize_mode = .ReleaseSmall,
|
||||
},
|
||||
.{
|
||||
.link_libc = true,
|
||||
.optimize_mode = .ReleaseSmall,
|
||||
},
|
||||
.{
|
||||
.optimize_mode = .ReleaseSmall,
|
||||
.single_threaded = true,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@ -913,8 +915,6 @@ const ModuleTestOptions = struct {
|
||||
skip_non_native: bool,
|
||||
skip_cross_glibc: bool,
|
||||
skip_libc: bool,
|
||||
skip_stage1: bool,
|
||||
skip_stage2: bool,
|
||||
max_rss: usize = 0,
|
||||
};
|
||||
|
||||
@ -922,49 +922,65 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
|
||||
const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);
|
||||
|
||||
for (test_targets) |test_target| {
|
||||
if (options.skip_non_native and !test_target.target.isNative())
|
||||
const is_native = test_target.target.isNative() or
|
||||
(test_target.target.getOsTag() == builtin.os.tag and
|
||||
test_target.target.getCpuArch() == builtin.cpu.arch);
|
||||
|
||||
if (options.skip_non_native and !is_native)
|
||||
continue;
|
||||
|
||||
if (options.skip_cross_glibc and test_target.target.isGnuLibC() and test_target.link_libc)
|
||||
if (options.skip_cross_glibc and test_target.target.isGnuLibC() and test_target.link_libc == true)
|
||||
continue;
|
||||
|
||||
if (options.skip_libc and test_target.link_libc)
|
||||
if (options.skip_libc and test_target.link_libc == true)
|
||||
continue;
|
||||
|
||||
if (test_target.link_libc and test_target.target.getOs().requiresLibC()) {
|
||||
// This would be a redundant test.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (options.skip_single_threaded and test_target.single_threaded)
|
||||
if (options.skip_single_threaded and test_target.single_threaded == true)
|
||||
continue;
|
||||
|
||||
if (test_target.disable_native and
|
||||
test_target.target.getOsTag() == builtin.os.tag and
|
||||
test_target.target.getCpuArch() == builtin.cpu.arch)
|
||||
// TODO get compiler-rt tests passing for self-hosted backends.
|
||||
if (test_target.use_llvm == false and mem.eql(u8, options.name, "compiler-rt"))
|
||||
continue;
|
||||
|
||||
// TODO get the x86_64 self-hosted backend tests passing on Windows
|
||||
if (test_target.target.getCpuArch() == .x86_64 and
|
||||
test_target.target.getOsTag() == .windows and
|
||||
test_target.use_llvm == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (test_target.backend) |backend| switch (backend) {
|
||||
.stage1 => if (options.skip_stage1) continue,
|
||||
.stage2_llvm => {},
|
||||
else => if (options.skip_stage2) continue,
|
||||
};
|
||||
// TODO get compiler-rt tests passing for wasm32-wasi
|
||||
// currently causes "LLVM ERROR: Unable to expand fixed point multiplication."
|
||||
if (test_target.target.getCpuArch() == .wasm32 and
|
||||
test_target.target.getOsTag() == .wasi and
|
||||
mem.eql(u8, options.name, "compiler-rt"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO get universal-libc tests passing for self-hosted backends.
|
||||
if (test_target.use_llvm == false and mem.eql(u8, options.name, "universal-libc"))
|
||||
continue;
|
||||
|
||||
// TODO get std lib tests passing for self-hosted backends.
|
||||
if (test_target.use_llvm == false and mem.eql(u8, options.name, "std"))
|
||||
continue;
|
||||
|
||||
// TODO get std lib tests passing for the C backend
|
||||
if (test_target.target.ofmt == std.Target.ObjectFormat.c and
|
||||
mem.eql(u8, options.name, "std"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const want_this_mode = for (options.optimize_modes) |m| {
|
||||
if (m == test_target.optimize_mode) break true;
|
||||
} else false;
|
||||
if (!want_this_mode) continue;
|
||||
|
||||
const libc_prefix = if (test_target.target.getOs().requiresLibC())
|
||||
""
|
||||
else if (test_target.link_libc)
|
||||
"c"
|
||||
else
|
||||
"bare";
|
||||
|
||||
const triple_prefix = test_target.target.zigTriple(b.allocator) catch @panic("OOM");
|
||||
const libc_suffix = if (test_target.link_libc == true) "-libc" else "";
|
||||
const triple_txt = test_target.target.zigTriple(b.allocator) catch @panic("OOM");
|
||||
|
||||
// wasm32-wasi builds need more RAM, idk why
|
||||
const max_rss = if (test_target.target.getOs().tag == .wasi)
|
||||
@ -978,45 +994,80 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
|
||||
.target = test_target.target,
|
||||
.max_rss = max_rss,
|
||||
.filter = options.test_filter,
|
||||
.link_libc = test_target.link_libc,
|
||||
.single_threaded = test_target.single_threaded,
|
||||
.use_llvm = test_target.use_llvm,
|
||||
.use_lld = test_target.use_lld,
|
||||
});
|
||||
const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";
|
||||
const backend_txt = if (test_target.backend) |backend| @tagName(backend) else "default";
|
||||
these_tests.single_threaded = test_target.single_threaded;
|
||||
if (test_target.link_libc) {
|
||||
these_tests.linkSystemLibrary("c");
|
||||
}
|
||||
const single_threaded_suffix = if (test_target.single_threaded == true) "-single" else "";
|
||||
const backend_suffix = if (test_target.use_llvm == true)
|
||||
"-llvm"
|
||||
else if (test_target.target.ofmt == std.Target.ObjectFormat.c)
|
||||
"-cbe"
|
||||
else if (test_target.use_llvm == false)
|
||||
"-selfhosted"
|
||||
else
|
||||
"";
|
||||
|
||||
these_tests.overrideZigLibDir("lib");
|
||||
these_tests.addIncludePath("test");
|
||||
if (test_target.backend) |backend| switch (backend) {
|
||||
.stage1 => {
|
||||
@panic("stage1 testing requested");
|
||||
},
|
||||
.stage2_llvm => {
|
||||
these_tests.use_llvm = true;
|
||||
},
|
||||
.stage2_c => {
|
||||
these_tests.use_llvm = false;
|
||||
},
|
||||
else => {
|
||||
these_tests.use_llvm = false;
|
||||
// TODO: force self-hosted linkers to avoid LLD creeping in
|
||||
// until the auto-select mechanism deems them worthy
|
||||
these_tests.use_lld = false;
|
||||
},
|
||||
};
|
||||
|
||||
const run = b.addRunArtifact(these_tests);
|
||||
run.skip_foreign_checks = true;
|
||||
run.setName(b.fmt("run test {s}-{s}-{s}-{s}-{s}-{s}", .{
|
||||
const qualified_name = b.fmt("{s}-{s}-{s}{s}{s}{s}", .{
|
||||
options.name,
|
||||
triple_prefix,
|
||||
triple_txt,
|
||||
@tagName(test_target.optimize_mode),
|
||||
libc_prefix,
|
||||
single_threaded_txt,
|
||||
backend_txt,
|
||||
}));
|
||||
libc_suffix,
|
||||
single_threaded_suffix,
|
||||
backend_suffix,
|
||||
});
|
||||
|
||||
step.dependOn(&run.step);
|
||||
if (test_target.target.ofmt == std.Target.ObjectFormat.c) {
|
||||
var altered_target = test_target.target;
|
||||
altered_target.ofmt = null;
|
||||
|
||||
const compile_c = b.addExecutable(.{
|
||||
.name = qualified_name,
|
||||
.link_libc = test_target.link_libc,
|
||||
.target = altered_target,
|
||||
});
|
||||
compile_c.overrideZigLibDir("lib");
|
||||
compile_c.addCSourceFileSource(.{
|
||||
.source = these_tests.getOutputSource(),
|
||||
.args = &.{
|
||||
// TODO output -std=c89 compatible C code
|
||||
"-std=c99",
|
||||
"-pedantic",
|
||||
"-Werror",
|
||||
// TODO stop violating these pedantic errors. spotted on linux
|
||||
"-Wno-address-of-packed-member",
|
||||
"-Wno-gnu-folding-constant",
|
||||
"-Wno-incompatible-pointer-types",
|
||||
"-Wno-overlength-strings",
|
||||
// TODO stop violating these pedantic errors. spotted on darwin
|
||||
"-Wno-dollar-in-identifier-extension",
|
||||
"-Wno-absolute-value",
|
||||
},
|
||||
});
|
||||
compile_c.addIncludePath("lib"); // for zig.h
|
||||
if (test_target.link_libc == false and test_target.target.getOsTag() == .windows) {
|
||||
compile_c.subsystem = .Console;
|
||||
compile_c.linkSystemLibrary("kernel32");
|
||||
compile_c.linkSystemLibrary("ntdll");
|
||||
}
|
||||
|
||||
const run = b.addRunArtifact(compile_c);
|
||||
run.skip_foreign_checks = true;
|
||||
run.enableTestRunnerMode();
|
||||
run.setName(b.fmt("run test {s}", .{qualified_name}));
|
||||
|
||||
step.dependOn(&run.step);
|
||||
} else {
|
||||
const run = b.addRunArtifact(these_tests);
|
||||
run.skip_foreign_checks = true;
|
||||
run.setName(b.fmt("run test {s}", .{qualified_name}));
|
||||
|
||||
step.dependOn(&run.step);
|
||||
}
|
||||
}
|
||||
return step;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user