~TestAllocator() { this->unmapTestOnly(); }
};
-SCUDO_DEFINE_GTEST_TYPE_NAME(scudo::AndroidSvelteConfig)
-#if SCUDO_FUCHSIA
-SCUDO_DEFINE_GTEST_TYPE_NAME(scudo::FuchsiaConfig)
-#else
-SCUDO_DEFINE_GTEST_TYPE_NAME(scudo::DefaultConfig)
-SCUDO_DEFINE_GTEST_TYPE_NAME(scudo::AndroidConfig)
-#endif
-
-template <class Config> struct ScudoCombinedTest : public ::testing::Test {
+template <class TypeParam> struct ScudoCombinedTest : public Test {
ScudoCombinedTest() {
- UseQuarantine = std::is_same<Config, scudo::AndroidConfig>::value;
+ UseQuarantine = std::is_same<TypeParam, scudo::AndroidConfig>::value;
Allocator = std::make_unique<AllocatorT>();
}
~ScudoCombinedTest() {
UseQuarantine = true;
}
+ void RunTest();
+
void BasicTest(scudo::uptr SizeLogMin, scudo::uptr SizeLogMax);
- using AllocatorT = TestAllocator<Config>;
+ using AllocatorT = TestAllocator<TypeParam>;
std::unique_ptr<AllocatorT> Allocator;
};
-using ScudoCombinedTestTypes = testing::Types<scudo::AndroidSvelteConfig,
#if SCUDO_FUCHSIA
- scudo::FuchsiaConfig,
+#define SCUDO_TYPED_TEST_ALL_TYPES(FIXTURE, NAME) \
+ SCUDO_TYPED_TEST_TYPE(FIXTURE, NAME, AndroidSvelteConfig) \
+ SCUDO_TYPED_TEST_TYPE(FIXTURE, NAME, FuchsiaConfig)
#else
- scudo::DefaultConfig,
- scudo::AndroidConfig
+#define SCUDO_TYPED_TEST_ALL_TYPES(FIXTURE, NAME) \
+ SCUDO_TYPED_TEST_TYPE(FIXTURE, NAME, AndroidSvelteConfig) \
+ SCUDO_TYPED_TEST_TYPE(FIXTURE, NAME, DefaultConfig) \
+ SCUDO_TYPED_TEST_TYPE(FIXTURE, NAME, AndroidConfig)
#endif
- >;
-TYPED_TEST_CASE(ScudoCombinedTest, ScudoCombinedTestTypes);
-TYPED_TEST(ScudoCombinedTest, IsOwned) {
+#define SCUDO_TYPED_TEST_TYPE(FIXTURE, NAME, TYPE) \
+ using FIXTURE##NAME##_##TYPE = FIXTURE##NAME<scudo::TYPE>; \
+ TEST_F(FIXTURE##NAME##_##TYPE, NAME) { Run(); }
+
+#define SCUDO_TYPED_TEST(FIXTURE, NAME) \
+ template <class TypeParam> \
+ struct FIXTURE##NAME : public FIXTURE<TypeParam> { \
+ void Run(); \
+ }; \
+ SCUDO_TYPED_TEST_ALL_TYPES(FIXTURE, NAME) \
+ template <class TypeParam> void FIXTURE##NAME<TypeParam>::Run()
+
+SCUDO_TYPED_TEST(ScudoCombinedTest, IsOwned) {
auto *Allocator = this->Allocator.get();
static scudo::u8 StaticBuffer[scudo::Chunk::getHeaderSize() + 1];
EXPECT_FALSE(
}
}
-TYPED_TEST(ScudoCombinedTest, BasicCombined0) { this->BasicTest(0, 16); }
-TYPED_TEST(ScudoCombinedTest, BasicCombined1) { this->BasicTest(17, 18); }
-TYPED_TEST(ScudoCombinedTest, BasicCombined2) { this->BasicTest(19, 19); }
-TYPED_TEST(ScudoCombinedTest, BasicCombined3) { this->BasicTest(20, 20); }
+SCUDO_TYPED_TEST(ScudoCombinedTest, BasicCombined0) { this->BasicTest(0, 16); }
+SCUDO_TYPED_TEST(ScudoCombinedTest, BasicCombined1) { this->BasicTest(17, 18); }
+SCUDO_TYPED_TEST(ScudoCombinedTest, BasicCombined2) { this->BasicTest(19, 19); }
+SCUDO_TYPED_TEST(ScudoCombinedTest, BasicCombined3) { this->BasicTest(20, 20); }
-TYPED_TEST(ScudoCombinedTest, ZeroContents) {
+SCUDO_TYPED_TEST(ScudoCombinedTest, ZeroContents) {
auto *Allocator = this->Allocator.get();
// Ensure that specifying ZeroContents returns a zero'd out block.
}
}
-TYPED_TEST(ScudoCombinedTest, ZeroFill) {
+SCUDO_TYPED_TEST(ScudoCombinedTest, ZeroFill) {
auto *Allocator = this->Allocator.get();
// Ensure that specifying ZeroContents returns a zero'd out block.
}
}
-TYPED_TEST(ScudoCombinedTest, PatternOrZeroFill) {
+SCUDO_TYPED_TEST(ScudoCombinedTest, PatternOrZeroFill) {
auto *Allocator = this->Allocator.get();
// Ensure that specifying PatternOrZeroFill returns a pattern or zero filled
}
}
-TYPED_TEST(ScudoCombinedTest, BlockReuse) {
+SCUDO_TYPED_TEST(ScudoCombinedTest, BlockReuse) {
auto *Allocator = this->Allocator.get();
// Verify that a chunk will end up being reused, at some point.
EXPECT_TRUE(Found);
}
-TYPED_TEST(ScudoCombinedTest, ReallocateLarge) {
+SCUDO_TYPED_TEST(ScudoCombinedTest, ReallocateLarge) {
auto *Allocator = this->Allocator.get();
// Reallocate a large chunk all the way down to a byte, verifying that we
Allocator->deallocate(P, Origin);
}
-TYPED_TEST(ScudoCombinedTest, ReallocateSame) {
+SCUDO_TYPED_TEST(ScudoCombinedTest, ReallocateSame) {
auto *Allocator = this->Allocator.get();
// Check that reallocating a chunk to a slightly smaller or larger size
Allocator->deallocate(P, Origin);
}
-TYPED_TEST(ScudoCombinedTest, IterateOverChunks) {
+SCUDO_TYPED_TEST(ScudoCombinedTest, IterateOverChunks) {
auto *Allocator = this->Allocator.get();
// Allocates a bunch of chunks, then iterate over all the chunks, ensuring
// they are the ones we allocated. This requires the allocator to not have any
}
}
-TYPED_TEST(ScudoCombinedTest, UseAfterFree) {
+SCUDO_TYPED_TEST(ScudoCombinedTest, UseAfterFree) {
auto *Allocator = this->Allocator.get();
// Check that use-after-free is detected.
}
}
-TYPED_TEST(ScudoCombinedTest, DisableMemoryTagging) {
+SCUDO_TYPED_TEST(ScudoCombinedTest, DisableMemoryTagging) {
auto *Allocator = this->Allocator.get();
if (Allocator->useMemoryTaggingTestOnly()) {
}
}
-TYPED_TEST(ScudoCombinedTest, Stats) {
+SCUDO_TYPED_TEST(ScudoCombinedTest, Stats) {
auto *Allocator = this->Allocator.get();
scudo::uptr BufferSize = 8192;
EXPECT_NE(Stats.find("Stats: Quarantine"), std::string::npos);
}
-TYPED_TEST(ScudoCombinedTest, CacheDrain) {
+SCUDO_TYPED_TEST(ScudoCombinedTest, CacheDrain) {
auto *Allocator = this->Allocator.get();
std::vector<void *> V;
TSD->unlock();
}
-TYPED_TEST(ScudoCombinedTest, ThreadedCombined) {
+SCUDO_TYPED_TEST(ScudoCombinedTest, ThreadedCombined) {
std::mutex Mutex;
std::condition_variable Cv;
bool Ready = false;
~TestAllocator() { this->unmapTestOnly(); }
};
-SCUDO_DEFINE_GTEST_TYPE_NAME(TestConfig1)
-SCUDO_DEFINE_GTEST_TYPE_NAME(TestConfig2)
-SCUDO_DEFINE_GTEST_TYPE_NAME(TestConfig3)
+template <class BaseConfig> struct ScudoPrimaryTest : public Test {};
-template <class BaseConfig> struct ScudoPrimaryTest : public ::testing::Test {};
-
-using ScudoPrimaryTestTypes = testing::Types<
-#if !SCUDO_FUCHSIA
- TestConfig1,
+#if SCUDO_FUCHSIA
+#define SCUDO_TYPED_TEST_ALL_TYPES(FIXTURE, NAME) \
+ SCUDO_TYPED_TEST_TYPE(FIXTURE, NAME, TestConfig2) \
+ SCUDO_TYPED_TEST_TYPE(FIXTURE, NAME, TestConfig3)
+#else
+#define SCUDO_TYPED_TEST_ALL_TYPES(FIXTURE, NAME) \
+ SCUDO_TYPED_TEST_TYPE(FIXTURE, NAME, TestConfig1) \
+ SCUDO_TYPED_TEST_TYPE(FIXTURE, NAME, TestConfig2) \
+ SCUDO_TYPED_TEST_TYPE(FIXTURE, NAME, TestConfig3)
#endif
- TestConfig2, TestConfig3>;
-TYPED_TEST_CASE(ScudoPrimaryTest, ScudoPrimaryTestTypes);
-TYPED_TEST(ScudoPrimaryTest, BasicPrimary) {
+#define SCUDO_TYPED_TEST_TYPE(FIXTURE, NAME, TYPE) \
+ using FIXTURE##NAME##_##TYPE = FIXTURE##NAME<TYPE>; \
+ TEST_F(FIXTURE##NAME##_##TYPE, NAME) { Run(); }
+
+#define SCUDO_TYPED_TEST(FIXTURE, NAME) \
+ template <class TypeParam> \
+ struct FIXTURE##NAME : public FIXTURE<TypeParam> { \
+ void Run(); \
+ }; \
+ SCUDO_TYPED_TEST_ALL_TYPES(FIXTURE, NAME) \
+ template <class TypeParam> void FIXTURE##NAME<TypeParam>::Run()
+
+SCUDO_TYPED_TEST(ScudoPrimaryTest, BasicPrimary) {
using Primary = TestAllocator<TypeParam, scudo::DefaultSizeClassMap>;
std::unique_ptr<Primary> Allocator(new Primary);
Allocator->init(/*ReleaseToOsInterval=*/-1);
Allocator.unmapTestOnly();
}
-TYPED_TEST(ScudoPrimaryTest, PrimaryIterate) {
+SCUDO_TYPED_TEST(ScudoPrimaryTest, PrimaryIterate) {
using Primary = TestAllocator<TypeParam, scudo::DefaultSizeClassMap>;
std::unique_ptr<Primary> Allocator(new Primary);
Allocator->init(/*ReleaseToOsInterval=*/-1);
Str.output();
}
-TYPED_TEST(ScudoPrimaryTest, PrimaryThreaded) {
+SCUDO_TYPED_TEST(ScudoPrimaryTest, PrimaryThreaded) {
using Primary = TestAllocator<TypeParam, scudo::SvelteSizeClassMap>;
std::unique_ptr<Primary> Allocator(new Primary);
Allocator->init(/*ReleaseToOsInterval=*/-1);
// Through a simple allocation that spans two pages, verify that releaseToOS
// actually releases some bytes (at least one page worth). This is a regression
// test for an error in how the release criteria were computed.
-TYPED_TEST(ScudoPrimaryTest, ReleaseToOS) {
+SCUDO_TYPED_TEST(ScudoPrimaryTest, ReleaseToOS) {
using Primary = TestAllocator<TypeParam, scudo::DefaultSizeClassMap>;
std::unique_ptr<Primary> Allocator(new Primary);
Allocator->init(/*ReleaseToOsInterval=*/-1);