This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Make some threading tests more robust
ClosedPublic

Authored by mstorsjo on Aug 9 2022, 3:49 AM.

Details

Summary

Increase the timeout tolerance if TEST_HAS_SANITIZERS is set, similarly
to how it's done in a couple other tests.

Use std::this_thread::yield(); instead of busylooping. When multiple
threads are busylooping, it's plausible that not all threads even get
started running before the timeout runs out.

This makes the threading tests succeed if run in Windows runners on
Github Actions.

Diff Detail

Event Timeline

mstorsjo created this revision.Aug 9 2022, 3:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2022, 3:49 AM
mstorsjo requested review of this revision.Aug 9 2022, 3:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2022, 3:49 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Mordante accepted this revision.Aug 10 2022, 12:24 PM
Mordante added a subscriber: Mordante.

LGTM, with a nit. I would have preferred to do D131484 before this one. (I don't think it's worth your time to inverse the order now.)

libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp
40

Can you add the comment of the other similar tests (See D131484)

This revision is now accepted and ready to land.Aug 10 2022, 12:24 PM

LGTM, with a nit. I would have preferred to do D131484 before this one. (I don't think it's worth your time to inverse the order now.)

I'm totally ok with landing D131484 before this one; I just sent them out in parallel for reviewing.

libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp
40

Sure (although some of the existing ones also lack the comment, e.g. the third diff here on phab). Also, if landing D131484 and renaming the define to TEST_IS_SLOW, should the comments be reworded slightly (all of them)? Because I was hitting the tolerance when running without sanitizers too...

mstorsjo updated this revision to Diff 451819.Aug 11 2022, 5:36 AM

Rebased the patch on top of D131484, added the same descriptive comment on the new uses of the define too.

ldionne accepted this revision.Aug 18 2022, 1:34 PM
This revision was automatically updated to reflect the committed changes.