#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/gwp_asan/client/sampling_partitionalloc_shims.h"
#include <stdlib.h>
#include <algorithm>
#include <iterator>
#include <set>
#include <string>
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/memory/page_size.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/gtest_util.h"
#include "base/test/multiprocess_test.h"
#include "base/test/test_timeouts.h"
#include "build/build_config.h"
#include "components/crash/core/common/crash_key.h"
#include "components/gwp_asan/client/guarded_page_allocator.h"
#include "components/gwp_asan/client/gwp_asan.h"
#include "components/gwp_asan/common/crash_key_name.h"
#include "partition_alloc/partition_alloc.h"
#include "partition_alloc/partition_root.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"
#if !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
namespace gwp_asan {
namespace internal {
extern GuardedPageAllocator& GetPartitionAllocGpaForTesting();
namespace {
constexpr const char* kFakeType = …;
constexpr const char* kFakeType2 = …;
constexpr size_t kSamplingFrequency = …;
constexpr size_t kLoopIterations = …;
constexpr int kSuccess = …;
constexpr int kFailure = …;
constexpr partition_alloc::PartitionOptions kAllocatorOptions = …;
static void HandleOOM(size_t unused_size) { … }
class SamplingPartitionAllocShimsTest : public base::MultiProcessTest { … };
MULTIPROCESS_TEST_MAIN_WITH_SETUP(
BasicFunctionality,
SamplingPartitionAllocShimsTest::multiprocessTestSetup) { … }
TEST_F(SamplingPartitionAllocShimsTest, BasicFunctionality) { … }
MULTIPROCESS_TEST_MAIN_WITH_SETUP(
Realloc,
SamplingPartitionAllocShimsTest::multiprocessTestSetup) { … }
TEST_F(SamplingPartitionAllocShimsTest, Realloc) { … }
MULTIPROCESS_TEST_MAIN_WITH_SETUP(
DifferentTypesDontOverlap,
SamplingPartitionAllocShimsTest::multiprocessTestSetup) { … }
TEST_F(SamplingPartitionAllocShimsTest, DifferentTypesDontOverlap) { … }
#if !defined(COMPONENT_BUILD)
MULTIPROCESS_TEST_MAIN_WITH_SETUP(
CrashKey,
SamplingPartitionAllocShimsTest::multiprocessTestSetup) {
if (crash_reporter::GetCrashKeyValue(kPartitionAllocCrashKey) !=
GetPartitionAllocGpaForTesting().GetCrashKey()) {
return kFailure;
}
return kSuccess;
}
TEST_F(SamplingPartitionAllocShimsTest, CrashKey) {
runTest("CrashKey");
}
#endif
}
}
}
#endif