diff --git a/ecmascript/jspandafile/tests/js_pandafile_executor_test.cpp b/ecmascript/jspandafile/tests/js_pandafile_executor_test.cpp index ccfce05e7bcaff5653db5d96606fd88cde4754f9..05e656179aa651e38be98314b8d1f3b73dd5c8a3 100644 --- a/ecmascript/jspandafile/tests/js_pandafile_executor_test.cpp +++ b/ecmascript/jspandafile/tests/js_pandafile_executor_test.cpp @@ -87,8 +87,6 @@ HWTEST_F_L0(JSPandaFileExecutorTest, Execute) Expected result = JSPandaFileExecutor::Execute(thread, pf.get(), JSPandaFile::ENTRY_MAIN_FUNCTION); EXPECT_TRUE(result); - - pfManager->RemoveJSPandaFile(pf.get()); } HWTEST_F_L0(JSPandaFileExecutorTest, ExecuteFromFile) @@ -126,6 +124,9 @@ HWTEST_F_L0(JSPandaFileExecutorTest, ExecuteFromFile) pfManager->RemoveJSPandaFile(pf.get()); std::shared_ptr foundPf = pfManager->FindJSPandaFile(fileName); EXPECT_TRUE(foundPf == nullptr); + + // readd panda file into mgr, due to panda file should managed by gc. + pfManager->AddJSPandaFile(pf); } HWTEST_F_L0(JSPandaFileExecutorTest, ExecuteFromBuffer) @@ -163,6 +164,9 @@ HWTEST_F_L0(JSPandaFileExecutorTest, ExecuteFromBuffer) pfManager->RemoveJSPandaFile(pf.get()); std::shared_ptr foundPf = pfManager->FindJSPandaFile(fileName); EXPECT_TRUE(foundPf == nullptr); + + // readd panda file into mgr, due to panda file should managed by gc. + pfManager->AddJSPandaFile(pf); } HWTEST_F_L0(JSPandaFileExecutorTest, ExecuteAbcFileWithSingletonPatternFlag) diff --git a/ecmascript/jspandafile/tests/js_pandafile_manager_test.cpp b/ecmascript/jspandafile/tests/js_pandafile_manager_test.cpp index 0f2e3ea25fad60816892b0a25c9511abac94ef0f..fe398fb60a2a7ee564fc798e1b0e1dc656bab9be 100644 --- a/ecmascript/jspandafile/tests/js_pandafile_manager_test.cpp +++ b/ecmascript/jspandafile/tests/js_pandafile_manager_test.cpp @@ -192,6 +192,10 @@ HWTEST_F_L0(JSPandaFileManagerTest, MultiEcmaVM_Add_Find_Remove_JSPandaFile) std::shared_ptr afterRemovePf2 = pfManager->FindJSPandaFile(filename2); EXPECT_EQ(afterRemovePf1, nullptr); EXPECT_EQ(afterRemovePf2, nullptr); + + // panda file would be managed by gc, readd to panda file manager after check + pfManager->AddJSPandaFile(pf1); + pfManager->AddJSPandaFile(pf2); } void CreateJSPandaFileAndConstpool(EcmaVM *vm) @@ -298,8 +302,6 @@ HWTEST_F_L0(JSPandaFileManagerTest, GenerateProgram) JSHandle mainFunc(thread, program->GetMainFunction(thread)); JSHandle funcName = JSFunction::GetFunctionName(thread, JSHandle(mainFunc)); EXPECT_STREQ(EcmaStringAccessor(JSHandle::Cast(funcName)).ToCString(thread).c_str(), "foo"); - - pfManager->RemoveJSPandaFile(pf.get()); } HWTEST_F_L0(JSPandaFileManagerTest, GetJSPtExtractor) diff --git a/ecmascript/jspandafile/tests/panda_file_translator_test.cpp b/ecmascript/jspandafile/tests/panda_file_translator_test.cpp index d8edae1b3272c30b5e0c820ed2ce7710188cd6fa..e92178a79db2e655ab03f72c46bca63124d340be 100644 --- a/ecmascript/jspandafile/tests/panda_file_translator_test.cpp +++ b/ecmascript/jspandafile/tests/panda_file_translator_test.cpp @@ -96,8 +96,6 @@ HWTEST_F_L0(PandaFileTranslatorTest, GenerateProgram) JSHandle mainFunc2(thread, program2->GetMainFunction(thread)); JSHandle funcName2 = JSFunction::GetFunctionName(thread, JSHandle(mainFunc2)); EXPECT_STREQ(EcmaStringAccessor(JSHandle::Cast(funcName2)).ToCString(thread).c_str(), "func_main_0"); - - pfManager->RemoveJSPandaFile(pf.get()); } HWTEST_F_L0(PandaFileTranslatorTest, TranslateClasses) @@ -131,6 +129,5 @@ HWTEST_F_L0(PandaFileTranslatorTest, TranslateClasses) EXPECT_TRUE(pf->FindMethodLiteral(methodId[0].GetOffset()) != nullptr); EXPECT_EQ(pf->FindMethodLiteral(methodId[0].GetOffset())->GetFunctionKind(), ecmascript::FunctionKind::NONE_FUNCTION); - pfManager->RemoveJSPandaFile(pf.get()); } } // namespace panda::test