@@ -334,8 +334,9 @@ TEST_F(shared_heap_test, test_destroy_shared_heap_head_only)
334334
335335 ASSERT_NE (nullptr , second);
336336
337- WASMSharedHeap *new_head =
338- wasm_runtime_destroy_shared_heap (shared_heap_chain, false );
337+ WASMSharedHeap *new_head = nullptr ;
338+ ASSERT_TRUE (
339+ wasm_runtime_destroy_shared_heap (shared_heap_chain, false , &new_head));
339340
340341 ASSERT_EQ (second, new_head);
341342 ASSERT_EQ (nullptr , new_head->chain_next );
@@ -355,8 +356,10 @@ TEST_F(shared_heap_test, test_destroy_shared_heap_entire_chain)
355356 FAIL () << " Failed to create shared heap" ;
356357 }
357358
358- EXPECT_EQ (nullptr ,
359- wasm_runtime_destroy_shared_heap (shared_heap_chain, true ));
359+ WASMSharedHeap *new_head = nullptr ;
360+ EXPECT_TRUE (
361+ wasm_runtime_destroy_shared_heap (shared_heap_chain, true , &new_head));
362+ EXPECT_EQ (nullptr , new_head);
360363}
361364
362365TEST_F (shared_heap_test, test_destroy_shared_heap_not_chain_head)
@@ -372,14 +375,16 @@ TEST_F(shared_heap_test, test_destroy_shared_heap_not_chain_head)
372375
373376 ASSERT_NE (nullptr , body);
374377
375- EXPECT_EQ (nullptr , wasm_runtime_destroy_shared_heap (body, true ));
378+ WASMSharedHeap *new_head = nullptr ;
379+ EXPECT_FALSE (wasm_runtime_destroy_shared_heap (body, true , &new_head));
376380 EXPECT_EQ (body, shared_heap_chain->chain_next );
377381
378382 test_shared_heap (shared_heap_chain, " test.wasm" , " test" , 0 , argv);
379383 EXPECT_EQ (10 , argv[0 ]);
380384
381- EXPECT_EQ (nullptr ,
382- wasm_runtime_destroy_shared_heap (shared_heap_chain, true ));
385+ EXPECT_TRUE (
386+ wasm_runtime_destroy_shared_heap (shared_heap_chain, true , &new_head));
387+ EXPECT_EQ (nullptr , new_head);
383388}
384389
385390TEST_F (shared_heap_test, test_destroy_shared_heap_when_attached)
@@ -395,63 +400,15 @@ TEST_F(shared_heap_test, test_destroy_shared_heap_when_attached)
395400 ASSERT_TRUE (wasm_runtime_attach_shared_heap (module_env.wasm_module_inst ,
396401 shared_heap));
397402
398- EXPECT_EQ (nullptr , wasm_runtime_destroy_shared_heap (shared_heap, true ));
403+ WASMSharedHeap *new_head = nullptr ;
404+ EXPECT_FALSE (
405+ wasm_runtime_destroy_shared_heap (shared_heap, true , &new_head));
399406
400407 wasm_runtime_detach_shared_heap (module_env.wasm_module_inst );
401408 destroy_module_env (module_env);
402409
403- EXPECT_EQ (nullptr , wasm_runtime_destroy_shared_heap (shared_heap, true ));
404- }
405-
406- TEST_F (shared_heap_test, test_destroy_invalid_shared_heap)
407- {
408- WASMSharedHeap fake_shared_heap = {};
409-
410- EXPECT_EQ (nullptr ,
411- wasm_runtime_destroy_shared_heap (&fake_shared_heap, true ));
412- }
413-
414- TEST_F (shared_heap_test, test_destroy_shared_heap_untracked_next_head_only)
415- {
416- WASMSharedHeap *shared_heap_chain = nullptr ;
417- WASMSharedHeap *body = nullptr ;
418- WASMSharedHeap fake_shared_heap = {};
419- uint32 BUF_SIZE = os_getpagesize ();
420-
421- create_test_shared_heap_chain (preallocated_buf, BUF_SIZE, preallocated_buf2,
422- BUF_SIZE, &shared_heap_chain);
423- body = shared_heap_chain->chain_next ;
424-
425- ASSERT_NE (nullptr , body);
426-
427- shared_heap_chain->chain_next = &fake_shared_heap;
428- EXPECT_EQ (NULL , wasm_runtime_destroy_shared_heap (shared_heap_chain, false ));
429- shared_heap_chain->chain_next = body;
430-
431- EXPECT_EQ (body, wasm_runtime_destroy_shared_heap (shared_heap_chain, false ));
432- EXPECT_EQ (nullptr , wasm_runtime_destroy_shared_heap (body, true ));
433- }
434-
435- TEST_F (shared_heap_test, test_destroy_shared_heap_untracked_next_entire_chain)
436- {
437- WASMSharedHeap *shared_heap_chain = nullptr ;
438- WASMSharedHeap *body = nullptr ;
439- WASMSharedHeap fake_shared_heap = {};
440- uint32 BUF_SIZE = os_getpagesize ();
441-
442- create_test_shared_heap_chain (NULL , BUF_SIZE, NULL , BUF_SIZE,
443- &shared_heap_chain);
444- body = shared_heap_chain->chain_next ;
445-
446- ASSERT_NE (nullptr , body);
447-
448- shared_heap_chain->chain_next = &fake_shared_heap;
449- EXPECT_EQ (nullptr ,
450- wasm_runtime_destroy_shared_heap (shared_heap_chain, true ));
451-
452- shared_heap_chain->chain_next = body;
453- EXPECT_EQ (nullptr ,
454- wasm_runtime_destroy_shared_heap (shared_heap_chain, true ));
410+ EXPECT_TRUE (wasm_runtime_destroy_shared_heap (shared_heap, true , &new_head));
411+ EXPECT_EQ (nullptr , new_head);
455412}
456413
457414TEST_F (shared_heap_test, test_shared_heap_rmw)
0 commit comments