[libcxx testing] Make three locking tests more reliable
authorDavid Zarzycki <dave@znu.io>
Sat, 9 May 2020 15:10:41 +0000 (11:10 -0400)
committerDavid Zarzycki <dave@znu.io>
Sat, 9 May 2020 15:11:26 +0000 (11:11 -0400)
commit4f4ce13944b88bcd678e615d340c21ea1cf5d3ec
treee940c39bb1877ce04019f0f4b4d7384bc4a92418
parent0b9783350b3a9644dc6e0ba94c0f6a87ca45cb36
[libcxx testing] Make three locking tests more reliable

The challenge with measuring time in tests is that slow and/or busy
machines can cause tests to fail in unexpected ways. After this change,
three tests should be much more robust. The only remaining and tiny race
that I can think of is preemption after `--countDown`. That being said,
the race isn't fixable because the standard library doesn't provide a
way to count threads that are waiting to acquire a lock.

Reviewers: ldionne, EricWF, howard.hinnant, mclow.lists, #libc

Reviewed By: ldionne, #libc

Subscribers: dexonsmith, jfb, broadwaylamb, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D79406
libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp
libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp
libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp