Skip to content

Commit

Permalink
[scudo] Test secondary cache options only if enabled (llvm#95872)
Browse files Browse the repository at this point in the history
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/llvm/pull/95595
](llvm#95595) from merging into
Fuchsia.
  • Loading branch information
Caslyn committed Jun 18, 2024
1 parent b1477eb commit 6f13f0b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,13 @@ TEST_F(MapAllocatorTest, SecondaryIterate) {
}

TEST_F(MapAllocatorTest, SecondaryOptions) {
// 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));
// 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(
Expand Down

0 comments on commit 6f13f0b

Please sign in to comment.