From 520bbb1774cefe51306d0821f6e7118e1013ea08 Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Thu, 12 Jul 2018 18:23:27 -0700 Subject: [PATCH] Disable EnvPosixTest.RunImmediately, add EnvPosixTest.RunEventually. (#4126) Summary: The original `EnvPosixTest.RunImmediately` assumes that after scheduling a background thread, the thread is guaranteed to complete after 0.1 second. I do not know about any non-real-time OS/runtime providing this guarantee. Nor does C++11 standard say anything about this in the documentation of `std::thread`. In fact, we have observed this test failure multiple times on appveyor, and we haven't been able to reproduce the failure deterministically. Therefore, I disable this test for now until we know for sure how it used to fail. Instead, I add another test `EnvPosixTest.RunEventually` that checks that a thread will be scheduled eventually. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4126 Differential Revision: D8827086 Pulled By: riversand963 fbshipit-source-id: abc5cb655f90d50b791493da5eeb3716885dfe93 --- env/env_test.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/env/env_test.cc b/env/env_test.cc index 8023b9d3d..69807a81b 100644 --- a/env/env_test.cc +++ b/env/env_test.cc @@ -125,7 +125,7 @@ static void SetBool(void* ptr) { reinterpret_cast*>(ptr)->store(true); } -TEST_F(EnvPosixTest, RunImmediately) { +TEST_F(EnvPosixTest, DISABLED_RunImmediately) { for (int pri = Env::BOTTOM; pri < Env::TOTAL; ++pri) { std::atomic called(false); env_->SetBackgroundThreads(1, static_cast(pri)); @@ -135,6 +135,13 @@ TEST_F(EnvPosixTest, RunImmediately) { } } +TEST_F(EnvPosixTest, RunEventually) { + std::atomic called(false); + env_->StartThread(&SetBool, &called); + env_->WaitForJoin(); + ASSERT_TRUE(called.load()); +} + #ifdef OS_WIN TEST_F(EnvPosixTest, AreFilesSame) { {