From 159472b1ce6a5f6d8daeef02e9506ce9f08c6f2c Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 2 Aug 2020 07:11:13 +0300 Subject: [PATCH 1/2] remove timing assumption --- tests/std/include/test_atomic_wait.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/std/include/test_atomic_wait.hpp b/tests/std/include/test_atomic_wait.hpp index 248615cdf42..83bbd889674 100644 --- a/tests/std/include/test_atomic_wait.hpp +++ b/tests/std/include/test_atomic_wait.hpp @@ -38,9 +38,11 @@ void test_atomic_wait_func(const UnderlyingType old_value, const UnderlyingType add_seq('4'); a.store(new_value); a.notify_one(); +#ifdef CAN_FAIL_ON_TIMING_ASSUMPTION // timing assumption that the main thread evaluates the `wait(old_value)` before this timeout expires std::this_thread::sleep_for(waiting_duration); add_seq('6'); +#endif }); a.wait(old_value); @@ -52,7 +54,12 @@ void test_atomic_wait_func(const UnderlyingType old_value, const UnderlyingType thd.join(); add_seq('\0'); + +#ifdef CAN_FAIL_ON_TIMING_ASSUMPTION assert(strcmp(seq, "123456") == 0); +#else + assert(strcmp(seq, "12345") == 0); +#endif } template From 7e2e57bc549536dfec76ffdf18841bf7fa6a6873 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 2 Aug 2020 17:13:05 +0300 Subject: [PATCH 2/2] Update tests/std/include/test_atomic_wait.hpp Co-authored-by: Stephan T. Lavavej --- tests/std/include/test_atomic_wait.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/std/include/test_atomic_wait.hpp b/tests/std/include/test_atomic_wait.hpp index 83bbd889674..aa003b906d5 100644 --- a/tests/std/include/test_atomic_wait.hpp +++ b/tests/std/include/test_atomic_wait.hpp @@ -42,7 +42,7 @@ void test_atomic_wait_func(const UnderlyingType old_value, const UnderlyingType // timing assumption that the main thread evaluates the `wait(old_value)` before this timeout expires std::this_thread::sleep_for(waiting_duration); add_seq('6'); -#endif +#endif // CAN_FAIL_ON_TIMING_ASSUMPTION }); a.wait(old_value);