[scudo] Add unmapTestOnly() to secondary. am: da86a54d0f
Original change: https://android-review.googlesource.com/c/platform/external/scudo/+/1718171
Change-Id: I3c3248482ea6a60b0c45a5e2ef86225462d29e15
diff --git a/standalone/combined.h b/standalone/combined.h
index 8080d67..f17c371 100644
--- a/standalone/combined.h
+++ b/standalone/combined.h
@@ -215,6 +215,7 @@
void unmapTestOnly() {
TSDRegistry.unmapTestOnly();
Primary.unmapTestOnly();
+ Secondary.unmapTestOnly();
#ifdef GWP_ASAN_HOOKS
if (getFlags()->GWP_ASAN_InstallSignalHandlers)
gwp_asan::segv_handler::uninstallSignalHandlers();
diff --git a/standalone/secondary.h b/standalone/secondary.h
index 77db873..3894b01 100644
--- a/standalone/secondary.h
+++ b/standalone/secondary.h
@@ -83,6 +83,7 @@
void enable() {}
void releaseToOS() {}
void disableMemoryTagging() {}
+ void unmapTestOnly() {}
bool setOption(Option O, UNUSED sptr Value) {
if (O == Option::ReleaseInterval || O == Option::MaxCacheEntriesCount ||
O == Option::MaxCacheEntrySize)
@@ -326,6 +327,8 @@
void enable() { Mutex.unlock(); }
+ void unmapTestOnly() { empty(); }
+
private:
void empty() {
struct {
@@ -456,6 +459,8 @@
void disableMemoryTagging() { Cache.disableMemoryTagging(); }
+ void unmapTestOnly() { Cache.unmapTestOnly(); }
+
private:
typename Config::SecondaryCache Cache;
diff --git a/standalone/tests/secondary_test.cpp b/standalone/tests/secondary_test.cpp
index c50101a..2320a4d 100644
--- a/standalone/tests/secondary_test.cpp
+++ b/standalone/tests/secondary_test.cpp
@@ -67,6 +67,7 @@
scudo::ScopedString Str(1024);
L->getStats(&Str);
Str.output();
+ L->unmapTestOnly();
}
struct NoCacheConfig {
@@ -124,6 +125,7 @@
scudo::ScopedString Str(1024);
L->getStats(&Str);
Str.output();
+ L->unmapTestOnly();
}
TEST(ScudoSecondaryTest, SecondaryIterate) {
@@ -147,6 +149,7 @@
scudo::ScopedString Str(1024);
L->getStats(&Str);
Str.output();
+ L->unmapTestOnly();
}
TEST(ScudoSecondaryTest, SecondaryOptions) {
@@ -170,6 +173,7 @@
EXPECT_TRUE(L->setOption(scudo::Option::MaxCacheEntrySize, 1UL << 20));
EXPECT_TRUE(L->canCache(1UL << 16));
}
+ L->unmapTestOnly();
}
static std::mutex Mutex;
@@ -216,4 +220,5 @@
scudo::ScopedString Str(1024);
L->getStats(&Str);
Str.output();
+ L->unmapTestOnly();
}