1 /* 2 * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "test.h" 17 #include "ark_native_engine.h" 18 #include "tools/log.h" 19 20 using panda::RuntimeOption; 21 static NativeEngine *g_nativeEngine = nullptr; 22 23 namespace Commonlibrary::Concurrent::TaskPoolModule { NativeEngineTest()24NativeEngineTest::NativeEngineTest() 25 { 26 engine_ = g_nativeEngine; 27 } 28 ~NativeEngineTest()29NativeEngineTest::~NativeEngineTest() {} 30 } // namespace Commonlibrary::Concurrent::TaskPoolModule 31 main(int argc,char ** argv)32int main(int argc, char **argv) 33 { 34 testing::GTEST_FLAG(output) = "xml:./"; 35 testing::InitGoogleTest(&argc, argv); 36 37 // Setup 38 RuntimeOption option; 39 option.SetGcType(RuntimeOption::GC_TYPE::GEN_GC); 40 41 const int64_t poolSize = 0x1000000; // 16M 42 option.SetGcPoolSize(poolSize); 43 44 option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); 45 option.SetDebuggerLibraryPath(""); 46 EcmaVM *vm = panda::JSNApi::CreateJSVM(option); 47 if (vm == nullptr) { 48 return 0; 49 } 50 51 g_nativeEngine = new ArkNativeEngine(vm, nullptr); 52 g_nativeEngine->SetInitWorkerFunc([](NativeEngine*) {}); 53 54 int ret = testing::UnitTest::GetInstance()->Run(); 55 56 g_nativeEngine->Loop(LOOP_NOWAIT); 57 if (g_nativeEngine) { 58 delete g_nativeEngine; 59 g_nativeEngine = nullptr; 60 } 61 return ret; 62 }