diff --git a/libcxx/test/std/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp b/libcxx/test/std/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp --- a/libcxx/test/std/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp +++ b/libcxx/test/std/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp @@ -33,7 +33,7 @@ int test1 = 0; int test2 = 0; -int runs = 0; +bool expect_timeout = false; void f() { @@ -51,7 +51,7 @@ if (d <= milliseconds(0)) break; } while (test2 == 0 && cv.wait_for(lk, d) == std::cv_status::no_timeout); Clock::time_point t1 = Clock::now(); - if (runs == 0) + if (!expect_timeout) { assert(t1 - t0 < milliseconds(250)); assert(test2 != 0); @@ -61,7 +61,6 @@ assert(t1 - t0 - milliseconds(250) < milliseconds(50)); assert(test2 == 0); } - ++runs; } int main(int, char**) @@ -80,6 +79,7 @@ } test1 = 0; test2 = 0; + expect_timeout = true; { std::unique_lock lk(mut); std::thread t = support::make_test_thread(f); diff --git a/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp b/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp --- a/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp +++ b/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp @@ -36,7 +36,7 @@ int test1 = 0; int test2 = 0; -int runs = 0; +bool expect_timeout = false; void f() { @@ -54,7 +54,7 @@ if (d <= milliseconds(0)) break; } while (test2 == 0 && cv.wait_for(lk, d) == std::cv_status::no_timeout); Clock::time_point t1 = Clock::now(); - if (runs == 0) + if (!expect_timeout) { assert(t1 - t0 < milliseconds(250)); assert(test2 != 0); @@ -64,7 +64,6 @@ assert(t1 - t0 - milliseconds(250) < milliseconds(50)); assert(test2 == 0); } - ++runs; } int main(int, char**) @@ -83,6 +82,7 @@ } test1 = 0; test2 = 0; + expect_timeout = true; { L1 lk(m0); std::thread t = support::make_test_thread(f);