From: Tianjiao Yin Date: Mon, 20 Nov 2017 02:51:19 +0000 (-0800) Subject: fix SingletonTest X-Git-Tag: v2017.11.20.00^0 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=79376dc7937cd38c10c0c632e3b39c6955ebd734;hp=dc91b004d384ba57887b38d4668845bffee0ba08;p=folly.git fix SingletonTest Summary: There is no guarantee that this code will finish in 6 seconds (nor other threads will release singleton in 5 seconds), especially in ASAN mode. Though I don't have better idea, this diff will relax the condition in ASAN mode to make the unit-test less flaky. Reviewed By: yfeldblum Differential Revision: D6371692 fbshipit-source-id: 58dd15cc0b3273719314c8b323ba88ee47e8ff61 --- diff --git a/folly/test/SingletonTest.cpp b/folly/test/SingletonTest.cpp index 04fe0707..806b7715 100644 --- a/folly/test/SingletonTest.cpp +++ b/folly/test/SingletonTest.cpp @@ -262,8 +262,9 @@ TEST(Singleton, SharedPtrUsage) { auto start_time = std::chrono::steady_clock::now(); vault.destroyInstances(); auto duration = std::chrono::steady_clock::now() - start_time; - EXPECT_TRUE(duration > std::chrono::seconds{4} && - duration < std::chrono::seconds{6}); + EXPECT_TRUE( + duration > std::chrono::seconds{4} && + duration < std::chrono::seconds{folly::kIsSanitizeAddress ? 30 : 6}); } EXPECT_EQ(vault.registeredSingletonCount(), 4); EXPECT_EQ(vault.livingSingletonCount(), 0);