Skip to content

Commit 6f13f0b

Browse files
authored
[scudo] Test secondary cache options only if enabled (#95872)
Configs that use `MapAllocatorNoCache` for its secondary cache will return `false` if `setOption` is called with some [specific options](https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/scudo/standalone/secondary.h#L104), and this breaks with the `SecondaryOptions` test. This change will gate testing all `setOption` expectations for cache options only if the allocator cache is enabled. This will unblock [github.com//pull/95595 ](#95595) from merging into Fuchsia.
1 parent b1477eb commit 6f13f0b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,13 @@ TEST_F(MapAllocatorTest, SecondaryIterate) {
191191
}
192192

193193
TEST_F(MapAllocatorTest, SecondaryOptions) {
194-
// Attempt to set a maximum number of entries higher than the array size.
195-
EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4096U));
196-
197-
// Attempt to set an invalid (negative) number of entries
198-
EXPECT_FALSE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, -1));
194+
// Test options that are only meaningful if the secondary cache is enabled.
199195
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));
200201
// Various valid combinations.
201202
EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4U));
202203
EXPECT_TRUE(

0 commit comments

Comments
 (0)