Merge pull request #15356 from jacobly0/cbe-std-tests

cbe: enable CI for std tests
This commit is contained in:
Andrew Kelley 2023-04-22 11:04:36 -07:00 committed by GitHub
commit 21aa55d34e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 1331 additions and 1181 deletions

View File

@ -1141,7 +1141,7 @@ test "setName, getName" {
thread.join();
}
test "std.Thread" {
test {
// Doesn't use testing.refAllDecls() since that would pull in the compileError spinLoopHint.
_ = Futex;
_ = ResetEvent;

View File

@ -7,7 +7,7 @@ pub const Stack = @import("atomic/stack.zig").Stack;
pub const Queue = @import("atomic/queue.zig").Queue;
pub const Atomic = @import("atomic/Atomic.zig").Atomic;
test "std.atomic" {
test {
_ = @import("atomic/stack.zig");
_ = @import("atomic/queue.zig");
_ = @import("atomic/Atomic.zig");

View File

@ -1635,6 +1635,8 @@ fn testStaticBitSet(comptime Set: type) !void {
}
test "IntegerBitSet" {
if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
try testStaticBitSet(IntegerBitSet(0));
try testStaticBitSet(IntegerBitSet(1));
try testStaticBitSet(IntegerBitSet(2));

View File

@ -5,9 +5,10 @@ const testing = std.testing;
const has_aesni = std.Target.x86.featureSetHas(builtin.cpu.features, .aes);
const has_avx = std.Target.x86.featureSetHas(builtin.cpu.features, .avx);
const has_armaes = std.Target.aarch64.featureSetHas(builtin.cpu.features, .aes);
const impl = if (builtin.cpu.arch == .x86_64 and has_aesni and has_avx) impl: {
// C backend doesn't currently support passing vectors to inline asm.
const impl = if (builtin.cpu.arch == .x86_64 and builtin.zig_backend != .stage2_c and has_aesni and has_avx) impl: {
break :impl @import("aes/aesni.zig");
} else if (builtin.cpu.arch == .aarch64 and has_armaes)
} else if (builtin.cpu.arch == .aarch64 and builtin.zig_backend != .stage2_c and has_armaes)
impl: {
break :impl @import("aes/armcrypto.zig");
} else impl: {

View File

@ -257,6 +257,8 @@ inline fn xorWith(x: *Block, y: Block) void {
const hexToBytes = std.fmt.hexToBytes;
test "AesOcb test vector 1" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var k: [Aes128Ocb.key_length]u8 = undefined;
var nonce: [Aes128Ocb.nonce_length]u8 = undefined;
var tag: [Aes128Ocb.tag_length]u8 = undefined;
@ -274,6 +276,8 @@ test "AesOcb test vector 1" {
}
test "AesOcb test vector 2" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var k: [Aes128Ocb.key_length]u8 = undefined;
var nonce: [Aes128Ocb.nonce_length]u8 = undefined;
var tag: [Aes128Ocb.tag_length]u8 = undefined;
@ -293,6 +297,8 @@ test "AesOcb test vector 2" {
}
test "AesOcb test vector 3" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var k: [Aes128Ocb.key_length]u8 = undefined;
var nonce: [Aes128Ocb.nonce_length]u8 = undefined;
var tag: [Aes128Ocb.tag_length]u8 = undefined;
@ -315,6 +321,8 @@ test "AesOcb test vector 3" {
}
test "AesOcb test vector 4" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var k: [Aes128Ocb.key_length]u8 = undefined;
var nonce: [Aes128Ocb.nonce_length]u8 = undefined;
var tag: [Aes128Ocb.tag_length]u8 = undefined;

View File

@ -1,3 +1,4 @@
const builtin = @import("builtin");
const std = @import("std");
const crypto = std.crypto;
const fmt = std.fmt;
@ -373,6 +374,8 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type {
}
test "ECDSA - Basic operations over EcdsaP384Sha384" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
const Scheme = EcdsaP384Sha384;
const kp = try Scheme.KeyPair.create(null);
const msg = "test";
@ -387,6 +390,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha384" {
}
test "ECDSA - Basic operations over Secp256k1" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
const Scheme = EcdsaSecp256k1Sha256oSha256;
const kp = try Scheme.KeyPair.create(null);
const msg = "test";
@ -401,6 +406,8 @@ test "ECDSA - Basic operations over Secp256k1" {
}
test "ECDSA - Basic operations over EcdsaP384Sha256" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);
const kp = try Scheme.KeyPair.create(null);
const msg = "test";
@ -415,6 +422,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha256" {
}
test "ECDSA - Verifying a existing signature with EcdsaP384Sha256" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);
// zig fmt: off
const sk_bytes = [_]u8{
@ -457,6 +466,8 @@ const TestVector = struct {
};
test "ECDSA - Test vectors from Project Wycheproof" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
const vectors = [_]TestVector{
.{ .key = "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e", .msg = "313233343030", .sig = "304402202ba3a8be6b94d5ec80a6d9d1190a436effe50d85a1eee859b8cc6af9bd5c2e1802204cd60b855d442f5b3c7b11eb6c4e0ae7525fe710fab9aa7c77a67f79e6fadd76", .result = .valid },
.{ .key = "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e", .msg = "313233343030", .sig = "304402202ba3a8be6b94d5ec80a6d9d1190a436effe50d85a1eee859b8cc6af9bd5c2e180220b329f479a2bbd0a5c384ee1493b1f5186a87139cac5df4087c134b49156847db", .result = .acceptable },
@ -869,6 +880,8 @@ fn tvTry(vector: TestVector) !void {
}
test "ECDSA - Sec1 encoding/decoding" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
const Scheme = EcdsaP384Sha384;
const kp = try Scheme.KeyPair.create(null);
const pk = kp.public_key;

View File

@ -248,9 +248,10 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
const has_pclmul = std.Target.x86.featureSetHas(builtin.cpu.features, .pclmul);
const has_avx = std.Target.x86.featureSetHas(builtin.cpu.features, .avx);
const has_armaes = std.Target.aarch64.featureSetHas(builtin.cpu.features, .aes);
const clmul = if (builtin.cpu.arch == .x86_64 and has_pclmul and has_avx) impl: {
// C backend doesn't currently support passing vectors to inline asm.
const clmul = if (builtin.cpu.arch == .x86_64 and builtin.zig_backend != .stage2_c and has_pclmul and has_avx) impl: {
break :impl clmulPclmul;
} else if (builtin.cpu.arch == .aarch64 and has_armaes) impl: {
} else if (builtin.cpu.arch == .aarch64 and builtin.zig_backend != .stage2_c and has_armaes) impl: {
break :impl clmulPmull;
} else impl: {
break :impl clmulSoft;

View File

@ -473,6 +473,6 @@ pub const AffineCoordinates = struct {
}
};
test "p256" {
test {
_ = @import("tests/p256.zig");
}

View File

@ -473,6 +473,8 @@ pub const AffineCoordinates = struct {
}
};
test "p384" {
test {
if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
_ = @import("tests/p384.zig");
}

View File

@ -551,6 +551,8 @@ pub const AffineCoordinates = struct {
}
};
test "secp256k1" {
test {
if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
_ = @import("tests/secp256k1.zig");
}

View File

@ -205,7 +205,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
if (!isComptime()) {
switch (builtin.cpu.arch) {
.aarch64 => if (comptime std.Target.aarch64.featureSetHas(builtin.cpu.features, .sha2)) {
.aarch64 => if (builtin.zig_backend != .stage2_c and comptime std.Target.aarch64.featureSetHas(builtin.cpu.features, .sha2)) {
var x: v4u32 = d.s[0..4].*;
var y: v4u32 = d.s[4..8].*;
const s_v = @ptrCast(*[16]v4u32, &s);
@ -242,7 +242,8 @@ fn Sha2x32(comptime params: Sha2Params32) type {
d.s[4..8].* = y +% @as(v4u32, d.s[4..8].*);
return;
},
.x86_64 => if (comptime std.Target.x86.featureSetHas(builtin.cpu.features, .sha)) {
// C backend doesn't currently support passing vectors to inline asm.
.x86_64 => if (builtin.zig_backend != .stage2_c and comptime std.Target.x86.featureSetHas(builtin.cpu.features, .sha)) {
var x: v4u32 = [_]u32{ d.s[5], d.s[4], d.s[1], d.s[0] };
var y: v4u32 = [_]u32{ d.s[7], d.s[6], d.s[3], d.s[2] };
const s_v = @ptrCast(*[16]v4u32, &s);

View File

@ -2189,6 +2189,8 @@ pub fn dumpStackPointerAddr(prefix: []const u8) void {
}
test "manage resources correctly" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // error.UnsupportedBackend
if (builtin.os.tag == .wasi) return error.SkipZigTest;
if (builtin.os.tag == .windows and builtin.cpu.arch == .x86_64) {

View File

@ -36,7 +36,7 @@ const xxhash = @import("hash/xxhash.zig");
pub const XxHash64 = xxhash.XxHash64;
pub const XxHash32 = xxhash.XxHash32;
test "hash" {
test {
_ = adler;
_ = auto_hash;
_ = crc;

View File

@ -915,6 +915,8 @@ test "big.int mul multi-single" {
}
test "big.int mul multi-multi" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var op1: u256 = 0x998888efefefefefefefef;
var op2: u256 = 0x333000abababababababab;
var a = try Managed.initSet(testing.allocator, op1);
@ -1034,6 +1036,8 @@ test "big.int mulWrap single-single signed" {
}
test "big.int mulWrap multi-multi unsigned" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var op1: u256 = 0x998888efefefefefefefef;
var op2: u256 = 0x333000abababababababab;
var a = try Managed.initSet(testing.allocator, op1);
@ -1049,6 +1053,8 @@ test "big.int mulWrap multi-multi unsigned" {
}
test "big.int mulWrap multi-multi signed" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var a = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb) - 1);
defer a.deinit();
var b = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb));
@ -1252,6 +1258,8 @@ test "big.int div q=0 alias" {
}
test "big.int div multi-multi q < r" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
const op1 = 0x1ffffffff0078f432;
const op2 = 0x1ffffffff01000000;
var a = try Managed.initSet(testing.allocator, op1);
@ -1608,6 +1616,8 @@ test "big.int div floor positive close to zero" {
}
test "big.int div multi-multi with rem" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var a = try Managed.initSet(testing.allocator, 0x8888999911110000ffffeeeeddddccccbbbbaaaa9999);
defer a.deinit();
var b = try Managed.initSet(testing.allocator, 0x99990000111122223333);
@ -1624,6 +1634,8 @@ test "big.int div multi-multi with rem" {
}
test "big.int div multi-multi no rem" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var a = try Managed.initSet(testing.allocator, 0x8888999911110000ffffeeeedb4fec200ee3a4286361);
defer a.deinit();
var b = try Managed.initSet(testing.allocator, 0x99990000111122223333);
@ -1640,6 +1652,8 @@ test "big.int div multi-multi no rem" {
}
test "big.int div multi-multi (2 branch)" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var a = try Managed.initSet(testing.allocator, 0x866666665555555588888887777777761111111111111111);
defer a.deinit();
var b = try Managed.initSet(testing.allocator, 0x86666666555555554444444433333333);
@ -1656,6 +1670,8 @@ test "big.int div multi-multi (2 branch)" {
}
test "big.int div multi-multi (3.1/3.3 branch)" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var a = try Managed.initSet(testing.allocator, 0x11111111111111111111111111111111111111111111111111111111111111);
defer a.deinit();
var b = try Managed.initSet(testing.allocator, 0x1111111111111111111111111111111111111111171);
@ -1672,6 +1688,8 @@ test "big.int div multi-multi (3.1/3.3 branch)" {
}
test "big.int div multi-single zero-limb trailing" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var a = try Managed.initSet(testing.allocator, 0x60000000000000000000000000000000000000000000000000000000000000000);
defer a.deinit();
var b = try Managed.initSet(testing.allocator, 0x10000000000000000);
@ -1690,6 +1708,8 @@ test "big.int div multi-single zero-limb trailing" {
}
test "big.int div multi-multi zero-limb trailing (with rem)" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var a = try Managed.initSet(testing.allocator, 0x86666666555555558888888777777776111111111111111100000000000000000000000000000000);
defer a.deinit();
var b = try Managed.initSet(testing.allocator, 0x8666666655555555444444443333333300000000000000000000000000000000);
@ -1709,6 +1729,8 @@ test "big.int div multi-multi zero-limb trailing (with rem)" {
}
test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-limb count > divisor zero-limb count" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var a = try Managed.initSet(testing.allocator, 0x8666666655555555888888877777777611111111111111110000000000000000);
defer a.deinit();
var b = try Managed.initSet(testing.allocator, 0x8666666655555555444444443333333300000000000000000000000000000000);
@ -1728,6 +1750,8 @@ test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-li
}
test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-limb count < divisor zero-limb count" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var a = try Managed.initSet(testing.allocator, 0x86666666555555558888888777777776111111111111111100000000000000000000000000000000);
defer a.deinit();
var b = try Managed.initSet(testing.allocator, 0x866666665555555544444444333333330000000000000000);
@ -2486,6 +2510,8 @@ test "big.int gcd non-one large" {
}
test "big.int gcd large multi-limb result" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var a = try Managed.initSet(testing.allocator, 0x12345678123456781234567812345678123456781234567812345678);
defer a.deinit();
var b = try Managed.initSet(testing.allocator, 0x12345671234567123456712345671234567123456712345671234567);

View File

@ -189,7 +189,7 @@ test "complex.magnitude" {
try testing.expect(math.approxEqAbs(f32, c, 5.83095, epsilon));
}
test "complex.cmath" {
test {
_ = @import("complex/abs.zig");
_ = @import("complex/acosh.zig");
_ = @import("complex/acos.zig");

View File

@ -1504,6 +1504,8 @@ test "comptime read/write int" {
}
test "readIntBig and readIntLittle" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
try testing.expect(readIntSliceBig(u0, &[_]u8{}) == 0x0);
try testing.expect(readIntSliceLittle(u0, &[_]u8{}) == 0x0);
@ -1795,6 +1797,8 @@ pub fn writeVarPackedInt(bytes: []u8, bit_offset: usize, bit_count: usize, value
}
test "writeIntBig and writeIntLittle" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
var buf0: [0]u8 = undefined;
var buf1: [1]u8 = undefined;
var buf2: [2]u8 = undefined;
@ -4011,6 +4015,8 @@ pub fn alignInSlice(slice: anytype, comptime new_alignment: usize) ?AlignedSlice
}
test "read/write(Var)PackedInt" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
switch (builtin.cpu.arch) {
// This test generates too much code to execute on WASI.
// LLVM backend fails with "too many locals: locals exceed maximum"

View File

@ -10,7 +10,7 @@ pub const TrailerFlags = @import("meta/trailer_flags.zig").TrailerFlags;
const Type = std.builtin.Type;
test "std.meta.TrailerFlags" {
test {
_ = TrailerFlags;
}

View File

@ -502,8 +502,7 @@ fn iter_fn(info: *dl_phdr_info, size: usize, counter: *usize) IterFnError!void {
}
test "dl_iterate_phdr" {
if (native_os == .windows or native_os == .wasi or native_os == .macos)
return error.SkipZigTest;
if (builtin.object_format != .elf) return error.SkipZigTest;
var counter: usize = 0;
try os.dl_iterate_phdr(&counter, IterFnError, iter_fn);
@ -797,6 +796,11 @@ test "sigaction" {
if (native_os == .linux and builtin.target.cpu.arch == .x86)
return error.SkipZigTest;
// https://github.com/ziglang/zig/issues/15381
if (native_os == .macos and builtin.target.cpu.arch == .x86_64) {
return error.SkipZigTest;
}
const S = struct {
var handler_called_count: u32 = 0;

View File

@ -90,6 +90,8 @@ pub fn fill(self: *Xoshiro256, buf: []u8) void {
}
test "xoroshiro sequence" {
if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
var r = Xoshiro256.init(0);
const seq1 = [_]u64{

966
lib/zig.h

File diff suppressed because it is too large Load Diff

View File

@ -21319,8 +21319,8 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
return sema.fail(block, op_src, "@atomicRmw with bool only allowed with .Xchg", .{});
},
.Float => switch (op) {
.Xchg, .Add, .Sub => {},
else => return sema.fail(block, op_src, "@atomicRmw with float only allowed with .Xchg, .Add, and .Sub", .{}),
.Xchg, .Add, .Sub, .Max, .Min => {},
else => return sema.fail(block, op_src, "@atomicRmw with float only allowed with .Xchg, .Add, .Sub, .Max, and .Min", .{}),
},
else => {},
}

File diff suppressed because it is too large Load Diff

View File

@ -10135,14 +10135,14 @@ fn toLlvmAtomicRmwBinOp(
) llvm.AtomicRMWBinOp {
return switch (op) {
.Xchg => .Xchg,
.Add => if (is_float) llvm.AtomicRMWBinOp.FAdd else return .Add,
.Sub => if (is_float) llvm.AtomicRMWBinOp.FSub else return .Sub,
.Add => if (is_float) .FAdd else return .Add,
.Sub => if (is_float) .FSub else return .Sub,
.And => .And,
.Nand => .Nand,
.Or => .Or,
.Xor => .Xor,
.Max => if (is_signed) llvm.AtomicRMWBinOp.Max else return .UMax,
.Min => if (is_signed) llvm.AtomicRMWBinOp.Min else return .UMin,
.Max => if (is_float) .FMax else if (is_signed) .Max else return .UMax,
.Min => if (is_float) .FMin else if (is_signed) .Min else return .UMin,
};
}

View File

@ -1436,6 +1436,8 @@ pub const AtomicRMWBinOp = enum(c_int) {
UMin,
FAdd,
FSub,
FMax,
FMin,
};
pub const TypeKind = enum(c_int) {

View File

@ -575,9 +575,6 @@ pub fn atomicPtrAlignment(
.xtensa,
=> 32,
.aarch64,
.aarch64_be,
.aarch64_32,
.amdgcn,
.bpfel,
.bpfeb,
@ -600,7 +597,12 @@ pub fn atomicPtrAlignment(
.loongarch64,
=> 64,
.x86_64 => 128,
.aarch64,
.aarch64_be,
.aarch64_32,
=> 128,
.x86_64 => if (std.Target.x86.featureSetHas(target.cpu.features, .cx16)) 128 else 64,
};
var buffer: Type.Payload.Bits = undefined;

View File

@ -286,20 +286,11 @@ test "page aligned array on stack" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_llvm and
builtin.cpu.arch == .aarch64 and builtin.os.tag == .windows)
{
if (builtin.cpu.arch == .aarch64 and builtin.os.tag == .windows) {
// https://github.com/ziglang/zig/issues/13679
return error.SkipZigTest;
}
if (builtin.zig_backend == .stage2_c and
builtin.os.tag == .windows and builtin.cpu.arch == .aarch64)
{
// https://github.com/ziglang/zig/issues/13876
return error.SkipZigTest;
}
// Large alignment value to make it hard to accidentally pass.
var array align(0x1000) = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8 };
var number1: u8 align(16) = 42;

View File

@ -3,6 +3,13 @@ const builtin = @import("builtin");
const expect = std.testing.expect;
const expectEqual = std.testing.expectEqual;
const supports_128_bit_atomics = switch (builtin.cpu.arch) {
// TODO: Ideally this could be sync'd with the logic in Sema.
.aarch64, .aarch64_be, .aarch64_32 => true,
.x86_64 => std.Target.x86.featureSetHas(builtin.cpu.features, .cx16),
else => false,
};
test "cmpxchg" {
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
@ -107,15 +114,14 @@ test "cmpxchg with ignored result" {
}
test "128-bit cmpxchg" {
if (!supports_128_bit_atomics) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.cpu.arch != .x86_64) return error.SkipZigTest;
if (comptime !std.Target.x86.featureSetHas(builtin.cpu.features, .cx16)) return error.SkipZigTest;
try test_u128_cmpxchg();
comptime try test_u128_cmpxchg();
}
@ -209,15 +215,7 @@ 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)
{
if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) {
// https://github.com/ziglang/zig/issues/10627
return error.SkipZigTest;
}
@ -234,6 +232,10 @@ fn testAtomicRmwFloat() !void {
try expect(x == 6);
_ = @atomicRmw(f32, &x, .Sub, 2, .SeqCst);
try expect(x == 4);
_ = @atomicRmw(f32, &x, .Max, 13, .SeqCst);
try expect(x == 13);
_ = @atomicRmw(f32, &x, .Min, 42, .SeqCst);
try expect(x == 13);
}
test "atomicrmw with ints" {
@ -242,10 +244,6 @@ test "atomicrmw with ints" {
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 and builtin.cpu.arch == .aarch64) {
return error.SkipZigTest;
}
try testAtomicRmwInts();
comptime try testAtomicRmwInts();
}
@ -311,24 +309,25 @@ fn testAtomicRmwInt(comptime signedness: std.builtin.Signedness, comptime N: usi
}
test "atomicrmw with 128-bit ints" {
if (builtin.cpu.arch != .x86_64) {
// TODO: Ideally this could use target.atomicPtrAlignment and check for IntTooBig
return error.SkipZigTest;
}
if (!supports_128_bit_atomics) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
// TODO "ld.lld: undefined symbol: __sync_lock_test_and_set_16" on -mcpu x86_64
if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest;
if (builtin.cpu.arch == .x86_64 and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest;
try testAtomicRmwInt128(.signed);
try testAtomicRmwInt128(.unsigned);
comptime try testAtomicRmwInt128(.signed);
comptime try testAtomicRmwInt128(.unsigned);
}
fn testAtomicRmwInt128(comptime signedness: std.builtin.Signedness) !void {
const uint = std.meta.Int(.unsigned, 128);
const int = std.meta.Int(signedness, 128);
const initial: int = 0xaaaaaaaa_bbbbbbbb_cccccccc_dddddddd;
const initial: int = @bitCast(int, @as(uint, 0xaaaaaaaa_bbbbbbbb_cccccccc_dddddddd));
const replacement: int = 0x00000000_00000005_00000000_00000003;
var x: int align(16) = initial;
@ -390,10 +389,6 @@ test "atomics with different types" {
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 and builtin.cpu.arch == .aarch64) {
return error.SkipZigTest;
}
try testAtomicsWithType(bool, true, false);
try testAtomicsWithType(u1, 0, 1);

View File

@ -7,7 +7,6 @@ var x: u8 = 1;
// This excludes builtin functions that return void or noreturn that cannot be tested.
test {
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO

View File

@ -1313,16 +1313,6 @@ 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;
@ -1342,18 +1332,6 @@ test "cast f128 to narrower 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 == .windows and builtin.cpu.arch == .aarch64 and
builtin.zig_backend == .stage2_c)
{
// https://github.com/ziglang/zig/issues/13876
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;
@ -1444,11 +1422,6 @@ 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,

View File

@ -535,18 +535,6 @@ test "another, possibly redundant, @fabs test" {
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 == .windows and builtin.cpu.arch == .aarch64 and
builtin.zig_backend == .stage2_c)
{
// https://github.com/ziglang/zig/issues/13876
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);
@ -584,18 +572,6 @@ test "a third @fabs test, surely there should not be three fabs tests" {
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 == .windows and builtin.cpu.arch == .aarch64 and
builtin.zig_backend == .stage2_c)
{
// https://github.com/ziglang/zig/issues/13876
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);
@ -698,11 +674,6 @@ 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);
}
@ -793,11 +764,6 @@ 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);
}
@ -894,11 +860,6 @@ 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);
}
@ -1010,18 +971,6 @@ test "negation f128" {
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64 and
builtin.zig_backend == .stage2_c)
{
// https://github.com/ziglang/zig/issues/13876
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;
@ -1065,11 +1014,6 @@ 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)));
}

View File

@ -615,18 +615,6 @@ test "f128" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64 and
builtin.zig_backend == .stage2_c)
{
// https://github.com/ziglang/zig/issues/13876
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();
}
@ -1297,18 +1285,6 @@ test "remainder division" {
return error.SkipZigTest;
}
if (builtin.zig_backend == .stage2_c and builtin.os.tag == .windows and
builtin.cpu.arch == .aarch64)
{
// https://github.com/ziglang/zig/issues/13876
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);
@ -1340,11 +1316,6 @@ 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);
@ -1387,11 +1358,6 @@ 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);
@ -1465,11 +1431,6 @@ 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);
}
@ -1508,18 +1469,6 @@ test "NaN comparison" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_c and builtin.os.tag == .windows and
builtin.cpu.arch == .aarch64)
{
// https://github.com/ziglang/zig/issues/13876
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);
@ -1589,18 +1538,6 @@ test "signed zeros are represented properly" {
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 == .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;
}
const S = struct {
fn doTheTest() !void {
try testOne(f16);

View File

@ -68,18 +68,6 @@ test "@mulAdd f128" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64 and
builtin.zig_backend == .stage2_c)
{
// https://github.com/ziglang/zig/issues/13876
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();
}
@ -201,18 +189,6 @@ test "vector f128" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64 and
builtin.zig_backend == .stage2_c)
{
// https://github.com/ziglang/zig/issues/13876
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();
}

View File

@ -615,3 +615,15 @@ test "pointer to container level packed struct field" {
@ptrCast(*S, &S.arr[0]).other_bits.enable_3 = true;
try expect(S.arr[0] == 0x10000000);
}
test "store undefined to packed result location" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var x: u4 = 0;
var s = packed struct { x: u4, y: u4 }{ .x = x, .y = if (x > 0) x else undefined };
try expectEqual(x, s.x);
}

View File

@ -96,18 +96,6 @@ test "vector float operators" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64 and
builtin.zig_backend == .stage2_c)
{
// https://github.com/ziglang/zig/issues/13876
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 {

View File

@ -43,18 +43,6 @@ test "float widening" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64 and
builtin.zig_backend == .stage2_c)
{
// https://github.com/ziglang/zig/issues/13876
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;
@ -75,18 +63,6 @@ test "float widening f16 to f128" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64 and
builtin.zig_backend == .stage2_c)
{
// https://github.com/ziglang/zig/issues/13876
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);

View File

@ -7,4 +7,4 @@ export fn entry() void {
// backend=stage2
// target=native
//
// :3:30: error: @atomicRmw with float only allowed with .Xchg, .Add, and .Sub
// :3:30: error: @atomicRmw with float only allowed with .Xchg, .Add, .Sub, .Max, and .Min

View File

@ -962,13 +962,6 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
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;
@ -1033,6 +1026,8 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
"-std=c99",
"-pedantic",
"-Werror",
// TODO stop violating these pedantic errors. spotted everywhere
"-Wno-builtin-requires-header",
// TODO stop violating these pedantic errors. spotted on linux
"-Wno-address-of-packed-member",
"-Wno-gnu-folding-constant",
@ -1044,10 +1039,21 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
},
});
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");
if (test_target.target.getOsTag() == .windows) {
if (test_target.link_libc == false) {
compile_c.subsystem = .Console;
compile_c.linkSystemLibrary("kernel32");
compile_c.linkSystemLibrary("ntdll");
}
if (mem.eql(u8, options.name, "std")) {
if (test_target.link_libc == false) {
compile_c.linkSystemLibrary("shell32");
compile_c.linkSystemLibrary("advapi32");
}
compile_c.linkSystemLibrary("crypt32");
compile_c.linkSystemLibrary("ws2_32");
compile_c.linkSystemLibrary("ole32");
}
}
const run = b.addRunArtifact(compile_c);