[compiler-rt] [scudo] Minor refactoring of secondary cache test (PR #95995)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 26 14:53:20 PDT 2024
https://github.com/ChiaHungDuan updated https://github.com/llvm/llvm-project/pull/95995
>From 08e61e81de38c3db10c2cbdf206f6a0f5e061a77 Mon Sep 17 00:00:00 2001
From: Chia-hung Duan <chiahungduan at google.com>
Date: Tue, 18 Jun 2024 21:27:09 +0000
Subject: [PATCH] [scudo] Minor refactoring of secondary cache test
---
.../scudo/standalone/tests/secondary_test.cpp | 49 ++++++++++---------
1 file 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 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