[compiler-rt] 91b614f - [scudo] Minor refactoring of secondary cache test (#95995)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 26 21:28:31 PDT 2024
Author: ChiaHungDuan
Date: 2024-06-26T21:28:29-07:00
New Revision: 91b614fc63acd0480afb76579e0200afbf9a381e
URL: https://github.com/llvm/llvm-project/commit/91b614fc63acd0480afb76579e0200afbf9a381e
DIFF: https://github.com/llvm/llvm-project/commit/91b614fc63acd0480afb76579e0200afbf9a381e.diff
LOG: [scudo] Minor refactoring of secondary cache test (#95995)
Added:
Modified:
compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp b/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp
index e74930148f25e..5685a9335316d 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 {
More information about the llvm-commits
mailing list