2014-10-10 14:49:02 +04:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-10-10 11:10:43 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2021-03-12 08:24:20 +01:00
|
|
|
#include "include/cppgc/platform.h"
|
2014-10-10 14:49:02 +04:00
|
|
|
#include "include/libplatform/libplatform.h"
|
2021-10-10 11:10:43 +02:00
|
|
|
#include "include/v8-initialization.h"
|
2014-10-10 14:49:02 +04:00
|
|
|
#include "src/base/compiler-specific.h"
|
2022-04-19 09:00:36 +02:00
|
|
|
#include "src/base/page-allocator.h"
|
2014-10-10 14:49:02 +04:00
|
|
|
#include "testing/gmock/include/gmock/gmock.h"
|
|
|
|
|
2024-04-18 07:06:43 +02:00
|
|
|
#ifdef V8_ENABLE_FUZZTEST
|
|
|
|
#include "test/unittests/fuzztest-init-adapter.h"
|
|
|
|
#endif // V8_ENABLE_FUZZTEST
|
|
|
|
|
2022-09-21 13:28:42 +02:00
|
|
|
#ifdef V8_USE_PERFETTO
|
|
|
|
#include "src/tracing/trace-event.h"
|
|
|
|
#endif // V8_USE_PERFETTO
|
|
|
|
|
2014-10-10 14:49:02 +04:00
|
|
|
namespace {
|
|
|
|
|
2022-04-19 09:00:36 +02:00
|
|
|
class CppGCEnvironment final : public ::testing::Environment {
|
2014-10-10 14:49:02 +04:00
|
|
|
public:
|
2016-01-20 09:45:45 -08:00
|
|
|
void SetUp() override {
|
2022-04-19 09:00:36 +02:00
|
|
|
// Initialize the process for cppgc with an arbitrary page allocator. This
|
|
|
|
// has to survive as long as the process, so it's ok to leak the allocator
|
|
|
|
// here.
|
|
|
|
cppgc::InitializeProcess(new v8::base::PageAllocator());
|
2022-09-21 13:28:42 +02:00
|
|
|
|
|
|
|
#ifdef V8_USE_PERFETTO
|
|
|
|
// Set up the in-process perfetto backend.
|
|
|
|
perfetto::TracingInitArgs init_args;
|
|
|
|
init_args.backends = perfetto::BackendType::kInProcessBackend;
|
|
|
|
perfetto::Tracing::Initialize(init_args);
|
|
|
|
#endif // V8_USE_PERFETTO
|
2014-10-10 14:49:02 +04:00
|
|
|
}
|
|
|
|
|
2022-04-19 09:00:36 +02:00
|
|
|
void TearDown() override { cppgc::ShutdownProcess(); }
|
2014-10-10 14:49:02 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
2017-03-21 10:16:54 +01:00
|
|
|
// Don't catch SEH exceptions and continue as the following tests might hang
|
|
|
|
// in an broken environment on windows.
|
2024-03-30 09:54:35 +01:00
|
|
|
GTEST_FLAG_SET(catch_exceptions, false);
|
2020-03-05 10:49:19 -08:00
|
|
|
|
|
|
|
// Most V8 unit-tests are multi-threaded, so enable thread-safe death-tests.
|
2024-03-30 09:54:35 +01:00
|
|
|
GTEST_FLAG_SET(death_test_style, "threadsafe");
|
2020-03-05 10:49:19 -08:00
|
|
|
|
2014-10-10 14:49:02 +04:00
|
|
|
testing::InitGoogleMock(&argc, argv);
|
2022-04-19 09:00:36 +02:00
|
|
|
testing::AddGlobalTestEnvironment(new CppGCEnvironment);
|
2014-10-10 14:49:02 +04:00
|
|
|
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
|
2015-08-31 17:10:53 -07:00
|
|
|
v8::V8::InitializeExternalStartupData(argv[0]);
|
2019-08-01 08:38:30 +02:00
|
|
|
v8::V8::InitializeICUDefaultLocation(argv[0]);
|
2024-04-18 07:06:43 +02:00
|
|
|
|
|
|
|
#ifdef V8_ENABLE_FUZZTEST
|
|
|
|
absl::ParseCommandLine(argc, argv);
|
|
|
|
fuzztest::InitFuzzTest(&argc, &argv);
|
|
|
|
#endif // V8_ENABLE_FUZZTEST
|
|
|
|
|
2014-10-10 14:49:02 +04:00
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|