Commit d15aaeba authored by Bartek Nowierski's avatar Bartek Nowierski Committed by Commit Bot

Make unittests work with PA-Everywhere&tags enabled

Bug: 1092288
Change-Id: Icd10cab67ac970d4569049ccaaf63bcc69b781ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2281769Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Bartek Nowierski <bartekn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#785273}
parent cc1ef8b3
...@@ -130,7 +130,7 @@ namespace base { ...@@ -130,7 +130,7 @@ namespace base {
namespace internal { namespace internal {
const size_t kTestAllocSize = 16; const size_t kTestAllocSize = 16;
#if !DCHECK_IS_ON() #if !DCHECK_IS_ON() || BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
const size_t kPointerOffset = kPartitionTagSize; const size_t kPointerOffset = kPartitionTagSize;
const size_t kExtraAllocSize = kPartitionTagSize; const size_t kExtraAllocSize = kPartitionTagSize;
#else #else
...@@ -919,8 +919,11 @@ TEST_F(PartitionAllocTest, GenericAllocGetSizeAndOffset) { ...@@ -919,8 +919,11 @@ TEST_F(PartitionAllocTest, GenericAllocGetSizeAndOffset) {
#if defined(ARCH_CPU_64_BITS) && !defined(OS_NACL) #if defined(ARCH_CPU_64_BITS) && !defined(OS_NACL)
TEST_F(PartitionAllocTest, GetOffsetMultiplePages) { TEST_F(PartitionAllocTest, GetOffsetMultiplePages) {
size_t size = 48 - kExtraAllocSize; const size_t real_size = 80;
size_t real_size = size + kExtraAllocSize; const size_t requested_size = real_size - kExtraAllocSize;
// Double check we don't end up with 0 or negative size.
EXPECT_GT(requested_size, 0u);
EXPECT_LE(requested_size, real_size);
PartitionBucket<ThreadSafe>* bucket = PartitionBucket<ThreadSafe>* bucket =
allocator.root()->SizeToBucket(real_size); allocator.root()->SizeToBucket(real_size);
// Make sure the test is testing multiple partition pages case. // Make sure the test is testing multiple partition pages case.
...@@ -930,12 +933,12 @@ TEST_F(PartitionAllocTest, GetOffsetMultiplePages) { ...@@ -930,12 +933,12 @@ TEST_F(PartitionAllocTest, GetOffsetMultiplePages) {
(bucket->num_system_pages_per_slot_span * kSystemPageSize) / real_size; (bucket->num_system_pages_per_slot_span * kSystemPageSize) / real_size;
std::vector<void*> ptrs; std::vector<void*> ptrs;
for (size_t i = 0; i < num_slots; ++i) { for (size_t i = 0; i < num_slots; ++i) {
ptrs.push_back(allocator.root()->Alloc(size, type_name)); ptrs.push_back(allocator.root()->Alloc(requested_size, type_name));
} }
for (size_t i = 0; i < num_slots; ++i) { for (size_t i = 0; i < num_slots; ++i) {
char* ptr = static_cast<char*>(ptrs[i]); char* ptr = static_cast<char*>(ptrs[i]);
for (size_t offset = 0; offset < size; offset += 13) { for (size_t offset = 0; offset < requested_size; offset += 13) {
EXPECT_EQ(PartitionAllocGetSize<ThreadSafe>(ptr), size); EXPECT_EQ(PartitionAllocGetSize<ThreadSafe>(ptr), requested_size);
EXPECT_EQ(PartitionAllocGetSlotOffset<ThreadSafe>(ptr + offset), offset); EXPECT_EQ(PartitionAllocGetSlotOffset<ThreadSafe>(ptr + offset), offset);
// TODO(bartekn): Remove when CheckedPtr2Impl no longer calls mismatched // TODO(bartekn): Remove when CheckedPtr2Impl no longer calls mismatched
// vartiant. // vartiant.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment