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/ets_runtime/js_runtime_config.gni")
15import("//arkcompiler/ets_runtime/test/test_helper.gni")
16
17module_output_path = "arkcompiler/ets_runtime"
18
19test_js_path =
20    "//arkcompiler/ets_runtime/ecmascript/pgo_profiler/tests/pgo_test_case/"
21
22test_js_files = [
23  "op_type_test",
24  "class_test",
25  "call_test",
26  "builtins_test",
27  "array_test",
28  "object_literal",
29  "sample_test",
30  "string_equal",
31  "array_size_test",
32  "truck",
33  "vehicle",
34  "typedarray_length",
35  "merge_file_1",
36  "merge_file_2",
37  "merge_file_3",
38]
39
40foreach(file, test_js_files) {
41  es2abc_gen_abc("gen_${file}_abc") {
42    test_js = "${test_js_path}${file}.js"
43    test_abc = "$target_out_dir/${file}.abc"
44
45    # Only targets in this file can depend on this.
46    extra_visibility = [ ":*" ]
47    src_js = rebase_path(test_js)
48    dst_file = rebase_path(test_abc)
49    extra_args = []
50    extra_args += [ "--module" ]
51    extra_args += [ "--merge-abc" ]
52    in_puts = [ test_js ]
53    out_puts = [ test_abc ]
54  }
55}
56
57host_unittest_action("PGOProfilerTest") {
58  module_out_path = module_output_path
59
60  sources = [
61    # test file
62    "pgo_profiler_test.cpp",
63  ]
64
65  configs = [
66    "//arkcompiler/ets_runtime:asm_interp_enable_config",
67    "//arkcompiler/ets_runtime:ecma_test_config",
68    "$ark_root/assembler:arkassembler_public_config",
69  ]
70
71  deps = [
72    "$ark_root/assembler:libarkassembler_static",
73    "$ark_third_party_root/icu/icu4c:shared_icui18n",
74    "$ark_third_party_root/icu/icu4c:shared_icuuc",
75    "//arkcompiler/ets_runtime:libark_jsruntime_test",
76    sdk_libc_secshared_dep,
77  ]
78
79  foreach(file, test_js_files) {
80    deps += [ ":gen_${file}_abc" ]
81  }
82
83  if (is_ohos && is_standard_system) {
84    test_abc_dir = "/data/test"
85  } else {
86    test_abc_dir = rebase_path(target_out_dir)
87  }
88  defines = [ "TARGET_ABC_PATH=\"${test_abc_dir}/\"" ]
89
90  # hiviewdfx libraries
91  external_deps = hiviewdfx_ext_deps
92  deps += hiviewdfx_deps
93}
94
95group("unittest") {
96  testonly = true
97  deps = [ ":PGOProfilerTest" ]
98}
99
100group("host_unittest") {
101  testonly = true
102  deps = [ ":PGOProfilerTestAction" ]
103
104  if (is_mac) {
105    deps -= [ ":PGOProfilerTestAction" ]
106  }
107}
108