[libcxx-commits] [PATCH] D99768: [libcxx] [test] Make the condvar wait_for tests a bit more understandable. NFC.
Martin Storsjö via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Apr 2 00:56:30 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf8013a35b6fb: [libcxx] [test] Make the condvar wait_for tests a bit more understandable. NFC. (authored by mstorsjo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99768/new/
https://reviews.llvm.org/D99768
Files:
libcxx/test/std/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp
libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp
Index: libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp
===================================================================
--- libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp
+++ 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);
Index: libcxx/test/std/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp
===================================================================
--- libcxx/test/std/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp
+++ 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<std::mutex> lk(mut);
std::thread t = support::make_test_thread(f);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99768.334913.patch
Type: text/x-patch
Size: 2196 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210402/c4ac2a15/attachment.bin>
More information about the libcxx-commits
mailing list