Skip to content

Commit 220c679

Browse files
authored
Merge pull request #25197 from rootbeer/24380-flaky-sigset-test
Re-enable std.posix "sigset_t bits" test
2 parents 09bc118 + bd46170 commit 220c679

File tree

9 files changed

+485
-387
lines changed

9 files changed

+485
-387
lines changed

lib/std/Thread.zig

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,3 +1637,40 @@ test detach {
16371637
event.wait();
16381638
try std.testing.expectEqual(value, 1);
16391639
}
1640+
1641+
test "Thread.getCpuCount" {
1642+
if (native_os == .wasi) return error.SkipZigTest;
1643+
1644+
const cpu_count = try Thread.getCpuCount();
1645+
try std.testing.expect(cpu_count >= 1);
1646+
}
1647+
1648+
fn testThreadIdFn(thread_id: *Thread.Id) void {
1649+
thread_id.* = Thread.getCurrentId();
1650+
}
1651+
1652+
test "Thread.getCurrentId" {
1653+
if (builtin.single_threaded) return error.SkipZigTest;
1654+
1655+
var thread_current_id: Thread.Id = undefined;
1656+
const thread = try Thread.spawn(.{}, testThreadIdFn, .{&thread_current_id});
1657+
thread.join();
1658+
try std.testing.expect(Thread.getCurrentId() != thread_current_id);
1659+
}
1660+
1661+
test "thread local storage" {
1662+
if (builtin.single_threaded) return error.SkipZigTest;
1663+
1664+
const thread1 = try Thread.spawn(.{}, testTls, .{});
1665+
const thread2 = try Thread.spawn(.{}, testTls, .{});
1666+
try testTls();
1667+
thread1.join();
1668+
thread2.join();
1669+
}
1670+
1671+
threadlocal var x: i32 = 1234;
1672+
fn testTls() !void {
1673+
if (x != 1234) return error.TlsBadStartValue;
1674+
x += 1;
1675+
if (x != 1235) return error.TlsBadEndValue;
1676+
}

0 commit comments

Comments
 (0)