Remove timing assumption that causes test to fail spuriously (#1129)

This commit is contained in:
Alex Guteniev 2020-08-03 23:40:04 +03:00 коммит произвёл GitHub
Родитель b57b7685ff
Коммит b74b6188b2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -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 // CAN_FAIL_ON_TIMING_ASSUMPTION
});
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 <class UnderlyingType>