- auto start = Clock::now();
- EXPECT_EQ(f.futexWaitUntil(0, start + milliseconds(100)),
- FutexResult::TIMEDOUT);
- LOG(INFO) << "Futex wait timed out after waiting for "
- << duration_cast<milliseconds>(Clock::now() - start).count()
- << "ms, should be ~100ms";
+ {
+ const auto start = Clock::now();
+ const auto deadline = time_point_cast<Duration>(start + milliseconds(100));
+ EXPECT_EQ(f.futexWaitUntil(0, deadline), FutexResult::TIMEDOUT);
+ LOG(INFO) << "Futex wait timed out after waiting for "
+ << duration_cast<milliseconds>(Clock::now() - start).count()
+ << "ms using clock with " << Duration::period::den
+ << " precision, should be ~100ms";
+ }
+
+ {
+ const auto start = Clock::now();
+ const auto deadline = time_point_cast<Duration>(
+ start - 2 * start.time_since_epoch());
+ EXPECT_EQ(f.futexWaitUntil(0, deadline), FutexResult::TIMEDOUT);
+ LOG(INFO) << "Futex wait with invalid deadline timed out after waiting for "
+ << duration_cast<milliseconds>(Clock::now() - start).count()
+ << "ms using clock with " << Duration::period::den
+ << " precision, should be ~0ms";
+ }