Skip to content

Commit

Permalink
Stop relying on allocator behaviour in modules unit test
Browse files Browse the repository at this point in the history
Another fixup for r355778 for Windows bots, this time to stop
accidentally relying on allocator behaviour for the test to pass.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355780 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit 59f2009)
  • Loading branch information
dexonsmith committed Mar 20, 2019
1 parent ccf0846 commit 781261b
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions unittests/Serialization/InMemoryModuleCacheTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,15 @@ TEST(InMemoryModuleCacheTest, addBuiltPCM) {
}

TEST(InMemoryModuleCacheTest, tryToDropPCM) {
auto B = getBuffer(1);
auto *RawB = B.get();
auto B1 = getBuffer(1);
auto B2 = getBuffer(2);
auto *RawB1 = B1.get();
auto *RawB2 = B2.get();
ASSERT_NE(RawB1, RawB2);

InMemoryModuleCache Cache;
EXPECT_EQ(InMemoryModuleCache::Unknown, Cache.getPCMState("B"));
EXPECT_EQ(RawB, &Cache.addPCM("B", std::move(B)));
EXPECT_EQ(RawB1, &Cache.addPCM("B", std::move(B1)));
EXPECT_FALSE(Cache.tryToDropPCM("B"));
EXPECT_EQ(nullptr, Cache.lookupPCM("B"));
EXPECT_EQ(InMemoryModuleCache::ToBuild, Cache.getPCMState("B"));
Expand All @@ -91,17 +94,13 @@ TEST(InMemoryModuleCacheTest, tryToDropPCM) {
EXPECT_DEATH(Cache.finalizePCM("B"), "Trying to finalize a dropped PCM");
#endif

B = getBuffer(2);
ASSERT_NE(RawB, B.get());
RawB = B.get();

// Add a new one.
EXPECT_EQ(RawB, &Cache.addBuiltPCM("B", std::move(B)));
EXPECT_EQ(RawB2, &Cache.addBuiltPCM("B", std::move(B2)));
EXPECT_TRUE(Cache.isPCMFinal("B"));

// Can try to drop again, but this should error and do nothing.
EXPECT_TRUE(Cache.tryToDropPCM("B"));
EXPECT_EQ(RawB, Cache.lookupPCM("B"));
EXPECT_EQ(RawB2, Cache.lookupPCM("B"));
}

TEST(InMemoryModuleCacheTest, finalizePCM) {
Expand Down

0 comments on commit 781261b

Please sign in to comment.