1# Copyright (c) 2022 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/runtime_core/ark_root.gni")
15import("$build_root/test.gni")
16
17module_output_path = "arkcompiler/runtime_core"
18
19template("host_unittest_action") {
20  _target_name_ = "${target_name}"
21
22  # unittest for phone running
23  ohos_unittest(_target_name_) {
24    forward_variables_from(invoker, "*")
25  }
26
27  _module_out_path_ = invoker.module_out_path
28
29  # unittest for host running
30  action("${_target_name_}Action") {
31    testonly = true
32
33    defines = [ "HOST_UT" ]
34
35    _host_test_target_ = ":${_target_name_}(${host_toolchain})"
36    _root_out_dir_ = get_label_info(_host_test_target_, "root_out_dir")
37
38    deps = [ _host_test_target_ ]
39
40    script = "//arkcompiler/ets_runtime/script/run_ark_executable.py"
41
42    args = [
43      "--script-file",
44      rebase_path(_root_out_dir_) +
45          "/tests/unittest/${_module_out_path_}/${_target_name_}",
46      "--expect-output",
47      "0",
48      "--env-path",
49      rebase_path(_root_out_dir_) + "/arkcompiler/runtime_core:" +
50          rebase_path(_root_out_dir_) + "/thirdparty/zlib:",
51      "--timeout-limit",
52      "1200",
53    ]
54
55    inputs = [
56      "$_root_out_dir_/tests/unittest/${_module_out_path_}/${_target_name_}",
57    ]
58    outputs = [ "$target_out_dir/${_target_name_}/" ]
59  }
60}
61