Skip to content

Commit 895e6ea

Browse files
shriteshandrewrk
authored andcommitted
Fix getCurrentId test for pthreads (#2197)
* Fix getCurrentId test for pthreads
1 parent d72239d commit 895e6ea

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

std/os/test.zig

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,17 @@ test "std.os.Thread.getCurrentId" {
4646
const thread = try os.spawnThread(&thread_current_id, testThreadIdFn);
4747
const thread_id = thread.handle();
4848
thread.wait();
49-
switch (builtin.os) {
50-
builtin.Os.windows => expect(os.Thread.getCurrentId() != thread_current_id),
51-
else => {
52-
// If the thread completes very quickly, then thread_id can be 0. See the
53-
// documentation comments for `std.os.Thread.handle`.
54-
expect(thread_id == 0 or thread_current_id == thread_id);
55-
},
49+
if (os.Thread.use_pthreads) {
50+
expect(thread_current_id == thread_id);
51+
} else {
52+
switch (builtin.os) {
53+
builtin.Os.windows => expect(os.Thread.getCurrentId() != thread_current_id),
54+
else => {
55+
// If the thread completes very quickly, then thread_id can be 0. See the
56+
// documentation comments for `std.os.Thread.handle`.
57+
expect(thread_id == 0 or thread_current_id == thread_id);
58+
},
59+
}
5660
}
5761
}
5862

0 commit comments

Comments
 (0)