[all-commits] [llvm/llvm-project] 01aa9e: [libcxx] [test] Make the condvar wait_for tests le...

Martin Storsjö via All-commits all-commits at lists.llvm.org
Thu Apr 1 11:45:43 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 01aa9e1f6e7df5a936612084c73be704e300c881
      https://github.com/llvm/llvm-project/commit/01aa9e1f6e7df5a936612084c73be704e300c881
  Author: Martin Storsjö <martin at martin.st>
  Date:   2021-04-01 (Thu, 01 Apr 2021)

  Changed paths:
    M libcxx/test/std/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp
    M libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp

  Log Message:
  -----------
  [libcxx] [test] Make the condvar wait_for tests less brittle

These seem to fail occasionally (they are marked as possibly requiring
a retry).

When doing a condvar wait_for(), it can wake up before the timeout
as a spurious wakeup. In these cases, the wait_for() method returns that
the timeout wasn't hit, and the test reruns another wait_for().

On Windows, it seems like the wait_for() operation often can end up
returning slightly before the intended deadline - when intending to
wait for 250 milliseconds, it can return after e.g. 235 milliseconds.
In these cases, the wait_for() doesn't indicate a timeout.

Previously, the test then reran a new wait_for() for a full 250
milliseconds each time. So for N consecutive wakeups slightly too early,
we'd wait for (N+1)*250 milliseconds. Now it only reruns wait_for() for
the remaining intended wait duration.

Differential Revision: https://reviews.llvm.org/D99175




More information about the All-commits mailing list