Chromium Code Reviews| Index: Source/wtf/PartitionAllocTest.cpp |
| diff --git a/Source/wtf/PartitionAllocTest.cpp b/Source/wtf/PartitionAllocTest.cpp |
| index 4ef8ef58390b623fd272f869d0dc60269b278cba..7adc14a566f339f2e3d63fd5062b2d0f94f0a692 100644 |
| --- a/Source/wtf/PartitionAllocTest.cpp |
| +++ b/Source/wtf/PartitionAllocTest.cpp |
| @@ -55,7 +55,7 @@ static SizeSpecificPartitionAllocator<kTestMaxAllocation> allocator; |
| static PartitionAllocatorGeneric genericAllocator; |
| static const size_t kTestAllocSize = 16; |
| -#ifdef NDEBUG |
| +#if !ENABLE(ASSERT) |
| static const size_t kPointerOffset = 0; |
| static const size_t kExtraAllocSize = 0; |
| #else |
| @@ -454,7 +454,7 @@ TEST(PartitionAllocTest, GenericAlloc) |
| // Check that the realloc copied correctly. |
| char* newCharPtr = static_cast<char*>(newPtr); |
| EXPECT_EQ(*newCharPtr, 'A'); |
| -#ifndef NDEBUG |
| +#if ENABLE(ASSERT) |
| // Subtle: this checks for an old bug where we copied too much from the |
| // source of the realloc. The condition can be detected by a trashing of |
| // the uninitialized value in the space of the upsized allocation. |
| @@ -557,13 +557,14 @@ TEST(PartitionAllocTest, GenericAllocSizes) |
| EXPECT_EQ(ptr3, newPtr); |
| newPtr = partitionAllocGeneric(genericAllocator.root(), size); |
| EXPECT_EQ(ptr2, newPtr); |
| -#if OS(LINUX) && defined(NDEBUG) |
| +#if OS(LINUX) && !ENABLE(ASSERT) |
| // On Linux, we have a guarantee that freelisting a page should cause its |
| // contents to be nulled out. We check for null here to detect an bug we |
| // had where a large slot size was causing us to not properly free all |
| // resources back to the system. |
| - // We only run the check in optimized builds because the debug build |
| - // writes over the allocated area with an "uninitialized" byte pattern. |
| + // We only run the check when asserts are disabled because when they are |
| + // enabled, the allocated area is overwritten with an "uninitialized" |
| + // byte pattern. |
|
Ken Russell (switch to Gerrit)
2014/07/15 23:25:35
Updated this comment. Ran wtf_unittests in Release
|
| EXPECT_EQ(0, *(reinterpret_cast<char*>(newPtr) + (size - 1))); |
| #endif |
| partitionFreeGeneric(genericAllocator.root(), newPtr); |
| @@ -681,7 +682,7 @@ TEST(PartitionAllocTest, Realloc) |
| char* charPtr2 = static_cast<char*>(ptr2); |
| EXPECT_EQ('A', charPtr2[0]); |
| EXPECT_EQ('A', charPtr2[size - 1]); |
| -#ifndef NDEBUG |
| +#if ENABLE(ASSERT) |
| EXPECT_EQ(WTF::kUninitializedByte, static_cast<unsigned char>(charPtr2[size])); |
| #endif |
| @@ -692,7 +693,7 @@ TEST(PartitionAllocTest, Realloc) |
| char* charPtr = static_cast<char*>(ptr); |
| EXPECT_EQ('A', charPtr[0]); |
| EXPECT_EQ('A', charPtr[size - 2]); |
| -#ifndef NDEBUG |
| +#if ENABLE(ASSERT) |
| EXPECT_EQ(WTF::kUninitializedByte, static_cast<unsigned char>(charPtr[size - 1])); |
| #endif |