#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "base/test/test_suite.h"
#include <signal.h>
#include <algorithm>
#include <memory>
#include <string>
#include <string_view>
#include <vector>
#include "base/at_exit.h"
#include "base/base_paths.h"
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/debug/asan_service.h"
#include "base/debug/debugger.h"
#include "base/debug/profiler.h"
#include "base/debug/stack_trace.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/i18n/icu_util.h"
#include "base/i18n/rtl.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/statistics_recorder.h"
#include "base/no_destructor.h"
#include "base/path_service.h"
#include "base/process/launch.h"
#include "base/process/memory.h"
#include "base/process/process.h"
#include "base/process/process_handle.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/test/fuzztest_init_helper.h"
#include "base/test/gtest_xml_unittest_result_printer.h"
#include "base/test/gtest_xml_util.h"
#include "base/test/icu_test_util.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/mock_entropy_provider.h"
#include "base/test/multiprocess_test.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/scoped_run_loop_timeout.h"
#include "base/test/test_suite_helper.h"
#include "base/test/test_switches.h"
#include "base/test/test_timeouts.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "base/tracing_buildflags.h"
#include "build/build_config.h"
#include "partition_alloc/buildflags.h"
#include "partition_alloc/tagging.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"
#if BUILDFLAG(IS_APPLE)
#include "base/apple/scoped_nsautorelease_pool.h"
#endif
#if BUILDFLAG(IS_IOS)
#include "base/test/test_listener_ios.h"
#include "base/test/test_support_ios.h"
#else
#include "base/strings/string_util.h"
#include "third_party/icu/source/common/unicode/uloc.h"
#endif
#if BUILDFLAG(IS_ANDROID)
#include "base/test/test_support_android.h"
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include "third_party/test_fonts/fontconfig/fontconfig_util_linux.h"
#endif
#if BUILDFLAG(IS_FUCHSIA)
#include "base/fuchsia/system_info.h"
#endif
#if BUILDFLAG(IS_WIN)
#if defined(_DEBUG)
#include <crtdbg.h>
#endif
#include <windows.h>
#include "base/debug/handle_hooks_win.h"
#endif
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
#include "base/allocator/partition_alloc_support.h"
#endif
#if GTEST_HAS_DEATH_TEST
#include "base/gtest_prod_util.h"
#endif
namespace base {
namespace {
bool IsMarkedMaybe(const testing::TestInfo& test) { … }
class DisableMaybeTests : public testing::EmptyTestEventListener { … };
class ResetCommandLineBetweenTests : public testing::EmptyTestEventListener { … };
class FeatureListScopedToEachTest : public testing::EmptyTestEventListener { … };
class CheckForLeakedGlobals : public testing::EmptyTestEventListener { … };
#if !BUILDFLAG(IS_APPLE)
class CheckProcessPriority : public testing::EmptyTestEventListener { … };
#endif
const std::string& GetProfileName() { … }
void InitializeLogging() { … }
#if BUILDFLAG(IS_WIN)
void InvalidParameter(const wchar_t* expression,
const wchar_t* function,
const wchar_t* file,
unsigned int line,
uintptr_t reserved) {
__debugbreak();
_exit(1);
}
void PureCall() {
fprintf(stderr, "Pure-virtual function call. Terminating.\n");
__debugbreak();
_exit(1);
}
void AbortHandler(int signal) {
fprintf(stderr, "\n");
__debugbreak();
}
#endif
#if GTEST_HAS_DEATH_TEST
std::string GetStackTraceMessage() { … }
#endif
}
int RunUnitTestsUsingBaseTestSuite(int argc, char** argv) { … }
TestSuite::TestSuite(int argc, char** argv) : … { … }
#if BUILDFLAG(IS_WIN)
TestSuite::TestSuite(int argc, wchar_t** argv) : argc_(argc) {
argv_as_strings_.reserve(argc);
argv_as_pointers_.reserve(argc + 1);
std::for_each(argv, argv + argc, [this](wchar_t* arg) {
argv_as_strings_.push_back(WideToUTF8(arg));
argv_as_pointers_.push_back(argv_as_strings_.back().data());
});
argv_as_pointers_.push_back(nullptr);
argv_ = argv_as_pointers_.data();
PreInitialize();
}
#endif
TestSuite::~TestSuite() { … }
int TestSuite::Run() { … }
void TestSuite::DisableCheckForThreadAndProcessPriority() { … }
void TestSuite::DisableCheckForLeakedGlobals() { … }
void TestSuite::UnitTestAssertHandler(const char* file,
int line,
const std::string_view summary,
const std::string_view stack_trace) { … }
void TestSuite::SuppressErrorDialogs() { … }
void TestSuite::Initialize() { … }
void TestSuite::InitializeFromCommandLine(int* argc, char** argv) { … }
int TestSuite::RunAllTests() { … }
void TestSuite::Shutdown() { … }
void TestSuite::PreInitialize() { … }
void TestSuite::AddTestLauncherResultPrinter() { … }
}