From: Yedidya Feldblum Date: Wed, 24 Feb 2016 00:35:17 +0000 (-0800) Subject: Fix Build: folly/test/IndestructibleTest.cpp under LSAN X-Git-Tag: deprecate-dynamic-initializer~45 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2739d9370ef5d0f3cc51f8c45e289caf83613009;p=folly.git Fix Build: folly/test/IndestructibleTest.cpp under LSAN Summary:[Folly] Fix Build: `folly/test/IndestructibleTest.cpp` under LSAN. Leaks of Meyers singletons are ignored automatically, while normal locals are not. So we make our instances be Meyers singletons. Differential Revision: D2968368 fb-gh-sync-id: 385ac4491d9a105885af82d85354af929d69cc80 shipit-source-id: 385ac4491d9a105885af82d85354af929d69cc80 --- diff --git a/folly/test/IndestructibleTest.cpp b/folly/test/IndestructibleTest.cpp index 6733138d..6ee8005d 100644 --- a/folly/test/IndestructibleTest.cpp +++ b/folly/test/IndestructibleTest.cpp @@ -49,7 +49,7 @@ class IndestructibleTest : public testing::Test {}; } TEST_F(IndestructibleTest, access) { - const Indestructible> data{ + static const Indestructible> data{ map{{"key1", 17}, {"key2", 19}, {"key3", 23}}}; auto& m = *data; @@ -60,7 +60,7 @@ TEST_F(IndestructibleTest, no_destruction) { int state = 0; int value = 0; - auto sing = make_unique>( + static Indestructible sing( [&] { ++state; value = 7; @@ -70,7 +70,7 @@ TEST_F(IndestructibleTest, no_destruction) { EXPECT_EQ(1, state); EXPECT_EQ(7, value); - sing = nullptr; + sing.~Indestructible(); EXPECT_EQ(1, state); } @@ -79,7 +79,7 @@ TEST_F(IndestructibleTest, move) { int value = 0; int moves = 0; - Indestructible sing( // move assignment + static Indestructible sing( // move assignment [&] { ++state; value = 7; @@ -91,11 +91,13 @@ TEST_F(IndestructibleTest, move) { EXPECT_EQ(7, value); EXPECT_EQ(0, moves); - Indestructible move_ctor(std::move(sing)); // move constructor + // move constructor + static Indestructible move_ctor(std::move(sing)); EXPECT_EQ(1, state); EXPECT_EQ(1, moves); - Indestructible move_assign = std::move(move_ctor); // move assignment + // move assignment + static Indestructible move_assign = std::move(move_ctor); EXPECT_EQ(1, state); EXPECT_EQ(2, moves); }