diff --git a/compiler-rt/lib/gwp_asan/tests/backtrace.cpp b/compiler-rt/lib/gwp_asan/tests/backtrace.cpp --- a/compiler-rt/lib/gwp_asan/tests/backtrace.cpp +++ b/compiler-rt/lib/gwp_asan/tests/backtrace.cpp @@ -30,7 +30,7 @@ *(reinterpret_cast(Ptr)) = 7; } -TEST_F(BacktraceGuardedPoolAllocator, DoubleFree) { +TEST_F(BacktraceGuardedPoolAllocatorDeathTest, DoubleFree) { void *Ptr = AllocateMemory(GPA); DeallocateMemory(GPA, Ptr); @@ -45,7 +45,7 @@ ASSERT_DEATH(DeallocateMemory2(GPA, Ptr), DeathRegex); } -TEST_F(BacktraceGuardedPoolAllocator, UseAfterFree) { +TEST_F(BacktraceGuardedPoolAllocatorDeathTest, UseAfterFree) { void *Ptr = AllocateMemory(GPA); DeallocateMemory(GPA, Ptr); diff --git a/compiler-rt/lib/gwp_asan/tests/enable_disable.cpp b/compiler-rt/lib/gwp_asan/tests/enable_disable.cpp --- a/compiler-rt/lib/gwp_asan/tests/enable_disable.cpp +++ b/compiler-rt/lib/gwp_asan/tests/enable_disable.cpp @@ -10,7 +10,7 @@ constexpr size_t Size = 100; -TEST_F(DefaultGuardedPoolAllocator, Fork) { +TEST_F(DefaultGuardedPoolAllocatorDeathTest, Fork) { void *P; pid_t Pid = fork(); EXPECT_GE(Pid, 0); diff --git a/compiler-rt/lib/gwp_asan/tests/harness.h b/compiler-rt/lib/gwp_asan/tests/harness.h --- a/compiler-rt/lib/gwp_asan/tests/harness.h +++ b/compiler-rt/lib/gwp_asan/tests/harness.h @@ -106,4 +106,9 @@ gwp_asan::GuardedPoolAllocator GPA; }; +// https://github.com/google/googletest/blob/master/docs/advanced.md#death-tests-and-threads +using DefaultGuardedPoolAllocatorDeathTest = DefaultGuardedPoolAllocator; +using CustomGuardedPoolAllocatorDeathTest = CustomGuardedPoolAllocator; +using BacktraceGuardedPoolAllocatorDeathTest = BacktraceGuardedPoolAllocator; + #endif // GWP_ASAN_TESTS_HARNESS_H_ diff --git a/compiler-rt/lib/scudo/standalone/tests/chunk_test.cpp b/compiler-rt/lib/scudo/standalone/tests/chunk_test.cpp --- a/compiler-rt/lib/scudo/standalone/tests/chunk_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/chunk_test.cpp @@ -21,7 +21,7 @@ scudo::HashAlgorithm = scudo::Checksum::HardwareCRC32; } -TEST(ScudoChunkTest, ChunkBasic) { +TEST(ScudoChunkDeathTest, ChunkBasic) { initChecksum(); const scudo::uptr Size = 0x100U; scudo::Chunk::UnpackedHeader Header = {}; @@ -60,7 +60,7 @@ free(Block); } -TEST(ScudoChunkTest, CorruptHeader) { +TEST(ScudoChunkDeathTest, CorruptHeader) { initChecksum(); const scudo::uptr Size = 0x100U; scudo::Chunk::UnpackedHeader Header = {}; diff --git a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp --- a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp @@ -103,6 +103,8 @@ std::unique_ptr Allocator; }; +template using ScudoCombinedDeathTest = ScudoCombinedTest; + #if SCUDO_FUCHSIA #define SCUDO_TYPED_TEST_ALL_TYPES(FIXTURE, NAME) \ SCUDO_TYPED_TEST_TYPE(FIXTURE, NAME, AndroidSvelteConfig) \ @@ -166,7 +168,7 @@ } #define SCUDO_MAKE_BASIC_TEST(SizeLog) \ - SCUDO_TYPED_TEST(ScudoCombinedTest, BasicCombined##SizeLog) { \ + SCUDO_TYPED_TEST(ScudoCombinedDeathTest, BasicCombined##SizeLog) { \ this->BasicTest(SizeLog); \ } @@ -314,7 +316,7 @@ Allocator->deallocate(P, Origin); } -SCUDO_TYPED_TEST(ScudoCombinedTest, ReallocateSame) { +SCUDO_TYPED_TEST(ScudoCombinedDeathTest, ReallocateSame) { auto *Allocator = this->Allocator.get(); // Check that reallocating a chunk to a slightly smaller or larger size @@ -365,7 +367,7 @@ } } -SCUDO_TYPED_TEST(ScudoCombinedTest, UseAfterFree) { +SCUDO_TYPED_TEST(ScudoCombinedDeathTest, UseAfterFree) { auto *Allocator = this->Allocator.get(); // Check that use-after-free is detected. @@ -392,7 +394,7 @@ } } -SCUDO_TYPED_TEST(ScudoCombinedTest, DisableMemoryTagging) { +SCUDO_TYPED_TEST(ScudoCombinedDeathTest, DisableMemoryTagging) { auto *Allocator = this->Allocator.get(); if (Allocator->useMemoryTaggingTestOnly()) { @@ -490,7 +492,7 @@ // Test that multiple instantiations of the allocator have not messed up the // process's signal handlers (GWP-ASan used to do this). -TEST(ScudoCombinedTest, SKIP_ON_FUCHSIA(testSEGV)) { +TEST(ScudoCombinedDeathTest, SKIP_ON_FUCHSIA(testSEGV)) { const scudo::uptr Size = 4 * scudo::getPageSizeCached(); scudo::MapPlatformData Data = {}; void *P = scudo::map(nullptr, Size, "testSEGV", MAP_NOACCESS, &Data); @@ -528,7 +530,7 @@ template using TSDRegistryT = scudo::TSDRegistrySharedT; }; -TEST(ScudoCombinedTest, DeathCombined) { +TEST(ScudoCombinedDeathTest, DeathCombined) { using AllocatorT = TestAllocator; auto Allocator = std::unique_ptr(new AllocatorT()); diff --git a/compiler-rt/lib/scudo/standalone/tests/map_test.cpp b/compiler-rt/lib/scudo/standalone/tests/map_test.cpp --- a/compiler-rt/lib/scudo/standalone/tests/map_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/map_test.cpp @@ -20,7 +20,7 @@ static_cast(getpagesize())); } -TEST(ScudoMapTest, MapNoAccessUnmap) { +TEST(ScudoMapDeathTest, MapNoAccessUnmap) { const scudo::uptr Size = 4 * scudo::getPageSizeCached(); scudo::MapPlatformData Data = {}; void *P = scudo::map(nullptr, Size, MappingName, MAP_NOACCESS, &Data); @@ -29,7 +29,7 @@ scudo::unmap(P, Size, UNMAP_ALL, &Data); } -TEST(ScudoMapTest, MapUnmap) { +TEST(ScudoMapDeathTest, MapUnmap) { const scudo::uptr Size = 4 * scudo::getPageSizeCached(); EXPECT_DEATH( { @@ -46,7 +46,7 @@ ""); } -TEST(ScudoMapTest, MapWithGuardUnmap) { +TEST(ScudoMapDeathTest, MapWithGuardUnmap) { const scudo::uptr PageSize = scudo::getPageSizeCached(); const scudo::uptr Size = 4 * PageSize; scudo::MapPlatformData Data = {}; diff --git a/compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp b/compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp --- a/compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp @@ -14,7 +14,7 @@ #if SCUDO_LINUX namespace scudo { -TEST(MemtagBasicTest, Unsupported) { +TEST(MemtagBasicDeathTest, Unsupported) { if (archSupportsMemoryTagging()) GTEST_SKIP(); @@ -63,6 +63,8 @@ uptr Addr = 0; }; +using MemtagDeathTest = MemtagTest; + TEST_F(MemtagTest, ArchMemoryTagGranuleSize) { EXPECT_GT(archMemoryTagGranuleSize(), 1u); EXPECT_TRUE(isPowerOfTwo(archMemoryTagGranuleSize())); @@ -77,7 +79,7 @@ EXPECT_EQ(0xffffull, Tags); } -TEST_F(MemtagTest, AddFixedTag) { +TEST_F(MemtagDeathTest, AddFixedTag) { for (uptr Tag = 0; Tag < 0x10; ++Tag) EXPECT_EQ(Tag, extractTag(addFixedTag(Addr, Tag))); if (SCUDO_DEBUG) { @@ -94,7 +96,7 @@ } } -TEST_F(MemtagTest, ScopedDisableMemoryTagChecks) { +TEST_F(MemtagDeathTest, ScopedDisableMemoryTagChecks) { u8 *P = reinterpret_cast(addFixedTag(Addr, 1)); EXPECT_NE(P, Buffer); @@ -120,7 +122,7 @@ } } -TEST_F(MemtagTest, SKIP_NO_DEBUG(LoadStoreTagUnaligned)) { +TEST_F(MemtagDeathTest, SKIP_NO_DEBUG(LoadStoreTagUnaligned)) { for (uptr P = Addr; P < Addr + 4 * archMemoryTagGranuleSize(); ++P) { if (P % archMemoryTagGranuleSize() == 0) continue; @@ -141,7 +143,7 @@ loadTag(Base + archMemoryTagGranuleSize())); } -TEST_F(MemtagTest, SKIP_NO_DEBUG(StoreTagsUnaligned)) { +TEST_F(MemtagDeathTest, SKIP_NO_DEBUG(StoreTagsUnaligned)) { for (uptr P = Addr; P < Addr + 4 * archMemoryTagGranuleSize(); ++P) { uptr Tagged = addFixedTag(P, 5); if (Tagged % archMemoryTagGranuleSize() == 0) diff --git a/compiler-rt/lib/scudo/standalone/tests/report_test.cpp b/compiler-rt/lib/scudo/standalone/tests/report_test.cpp --- a/compiler-rt/lib/scudo/standalone/tests/report_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/report_test.cpp @@ -10,14 +10,14 @@ #include "report.h" -TEST(ScudoReportTest, Check) { +TEST(ScudoReportDeathTest, Check) { CHECK_LT(-1, 1); EXPECT_DEATH(CHECK_GT(-1, 1), "\\(-1\\) > \\(1\\) \\(\\(u64\\)op1=18446744073709551615, " "\\(u64\\)op2=1"); } -TEST(ScudoReportTest, Generic) { +TEST(ScudoReportDeathTest, Generic) { // Potentially unused if EXPECT_DEATH isn't defined. UNUSED void *P = reinterpret_cast(0x42424242U); EXPECT_DEATH(scudo::reportError("TEST123"), "Scudo ERROR.*TEST123"); @@ -45,7 +45,7 @@ "Scudo ERROR.*42424242.*123.*456"); } -TEST(ScudoReportTest, CSpecific) { +TEST(ScudoReportDeathTest, CSpecific) { EXPECT_DEATH(scudo::reportAlignmentNotPowerOfTwo(123), "Scudo ERROR.*123"); EXPECT_DEATH(scudo::reportCallocOverflow(123, 456), "Scudo ERROR.*123.*456"); EXPECT_DEATH(scudo::reportInvalidPosixMemalignAlignment(789), diff --git a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp --- a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp @@ -38,7 +38,7 @@ static const size_t Size = 100U; -TEST(ScudoWrappersCTest, Malloc) { +TEST(ScudoWrappersCDeathTest, Malloc) { void *P = malloc(Size); EXPECT_NE(P, nullptr); EXPECT_LE(Size, malloc_usable_size(P)); @@ -154,7 +154,7 @@ EXPECT_EQ(errno, EINVAL); } -TEST(ScudoWrappersCTest, Realloc) { +TEST(ScudoWrappersCDeathTest, Realloc) { // realloc(nullptr, N) is malloc(N) void *P = realloc(nullptr, 0U); EXPECT_NE(P, nullptr); @@ -333,7 +333,7 @@ // Fuchsia doesn't have alarm, fork or malloc_info. #if !SCUDO_FUCHSIA -TEST(ScudoWrappersCTest, MallocDisableDeadlock) { +TEST(ScudoWrappersCDeathTest, MallocDisableDeadlock) { // We expect heap operations within a disable/enable scope to deadlock. EXPECT_DEATH( { @@ -368,7 +368,7 @@ free(P2); } -TEST(ScudoWrappersCTest, Fork) { +TEST(ScudoWrappersCDeathTest, Fork) { void *P; pid_t Pid = fork(); EXPECT_GE(Pid, 0) << strerror(errno); diff --git a/compiler-rt/lib/scudo/standalone/tests/wrappers_cpp_test.cpp b/compiler-rt/lib/scudo/standalone/tests/wrappers_cpp_test.cpp --- a/compiler-rt/lib/scudo/standalone/tests/wrappers_cpp_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/wrappers_cpp_test.cpp @@ -67,7 +67,7 @@ Color C = Color::Red; }; -TEST(ScudoWrappersCppTest, New) { +TEST(ScudoWrappersCppDeathTest, New) { if (getenv("SKIP_TYPE_MISMATCH")) { printf("Skipped type mismatch tests.\n"); return;