Commit 76260bc1 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

cppgc: Cleanups around testing

Bug: chromium:1056170
Change-Id: Ic6e40d5e5e9bcca28a8c344adfab06f4e88701aa
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2737302
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73231}
parent c87b273c
...@@ -170,7 +170,7 @@ bool FreeList::IsEmpty() const { ...@@ -170,7 +170,7 @@ bool FreeList::IsEmpty() const {
[](const auto* entry) { return !entry; }); [](const auto* entry) { return !entry; });
} }
bool FreeList::Contains(Block block) const { bool FreeList::ContainsForTesting(Block block) const {
for (Entry* list : free_list_heads_) { for (Entry* list : free_list_heads_) {
for (Entry* entry = list; entry; entry = entry->Next()) { for (Entry* entry = list; entry; entry = entry->Next()) {
if (entry <= block.address && if (entry <= block.address &&
......
...@@ -44,10 +44,10 @@ class V8_EXPORT_PRIVATE FreeList { ...@@ -44,10 +44,10 @@ class V8_EXPORT_PRIVATE FreeList {
size_t Size() const; size_t Size() const;
bool IsEmpty() const; bool IsEmpty() const;
bool Contains(Block) const;
void CollectStatistics(HeapStatistics::FreeListStatistics&); void CollectStatistics(HeapStatistics::FreeListStatistics&);
bool ContainsForTesting(Block) const;
private: private:
class Entry; class Entry;
......
...@@ -132,7 +132,7 @@ class ConcurrentSweeperTest : public testing::TestWithHeap { ...@@ -132,7 +132,7 @@ class ConcurrentSweeperTest : public testing::TestWithHeap {
// The corresponding page could be removed. // The corresponding page could be removed.
if (!backend->Lookup(static_cast<ConstAddress>(object))) continue; if (!backend->Lookup(static_cast<ConstAddress>(object))) continue;
if (!freelist.Contains({object, 0})) return false; if (!freelist.ContainsForTesting({object, 0})) return false;
} }
return true; return true;
......
...@@ -151,7 +151,7 @@ TEST(FreeListTest, Contains) { ...@@ -151,7 +151,7 @@ TEST(FreeListTest, Contains) {
FreeList list = CreatePopulatedFreeList(blocks); FreeList list = CreatePopulatedFreeList(blocks);
for (const auto& block : blocks) { for (const auto& block : blocks) {
EXPECT_TRUE(list.Contains({block.Address(), block.Size()})); EXPECT_TRUE(list.ContainsForTesting({block.Address(), block.Size()}));
} }
} }
......
...@@ -195,12 +195,12 @@ TEST_F(PageTest, NormalPageCreationDestruction) { ...@@ -195,12 +195,12 @@ TEST_F(PageTest, NormalPageCreationDestruction) {
EXPECT_NE(space->end(), std::find(space->begin(), space->end(), page)); EXPECT_NE(space->end(), std::find(space->begin(), space->end(), page));
space->free_list().Add({page->PayloadStart(), page->PayloadSize()}); space->free_list().Add({page->PayloadStart(), page->PayloadSize()});
EXPECT_TRUE( EXPECT_TRUE(space->free_list().ContainsForTesting(
space->free_list().Contains({page->PayloadStart(), page->PayloadSize()})); {page->PayloadStart(), page->PayloadSize()}));
space->free_list().Clear(); space->free_list().Clear();
EXPECT_FALSE( EXPECT_FALSE(space->free_list().ContainsForTesting(
space->free_list().Contains({page->PayloadStart(), page->PayloadSize()})); {page->PayloadStart(), page->PayloadSize()}));
space->RemovePage(page); space->RemovePage(page);
EXPECT_EQ(space->end(), std::find(space->begin(), space->end(), page)); EXPECT_EQ(space->end(), std::find(space->begin(), space->end(), page));
NormalPage::Destroy(page); NormalPage::Destroy(page);
......
...@@ -208,12 +208,12 @@ TEST_F(SweeperTest, CoalesceFreeListEntries) { ...@@ -208,12 +208,12 @@ TEST_F(SweeperTest, CoalesceFreeListEntries) {
object2_start, static_cast<size_t>(object3_end - object2_start)}; object2_start, static_cast<size_t>(object3_end - object2_start)};
EXPECT_EQ(0u, g_destructor_callcount); EXPECT_EQ(0u, g_destructor_callcount);
EXPECT_FALSE(freelist.Contains(coalesced_block)); EXPECT_FALSE(freelist.ContainsForTesting(coalesced_block));
Sweep(); Sweep();
EXPECT_EQ(2u, g_destructor_callcount); EXPECT_EQ(2u, g_destructor_callcount);
EXPECT_TRUE(freelist.Contains(coalesced_block)); EXPECT_TRUE(freelist.ContainsForTesting(coalesced_block));
} }
namespace { namespace {
......
...@@ -100,7 +100,7 @@ class TestWithHeap : public TestWithPlatform { ...@@ -100,7 +100,7 @@ class TestWithHeap : public TestWithPlatform {
// Restrictive test fixture that supports allocation but will make sure no // Restrictive test fixture that supports allocation but will make sure no
// garbage collection is triggered. This is useful for writing idiomatic // garbage collection is triggered. This is useful for writing idiomatic
// tests where object are allocated on the managed heap while still avoiding // tests where object are allocated on the managed heap while still avoiding
// far reaching test consquences of full garbage collection calls. // far reaching test consequences of full garbage collection calls.
class TestSupportingAllocationOnly : public TestWithHeap { class TestSupportingAllocationOnly : public TestWithHeap {
protected: protected:
TestSupportingAllocationOnly(); TestSupportingAllocationOnly();
......
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