#include "base/trace_event/memory_dump_manager.h"
#include <stdint.h>
#include <memory>
#include <string_view>
#include <utility>
#include <vector>
#include "base/allocator/buildflags.h"
#include "base/at_exit.h"
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/test/task_environment.h"
#include "base/test/test_io_thread.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread.h"
#include "base/trace_event/memory_dump_manager_test_utils.h"
#include "base/trace_event/memory_dump_provider.h"
#include "base/trace_event/memory_dump_request_args.h"
#include "base/trace_event/memory_dump_scheduler.h"
#include "base/trace_event/memory_infra_background_allowlist.h"
#include "base/trace_event/process_memory_dump.h"
#include "build/build_config.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
_;
AtMost;
Between;
Invoke;
Return;
namespace base {
namespace trace_event {
MATCHER(IsDetailedDump, "") { … }
MATCHER(IsLightDump, "") { … }
MATCHER(IsDeterministicDump, "") { … }
MATCHER(IsNotDeterministicDump, "") { … }
namespace {
constexpr char kMDPName[] = …;
constexpr char kAllowlistedMDPName[] = …;
constexpr std::string_view kTestMDPAllowlist[] = …;
void RegisterDumpProvider(
MemoryDumpProvider* mdp,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
const MemoryDumpProvider::Options& options,
const char* name = kMDPName) { … }
void RegisterDumpProvider(
MemoryDumpProvider* mdp,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) { … }
void RegisterDumpProviderWithSequencedTaskRunner(
MemoryDumpProvider* mdp,
scoped_refptr<base::SequencedTaskRunner> task_runner,
const MemoryDumpProvider::Options& options) { … }
void PostTaskAndWait(const Location& from_here,
SequencedTaskRunner* task_runner,
base::OnceClosure task) { … }
class MockMemoryDumpProvider : public MemoryDumpProvider { … };
class TestSequencedTaskRunner : public SequencedTaskRunner { … };
}
class MemoryDumpManagerTest : public testing::Test { … };
class MemoryDumpManagerTestAsCoordinator : public MemoryDumpManagerTest { … };
TEST_F(MemoryDumpManagerTest, SingleDumper) { … }
TEST_F(MemoryDumpManagerTest, CheckMemoryDumpArgs) { … }
TEST_F(MemoryDumpManagerTest, CheckMemoryDumpArgsDeterministic) { … }
TEST_F(MemoryDumpManagerTest, MultipleDumpers) { … }
#if BUILDFLAG(IS_IOS)
#define MAYBE_RegistrationConsistency …
#else
#define MAYBE_RegistrationConsistency …
#endif
TEST_F(MemoryDumpManagerTest, MAYBE_RegistrationConsistency) { … }
TEST_F(MemoryDumpManagerTest, RespectTaskRunnerAffinity) { … }
TEST_F(MemoryDumpManagerTest, PostTaskForSequencedTaskRunner) { … }
TEST_F(MemoryDumpManagerTest, DisableFailingDumpers) { … }
TEST_F(MemoryDumpManagerTest, RegisterDumperWhileDumping) { … }
TEST_F(MemoryDumpManagerTest, UnregisterDumperWhileDumping) { … }
TEST_F(MemoryDumpManagerTest, UnregisterDumperFromThreadWhileDumping) { … }
TEST_F(MemoryDumpManagerTest, TearDownThreadWhileDumping) { … }
TEST_F(MemoryDumpManagerTest, TriggerDumpWithoutTracing) { … }
TEST_F(MemoryDumpManagerTest, BackgroundAllowlisting) { … }
TEST_F(MemoryDumpManagerTest, UnregisterAndDeleteDumpProviderSoon) { … }
TEST_F(MemoryDumpManagerTest, UnregisterAndDeleteDumpProviderSoonDuringDump) { … }
class SimpleMockMemoryDumpProvider : public MemoryDumpProvider { … };
TEST_F(MemoryDumpManagerTest, NoStackOverflowWithTooManyMDPs) { … }
}
}