authorgravatar for shritesh@shritesh.comShritesh Bhattarai <shritesh@shritesh.com> 2019-04-05 17:12:46-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-05 18:12:46-04:00
log895e6eabc2fb294719dc39d6ad05e79086470b3d
tree7b7c8532d6e595fcc3bc9dba82248b10bd090e55
parentd72239d3391a7f3b771245072bb5cdb50a4fb652

Fix getCurrentId test for pthreads (#2197)

* Fix getCurrentId test for pthreads

1 files changed, 11 insertions(+), 7 deletions(-)

std/os/test.zig+11-7
...@@ -46,13 +46,17 @@ test "std.os.Thread.getCurrentId" {...@@ -46,13 +46,17 @@ test "std.os.Thread.getCurrentId" {
46 const thread = try os.spawnThread(&thread_current_id, testThreadIdFn);46 const thread = try os.spawnThread(&thread_current_id, testThreadIdFn);
47 const thread_id = thread.handle();47 const thread_id = thread.handle();
48 thread.wait();48 thread.wait();
49 switch (builtin.os) {49 if (os.Thread.use_pthreads) {
50 builtin.Os.windows => expect(os.Thread.getCurrentId() != thread_current_id),50 expect(thread_current_id == thread_id);
51 else => {51 } else {
52 // If the thread completes very quickly, then thread_id can be 0. See the52 switch (builtin.os) {
53 // documentation comments for `std.os.Thread.handle`.53 builtin.Os.windows => expect(os.Thread.getCurrentId() != thread_current_id),
54 expect(thread_id == 0 or thread_current_id == thread_id);54 else => {
55 },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 }
56 }60 }
57}61}
5862