aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChiaHungDuan <chiahungduan@google.com>2024-06-26 21:28:29 -0700
committerGitHub <noreply@github.com>2024-06-26 21:28:29 -0700
commit91b614fc63acd0480afb76579e0200afbf9a381e (patch)
tree602769b9bce9e7ff055a7a29dd9052c8849a38bc
parent6ca387cbcb207abe2a07bbb1b536f099c2e246e7 (diff)
downloadllvm-91b614fc63acd0480afb76579e0200afbf9a381e.zip
llvm-91b614fc63acd0480afb76579e0200afbf9a381e.tar.gz
llvm-91b614fc63acd0480afb76579e0200afbf9a381e.tar.bz2
[scudo] Minor refactoring of secondary cache test (#95995)
-rw-r--r--compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp49
1 files changed, 25 insertions, 24 deletions
diff --git a/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp b/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp
index e749301..5685a93 100644
--- a/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp
@@ -190,30 +190,31 @@ TEST_F(MapAllocatorTest, SecondaryIterate) {
Str.output();
}
-TEST_F(MapAllocatorTest, SecondaryOptions) {
- // Test options that are only meaningful if the secondary cache is enabled.
- if (Allocator->canCache(0U)) {
- // Attempt to set a maximum number of entries higher than the array size.
- EXPECT_TRUE(
- Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4096U));
- // Attempt to set an invalid (negative) number of entries
- EXPECT_FALSE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, -1));
- // Various valid combinations.
- EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4U));
- EXPECT_TRUE(
- Allocator->setOption(scudo::Option::MaxCacheEntrySize, 1UL << 20));
- EXPECT_TRUE(Allocator->canCache(1UL << 18));
- EXPECT_TRUE(
- Allocator->setOption(scudo::Option::MaxCacheEntrySize, 1UL << 17));
- EXPECT_FALSE(Allocator->canCache(1UL << 18));
- EXPECT_TRUE(Allocator->canCache(1UL << 16));
- EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 0U));
- EXPECT_FALSE(Allocator->canCache(1UL << 16));
- EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4U));
- EXPECT_TRUE(
- Allocator->setOption(scudo::Option::MaxCacheEntrySize, 1UL << 20));
- EXPECT_TRUE(Allocator->canCache(1UL << 16));
- }
+TEST_F(MapAllocatorTest, SecondaryCacheOptions) {
+ if (!Allocator->canCache(0U))
+ TEST_SKIP("Secondary Cache disabled");
+
+ // Attempt to set a maximum number of entries higher than the array size.
+ EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4096U));
+
+ // Attempt to set an invalid (negative) number of entries
+ EXPECT_FALSE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, -1));
+
+ // Various valid combinations.
+ EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4U));
+ EXPECT_TRUE(
+ Allocator->setOption(scudo::Option::MaxCacheEntrySize, 1UL << 20));
+ EXPECT_TRUE(Allocator->canCache(1UL << 18));
+ EXPECT_TRUE(
+ Allocator->setOption(scudo::Option::MaxCacheEntrySize, 1UL << 17));
+ EXPECT_FALSE(Allocator->canCache(1UL << 18));
+ EXPECT_TRUE(Allocator->canCache(1UL << 16));
+ EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 0U));
+ EXPECT_FALSE(Allocator->canCache(1UL << 16));
+ EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4U));
+ EXPECT_TRUE(
+ Allocator->setOption(scudo::Option::MaxCacheEntrySize, 1UL << 20));
+ EXPECT_TRUE(Allocator->canCache(1UL << 16));
}
struct MapAllocatorWithReleaseTest : public MapAllocatorTest {