Skip to content

Commit 21aa55d

Browse files
authored
Merge pull request #15356 from jacobly0/cbe-std-tests
cbe: enable CI for std tests
2 parents c7067ef + f5cf732 commit 21aa55d

37 files changed

+1330
-1180
lines changed

lib/std/Thread.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ test "setName, getName" {
11411141
thread.join();
11421142
}
11431143

1144-
test "std.Thread" {
1144+
test {
11451145
// Doesn't use testing.refAllDecls() since that would pull in the compileError spinLoopHint.
11461146
_ = Futex;
11471147
_ = ResetEvent;

lib/std/atomic.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub const Stack = @import("atomic/stack.zig").Stack;
77
pub const Queue = @import("atomic/queue.zig").Queue;
88
pub const Atomic = @import("atomic/Atomic.zig").Atomic;
99

10-
test "std.atomic" {
10+
test {
1111
_ = @import("atomic/stack.zig");
1212
_ = @import("atomic/queue.zig");
1313
_ = @import("atomic/Atomic.zig");

lib/std/bit_set.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,6 +1635,8 @@ fn testStaticBitSet(comptime Set: type) !void {
16351635
}
16361636

16371637
test "IntegerBitSet" {
1638+
if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
1639+
16381640
try testStaticBitSet(IntegerBitSet(0));
16391641
try testStaticBitSet(IntegerBitSet(1));
16401642
try testStaticBitSet(IntegerBitSet(2));

lib/std/crypto/aes.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ const testing = std.testing;
55
const has_aesni = std.Target.x86.featureSetHas(builtin.cpu.features, .aes);
66
const has_avx = std.Target.x86.featureSetHas(builtin.cpu.features, .avx);
77
const has_armaes = std.Target.aarch64.featureSetHas(builtin.cpu.features, .aes);
8-
const impl = if (builtin.cpu.arch == .x86_64 and has_aesni and has_avx) impl: {
8+
// C backend doesn't currently support passing vectors to inline asm.
9+
const impl = if (builtin.cpu.arch == .x86_64 and builtin.zig_backend != .stage2_c and has_aesni and has_avx) impl: {
910
break :impl @import("aes/aesni.zig");
10-
} else if (builtin.cpu.arch == .aarch64 and has_armaes)
11+
} else if (builtin.cpu.arch == .aarch64 and builtin.zig_backend != .stage2_c and has_armaes)
1112
impl: {
1213
break :impl @import("aes/armcrypto.zig");
1314
} else impl: {

lib/std/crypto/aes_ocb.zig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ inline fn xorWith(x: *Block, y: Block) void {
257257
const hexToBytes = std.fmt.hexToBytes;
258258

259259
test "AesOcb test vector 1" {
260+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
261+
260262
var k: [Aes128Ocb.key_length]u8 = undefined;
261263
var nonce: [Aes128Ocb.nonce_length]u8 = undefined;
262264
var tag: [Aes128Ocb.tag_length]u8 = undefined;
@@ -274,6 +276,8 @@ test "AesOcb test vector 1" {
274276
}
275277

276278
test "AesOcb test vector 2" {
279+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
280+
277281
var k: [Aes128Ocb.key_length]u8 = undefined;
278282
var nonce: [Aes128Ocb.nonce_length]u8 = undefined;
279283
var tag: [Aes128Ocb.tag_length]u8 = undefined;
@@ -293,6 +297,8 @@ test "AesOcb test vector 2" {
293297
}
294298

295299
test "AesOcb test vector 3" {
300+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
301+
296302
var k: [Aes128Ocb.key_length]u8 = undefined;
297303
var nonce: [Aes128Ocb.nonce_length]u8 = undefined;
298304
var tag: [Aes128Ocb.tag_length]u8 = undefined;
@@ -315,6 +321,8 @@ test "AesOcb test vector 3" {
315321
}
316322

317323
test "AesOcb test vector 4" {
324+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
325+
318326
var k: [Aes128Ocb.key_length]u8 = undefined;
319327
var nonce: [Aes128Ocb.nonce_length]u8 = undefined;
320328
var tag: [Aes128Ocb.tag_length]u8 = undefined;

lib/std/crypto/ecdsa.zig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const builtin = @import("builtin");
12
const std = @import("std");
23
const crypto = std.crypto;
34
const fmt = std.fmt;
@@ -373,6 +374,8 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type {
373374
}
374375

375376
test "ECDSA - Basic operations over EcdsaP384Sha384" {
377+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
378+
376379
const Scheme = EcdsaP384Sha384;
377380
const kp = try Scheme.KeyPair.create(null);
378381
const msg = "test";
@@ -387,6 +390,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha384" {
387390
}
388391

389392
test "ECDSA - Basic operations over Secp256k1" {
393+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
394+
390395
const Scheme = EcdsaSecp256k1Sha256oSha256;
391396
const kp = try Scheme.KeyPair.create(null);
392397
const msg = "test";
@@ -401,6 +406,8 @@ test "ECDSA - Basic operations over Secp256k1" {
401406
}
402407

403408
test "ECDSA - Basic operations over EcdsaP384Sha256" {
409+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
410+
404411
const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);
405412
const kp = try Scheme.KeyPair.create(null);
406413
const msg = "test";
@@ -415,6 +422,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha256" {
415422
}
416423

417424
test "ECDSA - Verifying a existing signature with EcdsaP384Sha256" {
425+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
426+
418427
const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);
419428
// zig fmt: off
420429
const sk_bytes = [_]u8{
@@ -457,6 +466,8 @@ const TestVector = struct {
457466
};
458467

459468
test "ECDSA - Test vectors from Project Wycheproof" {
469+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
470+
460471
const vectors = [_]TestVector{
461472
.{ .key = "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e", .msg = "313233343030", .sig = "304402202ba3a8be6b94d5ec80a6d9d1190a436effe50d85a1eee859b8cc6af9bd5c2e1802204cd60b855d442f5b3c7b11eb6c4e0ae7525fe710fab9aa7c77a67f79e6fadd76", .result = .valid },
462473
.{ .key = "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e", .msg = "313233343030", .sig = "304402202ba3a8be6b94d5ec80a6d9d1190a436effe50d85a1eee859b8cc6af9bd5c2e180220b329f479a2bbd0a5c384ee1493b1f5186a87139cac5df4087c134b49156847db", .result = .acceptable },
@@ -869,6 +880,8 @@ fn tvTry(vector: TestVector) !void {
869880
}
870881

871882
test "ECDSA - Sec1 encoding/decoding" {
883+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
884+
872885
const Scheme = EcdsaP384Sha384;
873886
const kp = try Scheme.KeyPair.create(null);
874887
const pk = kp.public_key;

lib/std/crypto/ghash_polyval.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,10 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
248248
const has_pclmul = std.Target.x86.featureSetHas(builtin.cpu.features, .pclmul);
249249
const has_avx = std.Target.x86.featureSetHas(builtin.cpu.features, .avx);
250250
const has_armaes = std.Target.aarch64.featureSetHas(builtin.cpu.features, .aes);
251-
const clmul = if (builtin.cpu.arch == .x86_64 and has_pclmul and has_avx) impl: {
251+
// C backend doesn't currently support passing vectors to inline asm.
252+
const clmul = if (builtin.cpu.arch == .x86_64 and builtin.zig_backend != .stage2_c and has_pclmul and has_avx) impl: {
252253
break :impl clmulPclmul;
253-
} else if (builtin.cpu.arch == .aarch64 and has_armaes) impl: {
254+
} else if (builtin.cpu.arch == .aarch64 and builtin.zig_backend != .stage2_c and has_armaes) impl: {
254255
break :impl clmulPmull;
255256
} else impl: {
256257
break :impl clmulSoft;

lib/std/crypto/pcurves/p256.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,6 @@ pub const AffineCoordinates = struct {
473473
}
474474
};
475475

476-
test "p256" {
476+
test {
477477
_ = @import("tests/p256.zig");
478478
}

lib/std/crypto/pcurves/p384.zig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,8 @@ pub const AffineCoordinates = struct {
473473
}
474474
};
475475

476-
test "p384" {
476+
test {
477+
if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
478+
477479
_ = @import("tests/p384.zig");
478480
}

lib/std/crypto/pcurves/secp256k1.zig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ pub const AffineCoordinates = struct {
551551
}
552552
};
553553

554-
test "secp256k1" {
554+
test {
555+
if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
556+
555557
_ = @import("tests/secp256k1.zig");
556558
}

lib/std/crypto/sha2.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
205205

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

lib/std/debug.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,8 @@ pub fn dumpStackPointerAddr(prefix: []const u8) void {
21892189
}
21902190

21912191
test "manage resources correctly" {
2192+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // error.UnsupportedBackend
2193+
21922194
if (builtin.os.tag == .wasi) return error.SkipZigTest;
21932195

21942196
if (builtin.os.tag == .windows and builtin.cpu.arch == .x86_64) {

lib/std/hash.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const xxhash = @import("hash/xxhash.zig");
3636
pub const XxHash64 = xxhash.XxHash64;
3737
pub const XxHash32 = xxhash.XxHash32;
3838

39-
test "hash" {
39+
test {
4040
_ = adler;
4141
_ = auto_hash;
4242
_ = crc;

lib/std/math/big/int_test.zig

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,8 @@ test "big.int mul multi-single" {
915915
}
916916

917917
test "big.int mul multi-multi" {
918+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
919+
918920
var op1: u256 = 0x998888efefefefefefefef;
919921
var op2: u256 = 0x333000abababababababab;
920922
var a = try Managed.initSet(testing.allocator, op1);
@@ -1034,6 +1036,8 @@ test "big.int mulWrap single-single signed" {
10341036
}
10351037

10361038
test "big.int mulWrap multi-multi unsigned" {
1039+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1040+
10371041
var op1: u256 = 0x998888efefefefefefefef;
10381042
var op2: u256 = 0x333000abababababababab;
10391043
var a = try Managed.initSet(testing.allocator, op1);
@@ -1049,6 +1053,8 @@ test "big.int mulWrap multi-multi unsigned" {
10491053
}
10501054

10511055
test "big.int mulWrap multi-multi signed" {
1056+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1057+
10521058
var a = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb) - 1);
10531059
defer a.deinit();
10541060
var b = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb));
@@ -1252,6 +1258,8 @@ test "big.int div q=0 alias" {
12521258
}
12531259

12541260
test "big.int div multi-multi q < r" {
1261+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1262+
12551263
const op1 = 0x1ffffffff0078f432;
12561264
const op2 = 0x1ffffffff01000000;
12571265
var a = try Managed.initSet(testing.allocator, op1);
@@ -1608,6 +1616,8 @@ test "big.int div floor positive close to zero" {
16081616
}
16091617

16101618
test "big.int div multi-multi with rem" {
1619+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1620+
16111621
var a = try Managed.initSet(testing.allocator, 0x8888999911110000ffffeeeeddddccccbbbbaaaa9999);
16121622
defer a.deinit();
16131623
var b = try Managed.initSet(testing.allocator, 0x99990000111122223333);
@@ -1624,6 +1634,8 @@ test "big.int div multi-multi with rem" {
16241634
}
16251635

16261636
test "big.int div multi-multi no rem" {
1637+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1638+
16271639
var a = try Managed.initSet(testing.allocator, 0x8888999911110000ffffeeeedb4fec200ee3a4286361);
16281640
defer a.deinit();
16291641
var b = try Managed.initSet(testing.allocator, 0x99990000111122223333);
@@ -1640,6 +1652,8 @@ test "big.int div multi-multi no rem" {
16401652
}
16411653

16421654
test "big.int div multi-multi (2 branch)" {
1655+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1656+
16431657
var a = try Managed.initSet(testing.allocator, 0x866666665555555588888887777777761111111111111111);
16441658
defer a.deinit();
16451659
var b = try Managed.initSet(testing.allocator, 0x86666666555555554444444433333333);
@@ -1656,6 +1670,8 @@ test "big.int div multi-multi (2 branch)" {
16561670
}
16571671

16581672
test "big.int div multi-multi (3.1/3.3 branch)" {
1673+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1674+
16591675
var a = try Managed.initSet(testing.allocator, 0x11111111111111111111111111111111111111111111111111111111111111);
16601676
defer a.deinit();
16611677
var b = try Managed.initSet(testing.allocator, 0x1111111111111111111111111111111111111111171);
@@ -1672,6 +1688,8 @@ test "big.int div multi-multi (3.1/3.3 branch)" {
16721688
}
16731689

16741690
test "big.int div multi-single zero-limb trailing" {
1691+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1692+
16751693
var a = try Managed.initSet(testing.allocator, 0x60000000000000000000000000000000000000000000000000000000000000000);
16761694
defer a.deinit();
16771695
var b = try Managed.initSet(testing.allocator, 0x10000000000000000);
@@ -1690,6 +1708,8 @@ test "big.int div multi-single zero-limb trailing" {
16901708
}
16911709

16921710
test "big.int div multi-multi zero-limb trailing (with rem)" {
1711+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1712+
16931713
var a = try Managed.initSet(testing.allocator, 0x86666666555555558888888777777776111111111111111100000000000000000000000000000000);
16941714
defer a.deinit();
16951715
var b = try Managed.initSet(testing.allocator, 0x8666666655555555444444443333333300000000000000000000000000000000);
@@ -1709,6 +1729,8 @@ test "big.int div multi-multi zero-limb trailing (with rem)" {
17091729
}
17101730

17111731
test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-limb count > divisor zero-limb count" {
1732+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1733+
17121734
var a = try Managed.initSet(testing.allocator, 0x8666666655555555888888877777777611111111111111110000000000000000);
17131735
defer a.deinit();
17141736
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
17281750
}
17291751

17301752
test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-limb count < divisor zero-limb count" {
1753+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1754+
17311755
var a = try Managed.initSet(testing.allocator, 0x86666666555555558888888777777776111111111111111100000000000000000000000000000000);
17321756
defer a.deinit();
17331757
var b = try Managed.initSet(testing.allocator, 0x866666665555555544444444333333330000000000000000);
@@ -2486,6 +2510,8 @@ test "big.int gcd non-one large" {
24862510
}
24872511

24882512
test "big.int gcd large multi-limb result" {
2513+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
2514+
24892515
var a = try Managed.initSet(testing.allocator, 0x12345678123456781234567812345678123456781234567812345678);
24902516
defer a.deinit();
24912517
var b = try Managed.initSet(testing.allocator, 0x12345671234567123456712345671234567123456712345671234567);

lib/std/math/complex.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ test "complex.magnitude" {
189189
try testing.expect(math.approxEqAbs(f32, c, 5.83095, epsilon));
190190
}
191191

192-
test "complex.cmath" {
192+
test {
193193
_ = @import("complex/abs.zig");
194194
_ = @import("complex/acosh.zig");
195195
_ = @import("complex/acos.zig");

lib/std/mem.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,8 @@ test "comptime read/write int" {
15041504
}
15051505

15061506
test "readIntBig and readIntLittle" {
1507+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1508+
15071509
try testing.expect(readIntSliceBig(u0, &[_]u8{}) == 0x0);
15081510
try testing.expect(readIntSliceLittle(u0, &[_]u8{}) == 0x0);
15091511

@@ -1795,6 +1797,8 @@ pub fn writeVarPackedInt(bytes: []u8, bit_offset: usize, bit_count: usize, value
17951797
}
17961798

17971799
test "writeIntBig and writeIntLittle" {
1800+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1801+
17981802
var buf0: [0]u8 = undefined;
17991803
var buf1: [1]u8 = undefined;
18001804
var buf2: [2]u8 = undefined;
@@ -4011,6 +4015,8 @@ pub fn alignInSlice(slice: anytype, comptime new_alignment: usize) ?AlignedSlice
40114015
}
40124016

40134017
test "read/write(Var)PackedInt" {
4018+
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
4019+
40144020
switch (builtin.cpu.arch) {
40154021
// This test generates too much code to execute on WASI.
40164022
// LLVM backend fails with "too many locals: locals exceed maximum"

lib/std/meta.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub const TrailerFlags = @import("meta/trailer_flags.zig").TrailerFlags;
1010

1111
const Type = std.builtin.Type;
1212

13-
test "std.meta.TrailerFlags" {
13+
test {
1414
_ = TrailerFlags;
1515
}
1616

lib/std/os/test.zig

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,7 @@ fn iter_fn(info: *dl_phdr_info, size: usize, counter: *usize) IterFnError!void {
502502
}
503503

504504
test "dl_iterate_phdr" {
505-
if (native_os == .windows or native_os == .wasi or native_os == .macos)
506-
return error.SkipZigTest;
505+
if (builtin.object_format != .elf) return error.SkipZigTest;
507506

508507
var counter: usize = 0;
509508
try os.dl_iterate_phdr(&counter, IterFnError, iter_fn);
@@ -797,6 +796,11 @@ test "sigaction" {
797796
if (native_os == .linux and builtin.target.cpu.arch == .x86)
798797
return error.SkipZigTest;
799798

799+
// https://github.com/ziglang/zig/issues/15381
800+
if (native_os == .macos and builtin.target.cpu.arch == .x86_64) {
801+
return error.SkipZigTest;
802+
}
803+
800804
const S = struct {
801805
var handler_called_count: u32 = 0;
802806

0 commit comments

Comments
 (0)