chromium/components/gwp_asan/client/guarded_page_allocator_unittest.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/gwp_asan/client/guarded_page_allocator.h"

#include <algorithm>
#include <array>
#include <set>
#include <utility>
#include <vector>

#include "base/allocator/buildflags.h"
#include "base/bits.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/page_size.h"
#include "base/memory/raw_ptr.h"
#include "base/test/bind.h"
#include "base/test/gtest_util.h"
#include "base/threading/simple_thread.h"
#include "build/build_config.h"
#include "components/gwp_asan/client/gwp_asan.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace gwp_asan {
namespace internal {

static constexpr size_t kMaxMetadata =;
static constexpr size_t kMaxSlots =;

class BaseGpaTest : public testing::Test {};

class GuardedPageAllocatorTest : public BaseGpaTest,
                                 public testing::WithParamInterface<bool> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(GuardedPageAllocatorTest, SingleAllocDealloc) {}

TEST_P(GuardedPageAllocatorTest, CrashOnBadDeallocPointer) {}

TEST_P(GuardedPageAllocatorTest, PointerIsMine) {}

TEST_P(GuardedPageAllocatorTest, GetRequestedSize) {}

TEST_P(GuardedPageAllocatorTest, LeftAlignedAllocation) {}

TEST_P(GuardedPageAllocatorTest, RightAlignedAllocation) {}

TEST_P(GuardedPageAllocatorTest, AllocationAlignment) {}

TEST_P(GuardedPageAllocatorTest, OutOfMemoryCallback) {}

class GuardedPageAllocatorParamTest
    : public BaseGpaTest,
      public testing::WithParamInterface<size_t> {};

TEST_P(GuardedPageAllocatorParamTest, AllocDeallocAllPages) {}
INSTANTIATE_TEST_SUITE_P();

class ThreadedAllocCountDelegate : public base::DelegateSimpleThread::Delegate {};

// Test that no pages are double-allocated or left unallocated, and that no
// extra pages are allocated when there's concurrent calls to Allocate().
TEST_P(GuardedPageAllocatorTest, ThreadedAllocCount) {}

class ThreadedHighContentionDelegate
    : public base::DelegateSimpleThread::Delegate {};

// Test that allocator remains in consistent state under high contention and
// doesn't double-allocate pages or fail to deallocate pages.
TEST_P(GuardedPageAllocatorTest, ThreadedHighContention) {}

class GuardedPageAllocatorPartitionAllocTest : public BaseGpaTest {};

TEST_F(GuardedPageAllocatorPartitionAllocTest,
       DifferentPartitionsNeverOverlap) {}

#if BUILDFLAG(USE_PARTITION_ALLOC_AS_GWP_ASAN_STORE)
constexpr size_t kSmallMaxSlots =;
class GuardedPageAllocatorRawPtrTest : public BaseGpaTest {};

TEST_F(GuardedPageAllocatorRawPtrTest, DeferDeallocation) {}
#endif  // BUILDFLAG(USE_PARTITION_ALLOC_AS_GWP_ASAN_STORE)

}  // namespace internal
}  // namespace gwp_asan