chromium/components/heap_profiling/multi_process/test_driver.cc

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

#include "components/heap_profiling/multi_process/test_driver.h"

#include <memory>
#include <optional>
#include <string>

#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/process/process_handle.h"
#include "base/run_loop.h"
#include "base/sampling_heap_profiler/poisson_allocation_sampler.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/threading/platform_thread.h"
#include "base/trace_event/heap_profiler.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/heap_profiling/multi_process/supervisor.h"
#include "components/services/heap_profiling/public/cpp/controller.h"
#include "components/services/heap_profiling/public/cpp/profiling_client.h"
#include "components/services/heap_profiling/public/cpp/settings.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/tracing_controller.h"
#include "partition_alloc/partition_root.h"

namespace heap_profiling {

namespace {

constexpr const char kTestCategory[] =;
const char kMallocEvent[] =;
const char kMallocTypeTag[] =;
const char kMallocVariadicTypeTag[] =;
const char kPAEvent[] =;
const char kVariadicEvent[] =;
const char kThreadName[] =;

// Make some specific allocations in Browser to do a deeper test of the
// allocation tracking.
constexpr int kMallocAllocSize =;
constexpr int kMallocAllocCount =;

constexpr int kVariadicAllocCount =;

// The sample rate should not affect the sampled allocations. Intentionally
// choose an odd number.
constexpr int kSampleRate =;

// Test fixed-size PartitionAlloc. The size must be aligned to system pointer
// size.
constexpr int kPartitionAllocSize =;
constexpr int kPartitionAllocCount =;
static const char* kPartitionAllocTypeName =;

// Ideally, we'd check to see that at least one renderer exists, and all
// renderers are being profiled, but something odd seems to be happening with
// warm-up/spare renderers.
//
// Whether at least 1 renderer exists, and at least 1 renderer is being
// profiled.
bool RenderersAreBeingProfiled(
    const std::vector<base::ProcessId>& profiled_pids) {}

// On success, populates |pid|.
int NumProcessesWithName(const base::Value::Dict& dump_json,
                         std::string name,
                         std::vector<int>* pids) {}

const base::Value::Dict* FindArgDump(base::ProcessId pid,
                                     const base::Value::Dict& dump_json,
                                     const char* arg) {}

constexpr uint64_t kNullParent =;
struct Node {};
NodeMap;

// Parses maps.types and maps.strings. Returns |true| on success.
bool ParseTypes(const base::Value::Dict* heaps_v2, NodeMap* output) {}

// |expected_size| of 0 means no expectation.
bool GetAllocatorSubarray(const base::Value::Dict* heaps_v2,
                          const char* allocator_name,
                          const char* subarray_name,
                          size_t expected_size,
                          const base::Value::List*& output) {}

bool ValidateSamplingAllocations(const base::Value::Dict* heaps_v2,
                                 const char* allocator_name,
                                 int approximate_size,
                                 int approximate_count,
                                 const char* type_name) {}

bool ValidateProcessMmaps(const base::Value::Dict* process_mmaps,
                          bool should_have_contents) {}

void HandleOOM(size_t unused_size) {}

}  // namespace

TestDriver::TestDriver()
    :{}
TestDriver::~TestDriver() {}

bool TestDriver::RunTest(const Options& options) {}

void TestDriver::GetHasStartedOnUIThread() {}

void TestDriver::CheckOrStartProfilingOnUIThreadAndSignal() {}

bool TestDriver::CheckOrStartProfilingOnUIThreadWithAsyncSignalling() {}

bool TestDriver::CheckOrStartProfilingOnUIThreadWithNestedRunLoops() {}

void TestDriver::MakeTestAllocations() {}

void TestDriver::CollectResults(bool synchronous) {}

void TestDriver::TraceFinished(base::OnceClosure closure,
                               bool success,
                               std::string trace_json) {}

bool TestDriver::ValidateBrowserAllocations(
    const base::Value::Dict& dump_json) {}

bool TestDriver::ValidateRendererAllocations(
    const base::Value::Dict& dump_json) {}

bool TestDriver::ShouldProfileBrowser() {}

bool TestDriver::ShouldProfileRenderer() {}

bool TestDriver::ShouldIncludeNativeThreadNames() {}

bool TestDriver::HasNativeFrames() {}

void TestDriver::WaitForProfilingToStartForBrowserUIThread() {}

void TestDriver::WaitForProfilingToStartForAllRenderersUIThread() {}

void TestDriver::WaitForProfilingToStartForAllRenderersUIThreadAndSignal() {}

void TestDriver::WaitForProfilingToStartForAllRenderersUIThreadCallback(
    std::vector<base::ProcessId> results) {}

}  // namespace heap_profiling