Skip to content

Commit 2cbefd4

Browse files
ChiaHungDuanAlexisPerry
authored andcommitted
[scudo] Minor refactoring of secondary cache test (llvm#95995)
1 parent 0cdd9d0 commit 2cbefd4

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -190,30 +190,31 @@ TEST_F(MapAllocatorTest, SecondaryIterate) {
190190
Str.output();
191191
}
192192

193-
TEST_F(MapAllocatorTest, SecondaryOptions) {
194-
// Test options that are only meaningful if the secondary cache is enabled.
195-
if (Allocator->canCache(0U)) {
196-
// Attempt to set a maximum number of entries higher than the array size.
197-
EXPECT_TRUE(
198-
Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4096U));
199-
// Attempt to set an invalid (negative) number of entries
200-
EXPECT_FALSE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, -1));
201-
// Various valid combinations.
202-
EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4U));
203-
EXPECT_TRUE(
204-
Allocator->setOption(scudo::Option::MaxCacheEntrySize, 1UL << 20));
205-
EXPECT_TRUE(Allocator->canCache(1UL << 18));
206-
EXPECT_TRUE(
207-
Allocator->setOption(scudo::Option::MaxCacheEntrySize, 1UL << 17));
208-
EXPECT_FALSE(Allocator->canCache(1UL << 18));
209-
EXPECT_TRUE(Allocator->canCache(1UL << 16));
210-
EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 0U));
211-
EXPECT_FALSE(Allocator->canCache(1UL << 16));
212-
EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4U));
213-
EXPECT_TRUE(
214-
Allocator->setOption(scudo::Option::MaxCacheEntrySize, 1UL << 20));
215-
EXPECT_TRUE(Allocator->canCache(1UL << 16));
216-
}
193+
TEST_F(MapAllocatorTest, SecondaryCacheOptions) {
194+
if (!Allocator->canCache(0U))
195+
TEST_SKIP("Secondary Cache disabled");
196+
197+
// Attempt to set a maximum number of entries higher than the array size.
198+
EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4096U));
199+
200+
// Attempt to set an invalid (negative) number of entries
201+
EXPECT_FALSE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, -1));
202+
203+
// Various valid combinations.
204+
EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4U));
205+
EXPECT_TRUE(
206+
Allocator->setOption(scudo::Option::MaxCacheEntrySize, 1UL << 20));
207+
EXPECT_TRUE(Allocator->canCache(1UL << 18));
208+
EXPECT_TRUE(
209+
Allocator->setOption(scudo::Option::MaxCacheEntrySize, 1UL << 17));
210+
EXPECT_FALSE(Allocator->canCache(1UL << 18));
211+
EXPECT_TRUE(Allocator->canCache(1UL << 16));
212+
EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 0U));
213+
EXPECT_FALSE(Allocator->canCache(1UL << 16));
214+
EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4U));
215+
EXPECT_TRUE(
216+
Allocator->setOption(scudo::Option::MaxCacheEntrySize, 1UL << 20));
217+
EXPECT_TRUE(Allocator->canCache(1UL << 16));
217218
}
218219

219220
struct MapAllocatorWithReleaseTest : public MapAllocatorTest {

0 commit comments

Comments
 (0)