On branch master

Your branch is up to date with 'origin/master'.
Signed-off-by:lifansheng <lifansheng1@huawei.com>
This commit is contained in:
Wang
2021-11-11 14:55:21 +08:00
parent de5707f85c
commit 00e718c78d
3 changed files with 32 additions and 25 deletions
+10 -5
View File
@@ -10,7 +10,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/test.gni")
if (is_standard_system) {
@@ -20,12 +19,15 @@ if (is_standard_system) {
ohos_unittest("test_process_unittest") {
module_out_path = module_output_path
configs = [ "//ark/js_runtime:ark_jsruntime_public_config" ]
include_dirs = [
"//base/compileruntime/js_sys_module/process",
"//ark/js_runtime",
"//foundation/ace/napi",
"//foundation/ace/napi/interfaces/kits",
"//foundation/ace/napi/native_engine",
"//foundation/ace/napi/native_engine/impl/quickjs",
"//foundation/ace/napi/native_engine/impl/ark",
"//third_party/googletest/include",
"//third_party/node/src",
"//utils/native/base/include",
@@ -34,24 +36,27 @@ ohos_unittest("test_process_unittest") {
cflags = [ "-g3" ]
sources = [
"test_ark.cpp",
"test_process.cpp",
"test_quickjs.cpp",
]
deps = [
"//ark/js_runtime:libark_jsruntime",
"//base/compileruntime/js_sys_module/process:process_packages",
"//foundation/ace/napi/:ace_napi",
"//foundation/ace/napi/:ace_napi_quickjs",
"//foundation/ace/napi/:ace_napi_ark",
"//third_party/googletest:gtest",
"//third_party/googletest:gtest_main",
"//third_party/icu/icu4c:static_icuuc",
"//third_party/libuv:uv_static",
"//third_party/quickjs:qjs",
"//utils/native/base:utils",
"//utils/native/base:utilsecurec",
]
if (is_standard_system) {
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
} else {
external_deps = [ "hilog:libhilog" ]
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ public:
void SetUp() override {}
void TearDown() override {}
protected:
NativeEngine* engine_;
NativeEngine *engine_;
};
#endif /* FOUNDATION_ACE_NAPI_TEST_UNITTEST_TEST_H */
+21 -19
View File
@@ -15,9 +15,11 @@
#include "test.h"
#include "quickjs_native_engine.h"
#include "utils/log.h"
#include "ark_native_engine.h"
static NativeEngine* g_nativeEngine = nullptr;
using panda::RuntimeOption;
static NativeEngine *g_nativeEngine = nullptr;
NativeEngineTest::NativeEngineTest()
{
@@ -26,35 +28,35 @@ NativeEngineTest::NativeEngineTest()
NativeEngineTest::~NativeEngineTest() {}
int main(int argc, char** argv)
int main(int argc, char **argv)
{
testing::GTEST_FLAG(output) = "xml:./";
testing::InitGoogleTest(&argc, argv);
JSRuntime* rt = JS_NewRuntime();
if (rt == nullptr) {
// Setup
RuntimeOption option;
option.SetGcType(RuntimeOption::GC_TYPE::GEN_GC);
const int64_t poolSize = 0x1000000; // 16M
option.SetGcPoolSize(poolSize);
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
option.SetDebuggerLibraryPath("");
EcmaVM *vm = panda::JSNApi::CreateJSVM(option);
if (vm == nullptr) {
return 0;
}
JSContext* ctx = JS_NewContext(rt);
if (ctx == nullptr) {
return 0;
}
g_nativeEngine = new ArkNativeEngine(vm, nullptr);
js_std_add_helpers(ctx, 0, nullptr);
int ret = testing::UnitTest::GetInstance()->Run();
g_nativeEngine = new QuickJSNativeEngine(rt, ctx, nullptr);
int ret = RUN_ALL_TESTS();
g_nativeEngine->Loop(LOOP_DEFAULT);
g_nativeEngine->Loop(LOOP_NOWAIT);
delete g_nativeEngine;
g_nativeEngine = nullptr;
js_std_free_handlers(rt);
JS_FreeContext(ctx);
JS_FreeRuntime(rt);
panda::JSNApi::DestoryJSVM(vm);
vm = nullptr;
return ret;
}