diff options
Diffstat (limited to 'lib/scudo/standalone/tests')
-rw-r--r-- | lib/scudo/standalone/tests/combined_test.cpp | 16 | ||||
-rw-r--r-- | lib/scudo/standalone/tests/primary_test.cpp | 19 | ||||
-rw-r--r-- | lib/scudo/standalone/tests/quarantine_test.cpp | 8 | ||||
-rw-r--r-- | lib/scudo/standalone/tests/secondary_test.cpp | 16 |
4 files changed, 46 insertions, 13 deletions
diff --git a/lib/scudo/standalone/tests/combined_test.cpp b/lib/scudo/standalone/tests/combined_test.cpp index 3f971a304..d74c07e84 100644 --- a/lib/scudo/standalone/tests/combined_test.cpp +++ b/lib/scudo/standalone/tests/combined_test.cpp @@ -136,7 +136,21 @@ template <class Config> static void testAllocator() { } Allocator->releaseToOS(); - Allocator->printStats(); + + scudo::uptr BufferSize = 8192; + std::vector<char> Buffer(BufferSize); + scudo::uptr ActualSize = Allocator->getStats(Buffer.data(), BufferSize); + while (ActualSize > BufferSize) { + BufferSize = ActualSize + 1024; + Buffer.resize(BufferSize); + ActualSize = Allocator->getStats(Buffer.data(), BufferSize); + } + std::string Stats(Buffer.begin(), Buffer.end()); + // Basic checks on the contents of the statistics output, which also allows us + // to verify that we got it all. + EXPECT_NE(Stats.find("Stats: SizeClassAllocator"), std::string::npos); + EXPECT_NE(Stats.find("Stats: MapAllocator"), std::string::npos); + EXPECT_NE(Stats.find("Stats: Quarantine"), std::string::npos); } TEST(ScudoCombinedTest, BasicCombined) { diff --git a/lib/scudo/standalone/tests/primary_test.cpp b/lib/scudo/standalone/tests/primary_test.cpp index a6cfc6bdb..7da7b25ca 100644 --- a/lib/scudo/standalone/tests/primary_test.cpp +++ b/lib/scudo/standalone/tests/primary_test.cpp @@ -46,7 +46,9 @@ template <typename Primary> static void testPrimary() { } Cache.destroy(nullptr); Allocator->releaseToOS(); - Allocator->printStats(); + scudo::ScopedString Str(1024); + Allocator->getStats(&Str); + Str.output(); } TEST(ScudoPrimaryTest, BasicPrimary) { @@ -86,7 +88,9 @@ TEST(ScudoPrimaryTest, Primary64OOM) { } Cache.destroy(nullptr); Allocator.releaseToOS(); - Allocator.printStats(); + scudo::ScopedString Str(1024); + Allocator.getStats(&Str); + Str.output(); EXPECT_EQ(AllocationFailed, true); Allocator.unmapTestOnly(); } @@ -125,7 +129,9 @@ template <typename Primary> static void testIteratePrimary() { } Cache.destroy(nullptr); Allocator->releaseToOS(); - Allocator->printStats(); + scudo::ScopedString Str(1024); + Allocator->getStats(&Str); + Str.output(); } TEST(ScudoPrimaryTest, PrimaryIterate) { @@ -180,7 +186,9 @@ template <typename Primary> static void testPrimaryThreaded() { for (auto &T : Threads) T.join(); Allocator->releaseToOS(); - Allocator->printStats(); + scudo::ScopedString Str(1024); + Allocator->getStats(&Str); + Str.output(); } TEST(ScudoPrimaryTest, PrimaryThreaded) { @@ -203,8 +211,7 @@ template <typename Primary> static void testReleaseToOS() { Cache.init(nullptr, Allocator.get()); const scudo::uptr Size = scudo::getPageSizeCached() * 2; EXPECT_TRUE(Primary::canAllocate(Size)); - const scudo::uptr ClassId = - Primary::SizeClassMap::getClassIdBySize(Size); + const scudo::uptr ClassId = Primary::SizeClassMap::getClassIdBySize(Size); void *P = Cache.allocate(ClassId); EXPECT_NE(P, nullptr); Cache.deallocate(ClassId, P); diff --git a/lib/scudo/standalone/tests/quarantine_test.cpp b/lib/scudo/standalone/tests/quarantine_test.cpp index d7453aa42..28baf8feb 100644 --- a/lib/scudo/standalone/tests/quarantine_test.cpp +++ b/lib/scudo/standalone/tests/quarantine_test.cpp @@ -213,7 +213,9 @@ TEST(ScudoQuarantineTest, GlobalQuarantine) { Quarantine.drainAndRecycle(&Cache, Cb); EXPECT_EQ(Cache.getSize(), 0UL); - Quarantine.printStats(); + scudo::ScopedString Str(1024); + Quarantine.getStats(&Str); + Str.output(); } void *populateQuarantine(void *Param) { @@ -236,5 +238,7 @@ TEST(ScudoQuarantineTest, ThreadedGlobalQuarantine) { for (scudo::uptr I = 0; I < NumberOfThreads; I++) pthread_join(T[I], 0); - Quarantine.printStats(); + scudo::ScopedString Str(1024); + Quarantine.getStats(&Str); + Str.output(); } diff --git a/lib/scudo/standalone/tests/secondary_test.cpp b/lib/scudo/standalone/tests/secondary_test.cpp index 84c375449..b602b8d63 100644 --- a/lib/scudo/standalone/tests/secondary_test.cpp +++ b/lib/scudo/standalone/tests/secondary_test.cpp @@ -45,7 +45,9 @@ TEST(ScudoSecondaryTest, SecondaryBasic) { L->deallocate(V.back()); V.pop_back(); } - L->printStats(); + scudo::ScopedString Str(1024); + L->getStats(&Str); + Str.output(); } // This exercises a variety of combinations of size and alignment for the @@ -76,7 +78,9 @@ TEST(ScudoSecondaryTest, SecondaryCombinations) { } } } - L->printStats(); + scudo::ScopedString Str(1024); + L->getStats(&Str); + Str.output(); } TEST(ScudoSecondaryTest, SecondaryIterate) { @@ -97,7 +101,9 @@ TEST(ScudoSecondaryTest, SecondaryIterate) { L->deallocate(V.back()); V.pop_back(); } - L->printStats(); + scudo::ScopedString Str(1024); + L->getStats(&Str); + Str.output(); } static std::mutex Mutex; @@ -133,5 +139,7 @@ TEST(ScudoSecondaryTest, SecondaryThreadsRace) { } for (auto &T : Threads) T.join(); - L->printStats(); + scudo::ScopedString Str(1024); + L->getStats(&Str); + Str.output(); } |