diff --git a/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp b/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp index af69313214ea6..e74930148f25e 100644 --- a/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp @@ -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(