-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools,test: fix V8 initialization order
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/3300129/ PR-URL: #42657 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
- Loading branch information
1 parent
58f3fdc
commit 62e6275
Showing
3 changed files
with
47 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,39 @@ | ||
#include "node_test_fixture.h" | ||
#include "cppgc/platform.h" | ||
|
||
ArrayBufferUniquePtr NodeZeroIsolateTestFixture::allocator{nullptr, nullptr}; | ||
uv_loop_t NodeZeroIsolateTestFixture::current_loop; | ||
NodePlatformUniquePtr NodeZeroIsolateTestFixture::platform; | ||
TracingAgentUniquePtr NodeZeroIsolateTestFixture::tracing_agent; | ||
bool NodeZeroIsolateTestFixture::node_initialized = false; | ||
|
||
|
||
void NodeTestEnvironment::SetUp() { | ||
NodeZeroIsolateTestFixture::tracing_agent = | ||
std::make_unique<node::tracing::Agent>(); | ||
node::tracing::TraceEventHelper::SetAgent( | ||
NodeZeroIsolateTestFixture::tracing_agent.get()); | ||
node::tracing::TracingController* tracing_controller = | ||
NodeZeroIsolateTestFixture::tracing_agent->GetTracingController(); | ||
static constexpr int kV8ThreadPoolSize = 4; | ||
NodeZeroIsolateTestFixture::platform.reset( | ||
new node::NodePlatform(kV8ThreadPoolSize, tracing_controller)); | ||
v8::V8::InitializePlatform(NodeZeroIsolateTestFixture::platform.get()); | ||
#ifdef V8_SANDBOX | ||
ASSERT_TRUE(v8::V8::InitializeSandbox()); | ||
#endif | ||
cppgc::InitializeProcess( | ||
NodeZeroIsolateTestFixture::platform->GetPageAllocator()); | ||
v8::V8::Initialize(); | ||
} | ||
|
||
void NodeTestEnvironment::TearDown() { | ||
v8::V8::Dispose(); | ||
v8::V8::DisposePlatform(); | ||
NodeZeroIsolateTestFixture::platform->Shutdown(); | ||
NodeZeroIsolateTestFixture::platform.reset(nullptr); | ||
NodeZeroIsolateTestFixture::tracing_agent.reset(nullptr); | ||
} | ||
|
||
::testing::Environment* const node_env = | ||
::testing::AddGlobalTestEnvironment(new NodeTestEnvironment()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters