[libc++] Fixes a flaky test.
authorMark de Wever <koraq@xs4all.nl>
Sat, 11 Feb 2023 15:45:35 +0000 (16:45 +0100)
committerMark de Wever <koraq@xs4all.nl>
Fri, 17 Feb 2023 17:22:09 +0000 (18:22 +0100)
commit261d21f8c3754e148eaf6608d359ec6e56fa276c
treee68bb668c08debbe15dd11ed0c6de06fd1053e0a
parentc8399811e7b162bb1b11c06a2d757d23576b1c95
[libc++] Fixes a flaky test.

While investigating the flaky tests on the mac backdeployment targets
it seems the tests are different than suggested in the LWG issue.
That tests "does work", grabs the mutex, marks the task as done, and
finally calls the notifier.
Our test emulated "does work" after the notification, effectively
sleeping with a lock held. This has been fixed.

A second improvement is that the test fails when, due to OS
scheduling, the condition variable is not used in the main thread.

During discussing the approach of the patch with @ldionne, he
noticed the real reason why the test is flaky; the Apple
backdeployment targets use a dylib, which does not contain the
fix. So the test can't be tested on that platform; it only
proves the LWG issue was correct and the Standard contained
a bug.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D143816
libcxx/test/std/thread/thread.condition/notify_all_at_thread_exit_lwg3343.pass.cpp