Skip to content

Commit 6c906aa

Browse files
committed
move test case wasm_handle and plugin_handle to proper scope
Previously, the test was creating a new wasm_handle and plugin_handle for each request, which led to the WasmHandleBase destructor calling wasm_base_->startShutdown() mid-test. Apparently V8 tolerates this, but WAMR (correctly) does not. Signed-off-by: Michael Warres <mpw@google.com>
1 parent 7e52561 commit 6c906aa

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

test/stop_iteration_test.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ TEST_P(TestVm, AllowOnHeadersStopIteration) {
4545
ASSERT_TRUE(root_context != nullptr);
4646
ASSERT_TRUE(wasm->configure(root_context, plugin));
4747

48+
auto wasm_handle = std::make_shared<WasmHandleBase>(wasm);
49+
auto plugin_handle = std::make_shared<PluginHandleBase>(wasm_handle, plugin);
50+
4851
// By default, stream context onRequestHeaders and onResponseHeaders
4952
// translates FilterHeadersStatus::StopIteration to
5053
// FilterHeadersStatus::StopAllIterationAndWatermark.
5154
{
52-
auto wasm_handle = std::make_shared<WasmHandleBase>(wasm);
53-
auto plugin_handle = std::make_shared<PluginHandleBase>(wasm_handle, plugin);
5455
auto stream_context = TestContext(wasm.get(), root_context->id(), plugin_handle);
5556
stream_context.onCreate();
5657
EXPECT_EQ(stream_context.onRequestHeaders(/*headers=*/0, /*end_of_stream=*/false),
@@ -64,8 +65,6 @@ TEST_P(TestVm, AllowOnHeadersStopIteration) {
6465

6566
// Create a stream context that propagates FilterHeadersStatus::StopIteration.
6667
{
67-
auto wasm_handle = std::make_shared<WasmHandleBase>(wasm);
68-
auto plugin_handle = std::make_shared<PluginHandleBase>(wasm_handle, plugin);
6968
auto stream_context = TestContext(wasm.get(), root_context->id(), plugin_handle);
7069
stream_context.set_allow_on_headers_stop_iteration(true);
7170
stream_context.onCreate();

0 commit comments

Comments
 (0)