[libcxx-commits] [PATCH] D79406: [libcxx testing] Make three locking tests more reliable

David Zarzycki via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 6 04:16:17 PDT 2020


davezarzycki added a comment.

Hi @ldionne – Ya, it looks like a lot of those tests need fixing. The "tolerance" goal is within them is fundamentally flawed. These tests are not testing "real time" APIs where one can hopefully reason about precise timing. These APIs are best-effort APIs and on a slow and/or heavily loaded machine, best-effort can get really slow. I don't have the time to fix all of the tests but here is the gist of what needs fixing is twofold:

1. Use an atomic variable to ensure that all the created threads have started. This isn't perfect, but it's far better than not verifying that they've started.
2. Think hard about each "tolerance" test and convert it to either `>= WaitTime` or `<= WaitTime`

I'd also like to add that there seem to be other issues. For example: lock_shared.pass.cpp has two tests, and the latter probably meant to test that a writer lock must wait for readers to finish, but instead it "tests" that a reader lock "waited" (the 'q' thread) but due to signed arithmetic, a negative wait time passes the tolerance test. :-( I'll supply a fix, but really, I don't have the time to audit all of these tests.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79406/new/

https://reviews.llvm.org/D79406





More information about the libcxx-commits mailing list