typedef DefaultSizeClassMap SCMap;
typedef
- SizeClassAllocator64<kAllocatorSpace, kAllocatorSize, 16, SCMap> Allocator;
-typedef SizeClassAllocatorLocalCache<Allocator::kNumClasses, Allocator>
- AllocatorCache;
+ SizeClassAllocator64<kAllocatorSpace, kAllocatorSize, 16, SCMap> Allocator64;
template <class SizeClassMap>
void TestSizeClassMap() {
TestSizeClassMap<CompactSizeClassMap>();
}
-TEST(SanitizerCommon, SizeClassAllocator64) {
+template <class Allocator>
+void TestSizeClassAllocator() {
Allocator a;
a.Init();
a.TestOnlyUnmap();
}
+TEST(SanitizerCommon, SizeClassAllocator64) {
+ TestSizeClassAllocator<Allocator64>();
+}
-TEST(SanitizerCommon, SizeClassAllocator64MetadataStress) {
+template <class Allocator>
+void SizeClassAllocator64MetadataStress() {
Allocator a;
a.Init();
static volatile void *sink;
(void)sink;
}
+TEST(SanitizerCommon, SizeClassAllocator64MetadataStress) {
+ SizeClassAllocator64MetadataStress<Allocator64>();
+}
+
+template<class Allocator>
void FailInAssertionOnOOM() {
Allocator a;
a.Init();
}
TEST(SanitizerCommon, SizeClassAllocator64Overflow) {
- EXPECT_DEATH(FailInAssertionOnOOM(),
- "Out of memory");
+ EXPECT_DEATH(FailInAssertionOnOOM<Allocator64>(), "Out of memory");
}
TEST(SanitizerCommon, LargeMmapAllocator) {
}
}
-TEST(SanitizerCommon, CombinedAllocator) {
- typedef Allocator PrimaryAllocator;
- typedef LargeMmapAllocator SecondaryAllocator;
- typedef CombinedAllocator<PrimaryAllocator, AllocatorCache,
- SecondaryAllocator> Allocator;
+template
+<class PrimaryAllocator, class SecondaryAllocator, class AllocatorCache>
+void TestCombinedAllocator() {
+ CombinedAllocator<PrimaryAllocator, AllocatorCache, SecondaryAllocator> a;
+ a.Init();
AllocatorCache cache;
- Allocator a;
- a.Init();
cache.Init();
EXPECT_EQ(a.Allocate(&cache, -1, 1), (void*)0);
a.TestOnlyUnmap();
}
-static THREADLOCAL AllocatorCache static_allocator_cache;
-TEST(SanitizerCommon, SizeClassAllocatorLocalCache) {
- static_allocator_cache.Init();
+TEST(SanitizerCommon, CombinedAllocator) {
+ TestCombinedAllocator<Allocator64,
+ LargeMmapAllocator,
+ SizeClassAllocatorLocalCache<Allocator64::kNumClasses, Allocator64> > ();
+}
- Allocator a;
+template <class AllocatorCache>
+void TestSizeClassAllocatorLocalCache() {
+ static THREADLOCAL AllocatorCache static_allocator_cache;
+ static_allocator_cache.Init();
AllocatorCache cache;
+ typename AllocatorCache::Allocator a;
a.Init();
cache.Init();
a.TestOnlyUnmap();
}
+
+TEST(SanitizerCommon, SizeClassAllocator64LocalCache) {
+ typedef SizeClassAllocatorLocalCache<Allocator64::kNumClasses, Allocator64>
+ AllocatorCache;
+ TestSizeClassAllocatorLocalCache<AllocatorCache> ();
+}