14d6c458bSopenharmony_ci/* 24d6c458bSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 34d6c458bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44d6c458bSopenharmony_ci * you may not use this file except in compliance with the License. 54d6c458bSopenharmony_ci * You may obtain a copy of the License at 64d6c458bSopenharmony_ci * 74d6c458bSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84d6c458bSopenharmony_ci * 94d6c458bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104d6c458bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114d6c458bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124d6c458bSopenharmony_ci * See the License for the specific language governing permissions and 134d6c458bSopenharmony_ci * limitations under the License. 144d6c458bSopenharmony_ci */ 154d6c458bSopenharmony_ci 164d6c458bSopenharmony_ci#include "test.h" 174d6c458bSopenharmony_ci#include "ark_native_engine.h" 184d6c458bSopenharmony_ci#include "tools/log.h" 194d6c458bSopenharmony_ci 204d6c458bSopenharmony_ciusing panda::RuntimeOption; 214d6c458bSopenharmony_cistatic NativeEngine *g_nativeEngine = nullptr; 224d6c458bSopenharmony_ci 234d6c458bSopenharmony_ciNativeEngineTest::NativeEngineTest() 244d6c458bSopenharmony_ci{ 254d6c458bSopenharmony_ci engine_ = g_nativeEngine; 264d6c458bSopenharmony_ci} 274d6c458bSopenharmony_ci 284d6c458bSopenharmony_ciNativeEngineTest::~NativeEngineTest() {} 294d6c458bSopenharmony_ci 304d6c458bSopenharmony_ciint main(int argc, char **argv) 314d6c458bSopenharmony_ci{ 324d6c458bSopenharmony_ci testing::GTEST_FLAG(output) = "xml:./"; 334d6c458bSopenharmony_ci testing::InitGoogleTest(&argc, argv); 344d6c458bSopenharmony_ci 354d6c458bSopenharmony_ci // Setup 364d6c458bSopenharmony_ci RuntimeOption option; 374d6c458bSopenharmony_ci option.SetGcType(RuntimeOption::GC_TYPE::GEN_GC); 384d6c458bSopenharmony_ci 394d6c458bSopenharmony_ci const int64_t poolSize = 0x1000000; // 16M 404d6c458bSopenharmony_ci option.SetGcPoolSize(poolSize); 414d6c458bSopenharmony_ci 424d6c458bSopenharmony_ci option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); 434d6c458bSopenharmony_ci option.SetDebuggerLibraryPath(""); 444d6c458bSopenharmony_ci EcmaVM *vm = panda::JSNApi::CreateJSVM(option); 454d6c458bSopenharmony_ci if (vm == nullptr) { 464d6c458bSopenharmony_ci return 0; 474d6c458bSopenharmony_ci } 484d6c458bSopenharmony_ci 494d6c458bSopenharmony_ci g_nativeEngine = new ArkNativeEngine(vm, nullptr); 504d6c458bSopenharmony_ci 514d6c458bSopenharmony_ci int ret = testing::UnitTest::GetInstance()->Run(); 524d6c458bSopenharmony_ci 534d6c458bSopenharmony_ci g_nativeEngine->Loop(LOOP_NOWAIT); 544d6c458bSopenharmony_ci if (g_nativeEngine) { 554d6c458bSopenharmony_ci delete g_nativeEngine; 564d6c458bSopenharmony_ci g_nativeEngine = nullptr; 574d6c458bSopenharmony_ci } 584d6c458bSopenharmony_ci panda::JSNApi::DestroyJSVM(vm); 594d6c458bSopenharmony_ci vm = nullptr; 604d6c458bSopenharmony_ci 614d6c458bSopenharmony_ci return ret; 624d6c458bSopenharmony_ci} 63