[scudo] Only print stats when the test fails. (#168000)
When running the tests on other platforms, printing the stats on all of the passing tests makes it hard to see failure output. Therefore, this change only prints the stats if the test actually fails.
This commit is contained in:
parent
ab2a302f0e
commit
420f62e05c
@ -326,8 +326,10 @@ void ScudoCombinedTest<Config>::BasicTest(scudo::uptr SizeLog) {
|
||||
}
|
||||
}
|
||||
|
||||
Allocator->printStats();
|
||||
Allocator->printFragmentationInfo();
|
||||
if (TEST_HAS_FAILURE) {
|
||||
Allocator->printStats();
|
||||
Allocator->printFragmentationInfo();
|
||||
}
|
||||
}
|
||||
|
||||
#define SCUDO_MAKE_BASIC_TEST(SizeLog) \
|
||||
|
||||
@ -230,9 +230,11 @@ SCUDO_TYPED_TEST(ScudoPrimaryTest, BasicPrimary) {
|
||||
}
|
||||
SizeClassAllocator.destroy(nullptr);
|
||||
Allocator->releaseToOS(scudo::ReleaseToOS::Force);
|
||||
scudo::ScopedString Str;
|
||||
Allocator->getStats(&Str);
|
||||
Str.output();
|
||||
if (TEST_HAS_FAILURE) {
|
||||
scudo::ScopedString Str;
|
||||
Allocator->getStats(&Str);
|
||||
Str.output();
|
||||
}
|
||||
}
|
||||
|
||||
struct SmallRegionsConfig {
|
||||
@ -289,10 +291,12 @@ TEST(ScudoPrimaryTest, Primary64OOM) {
|
||||
|
||||
SizeClassAllocator.destroy(nullptr);
|
||||
Allocator.releaseToOS(scudo::ReleaseToOS::Force);
|
||||
scudo::ScopedString Str;
|
||||
Allocator.getStats(&Str);
|
||||
Str.output();
|
||||
EXPECT_EQ(AllocationFailed, true);
|
||||
if (TEST_HAS_FAILURE) {
|
||||
scudo::ScopedString Str;
|
||||
Allocator.getStats(&Str);
|
||||
Str.output();
|
||||
}
|
||||
Allocator.unmapTestOnly();
|
||||
}
|
||||
|
||||
@ -328,9 +332,11 @@ SCUDO_TYPED_TEST(ScudoPrimaryTest, PrimaryIterate) {
|
||||
}
|
||||
SizeClassAllocator.destroy(nullptr);
|
||||
Allocator->releaseToOS(scudo::ReleaseToOS::Force);
|
||||
scudo::ScopedString Str;
|
||||
Allocator->getStats(&Str);
|
||||
Str.output();
|
||||
if (TEST_HAS_FAILURE) {
|
||||
scudo::ScopedString Str;
|
||||
Allocator->getStats(&Str);
|
||||
Str.output();
|
||||
}
|
||||
}
|
||||
|
||||
SCUDO_TYPED_TEST(ScudoPrimaryTest, PrimaryThreaded) {
|
||||
@ -385,11 +391,13 @@ SCUDO_TYPED_TEST(ScudoPrimaryTest, PrimaryThreaded) {
|
||||
for (auto &T : Threads)
|
||||
T.join();
|
||||
Allocator->releaseToOS(scudo::ReleaseToOS::Force);
|
||||
scudo::ScopedString Str;
|
||||
Allocator->getStats(&Str);
|
||||
Allocator->getFragmentationInfo(&Str);
|
||||
Allocator->getMemoryGroupFragmentationInfo(&Str);
|
||||
Str.output();
|
||||
if (TEST_HAS_FAILURE) {
|
||||
scudo::ScopedString Str;
|
||||
Allocator->getStats(&Str);
|
||||
Allocator->getFragmentationInfo(&Str);
|
||||
Allocator->getMemoryGroupFragmentationInfo(&Str);
|
||||
Str.output();
|
||||
}
|
||||
}
|
||||
|
||||
// Through a simple allocation that spans two pages, verify that releaseToOS
|
||||
|
||||
@ -216,9 +216,11 @@ TEST(ScudoQuarantineTest, GlobalQuarantine) {
|
||||
Quarantine.drainAndRecycle(&Cache, Cb);
|
||||
EXPECT_EQ(Cache.getSize(), 0UL);
|
||||
|
||||
scudo::ScopedString Str;
|
||||
Quarantine.getStats(&Str);
|
||||
Str.output();
|
||||
if (TEST_HAS_FAILURE) {
|
||||
scudo::ScopedString Str;
|
||||
Quarantine.getStats(&Str);
|
||||
Str.output();
|
||||
}
|
||||
}
|
||||
|
||||
struct PopulateQuarantineThread {
|
||||
@ -248,9 +250,11 @@ TEST(ScudoQuarantineTest, ThreadedGlobalQuarantine) {
|
||||
for (scudo::uptr I = 0; I < NumberOfThreads; I++)
|
||||
pthread_join(T[I].Thread, 0);
|
||||
|
||||
scudo::ScopedString Str;
|
||||
Quarantine.getStats(&Str);
|
||||
Str.output();
|
||||
if (TEST_HAS_FAILURE) {
|
||||
scudo::ScopedString Str;
|
||||
Quarantine.getStats(&Str);
|
||||
Str.output();
|
||||
}
|
||||
|
||||
for (scudo::uptr I = 0; I < NumberOfThreads; I++)
|
||||
Quarantine.drainAndRecycle(&T[I].Cache, Cb);
|
||||
|
||||
@ -12,8 +12,10 @@
|
||||
|
||||
template <class SizeClassMap> void testSizeClassMap() {
|
||||
typedef SizeClassMap SCMap;
|
||||
scudo::printMap<SCMap>();
|
||||
scudo::validateMap<SCMap>();
|
||||
if (TEST_HAS_FAILURE) {
|
||||
scudo::printMap<SCMap>();
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ScudoSizeClassMapTest, DefaultSizeClassMap) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user