1# Copyright (c) 2021 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") 15import("$build_root/test.gni") 16import("../toolchain.gni") 17 18if (is_standard_system || ark_standalone_build) { 19 _icu_path_ = "thirdparty/icu" 20} else { 21 _icu_path_ = "global/i18n" 22} 23 24template("host_unittest_action") { 25 _target_name_ = "${target_name}" 26 27 # unittest for running on OpenHarmony device 28 ohos_unittest(_target_name_) { 29 resource_config_file = 30 "//arkcompiler/toolchain/test/resource/tooling/ohos_test.xml" 31 forward_variables_from(invoker, "*") 32 } 33 34 _module_out_path_ = invoker.module_out_path 35 36 # unittest for running on host 37 action("${_target_name_}ActionWithoutQemu") { 38 testonly = true 39 40 _host_test_target_ = ":${_target_name_}(${host_toolchain})" 41 _root_out_dir_ = get_label_info(_host_test_target_, "root_out_dir") 42 43 deps = [ _host_test_target_ ] 44 45 script = "//arkcompiler/ets_runtime/script/run_ark_executable.py" 46 47 args = [ 48 "--script-file", 49 rebase_path(_root_out_dir_) + 50 "/tests/unittest/${_module_out_path_}/${_target_name_}", 51 "--expect-output", 52 "0", 53 "--env-path", 54 rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" + 55 rebase_path(_root_out_dir_) + "/test/test:" + 56 rebase_path(_root_out_dir_) + "/${_icu_path_}:" + 57 rebase_path(_root_out_dir_) + "/thirdparty/cJSON:" + 58 rebase_path(_root_out_dir_) + "/thirdparty/libuv:" + 59 rebase_path(_root_out_dir_) + 60 "/thirdparty/bounds_checking_function:" + 61 rebase_path(_root_out_dir_) + "/thirdparty/openssl:" + 62 rebase_path(_root_out_dir_) + "/thirdparty/zlib:" + 63 rebase_path("//prebuilts/clang/ohos/linux-x86_64/llvm/lib/"), 64 "--timeout-limit", 65 "1200", 66 ] 67 68 inputs = [ 69 "$_root_out_dir_/tests/unittest/${_module_out_path_}/${_target_name_}", 70 ] 71 outputs = [ "$target_out_dir/${_target_name_}/" ] 72 } 73 if (ark_standalone_build && host_os == "linux" && target_os == "ohos") { 74 import("$ark_third_party_root/musl/musl_template.gni") 75 import("$build_root/config/qemu/config.gni") 76 77 action("${_target_name_}ActionWithQemu") { 78 testonly = true 79 80 _host_test_target_ = ":${_target_name_}" 81 82 # path of root_out_dir based on root_src_dir 83 _root_out_dir_ = get_label_info(_host_test_target_, "root_out_dir") 84 85 deps = [ 86 "$ark_third_party_root/musl:soft_create_linker_for_qemu", 87 _host_test_target_, 88 ] 89 90 script = "${js_root}/script/run_ark_executable.py" 91 92 args = [ 93 "--script-file", 94 rebase_path( 95 "$_root_out_dir_/tests/unittest/${_module_out_path_}/${_target_name_}", 96 root_build_dir), 97 "--expect-output", 98 "0", 99 "--clang-lib-path", 100 rebase_path("${clang_base_path}/lib/${musl_arch}-linux-ohos", 101 root_build_dir), 102 "--qemu-binary-path", 103 rebase_path("${QEMU_INSTALLATION_PATH}/bin/qemu-${musl_arch}", 104 root_build_dir), 105 "--qemu-ld-prefix", 106 rebase_path(musl_linker_so_out_dir, root_build_dir), 107 "--timeout-limit", 108 "1200", 109 ] 110 111 inputs = [ 112 "$_root_out_dir_/tests/unittest/${_module_out_path_}/${_target_name_}", 113 ] 114 outputs = [ "$target_out_dir/${_target_name_}WithQemu/" ] 115 } 116 } 117 group("${_target_name_}Action") { 118 testonly = true 119 120 deps = [] 121 if (ark_standalone_build && host_os == "linux" && target_os == "ohos" && 122 run_with_qemu) { 123 deps += [ ":${_target_name_}ActionWithQemu" ] 124 } else { 125 deps += [ ":${_target_name_}ActionWithoutQemu" ] 126 } 127 } 128} 129