Commit c27b2745 authored by Tianjiao Yin's avatar Tianjiao Yin Committed by Facebook Github Bot

fix FutexTest

Summary: 2_ms seems too short. I am not sure whether it's feasible to check whether thread is waiting for an address. We could wait for longer to reduce false alarm.

Reviewed By: nbronson

Differential Revision: D5220819

fbshipit-source-id: 42f31206e9cb7f9addaa049d0e7cd995f6735f6c
parent ee87051b
...@@ -184,17 +184,19 @@ void run_steady_clock_test() { ...@@ -184,17 +184,19 @@ void run_steady_clock_test() {
template <template <typename> class Atom> template <template <typename> class Atom>
void run_wake_blocked_test() { void run_wake_blocked_test() {
Futex<Atom> f(0); for (auto delay = std::chrono::milliseconds(1);; delay *= 2) {
bool success = false;
auto thr = DSched::thread([&] { EXPECT_TRUE(f.futexWait(0)); }); Futex<Atom> f(0);
auto thr = DSched::thread([&] { success = f.futexWait(0); });
// A sleep here guarantees to a large extent that 'thr' will execute /* sleep override */ std::this_thread::sleep_for(delay);
// futexWait before we wake it up, thus testing late futexWake. f.store(1);
std::this_thread::sleep_for(std::chrono::milliseconds(2)); f.futexWake(1);
DSched::join(thr);
f.store(1); LOG(INFO) << "delay=" << delay.count() << "_ms, success=" << success;
f.futexWake(1); if (success) {
DSched::join(thr); break;
}
}
} }
TEST(Futex, clock_source) { TEST(Futex, clock_source) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment