-
- Downloads
[libstdc++] [testsuite] avoid async.cc loss of precision [PR91486]
When we get to test_pr91486_wait_until(), we're about 10s past the float_steady_clock epoch. This is enough for the 1s delta for the timeout to come out slightly lower when the futex-less wait_until converts the deadline from float_steady_clock to __clock_t. So we may wake up a little too early, and end up looping one extra time to sleep for e.g. another 954ns until we hit the deadline. Each iteration calls float_steady_clock::now(), bumping the call_count that we VERIFY() at the end of the subtest. Since we expect at most 3 calls, and we're going to have at the very least 3 on futex-less targets (one in the test proper, one before wait_until_impl to compute the deadline, and one after wait_until_impl to check whether the deadline was hit), any such imprecision that causes an extra iteration will reach 5 and cause the test to fail. Initializing the epoch in the beginning of the test makes such spurious fails due to loss of precision far less likely. I don't suppose allowing for an extra couple of calls would be desirable. While at that, I'm annotating unused status variables as such. for libstdc++-v3/ChangeLog PR libstdc++/91486 * testsuite/30_threads/async/async.cc (test_pr91486_wait_for): Mark status as unused. (test_pr91486_wait_until): Likewise. Initialize epoch later.
Please register or sign in to comment