• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 
18 #include "utils/log.h"
19 #include "ark_native_engine.h"
20 
21 using panda::RuntimeOption;
22 static NativeEngine *g_nativeEngine = nullptr;
23 
NativeEngineTest()24 NativeEngineTest::NativeEngineTest()
25 {
26     engine_ = g_nativeEngine;
27 }
28 
~NativeEngineTest()29 NativeEngineTest::~NativeEngineTest() {}
30 
main(int argc,char ** argv)31 int main(int argc, char **argv)
32 {
33     testing::GTEST_FLAG(output) = "xml:./";
34     testing::InitGoogleTest(&argc, argv);
35 
36     // Setup
37     RuntimeOption option;
38     option.SetGcType(RuntimeOption::GC_TYPE::GEN_GC);
39 
40     const int64_t poolSize = 0x1000000;  // 16M
41     option.SetGcPoolSize(poolSize);
42 
43     option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
44     option.SetDebuggerLibraryPath("");
45     EcmaVM *vm = panda::JSNApi::CreateJSVM(option);
46     if (vm == nullptr) {
47         return 0;
48     }
49 
50     g_nativeEngine = new ArkNativeEngine(vm, nullptr);
51 
52     int ret = testing::UnitTest::GetInstance()->Run();
53 
54     g_nativeEngine->Loop(LOOP_NOWAIT);
55 
56     delete g_nativeEngine;
57     g_nativeEngine = nullptr;
58     panda::JSNApi::DestroyJSVM(vm);
59     vm = nullptr;
60 
61     return ret;
62 }
63