1# Copyright (c) 2024 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
17test_js_path = "//arkcompiler/ets_runtime/ecmascript/dfx/cpu_profiler/tests/js/"
18
19test_js_files = [ "cpuprofiler_1" ]
20
21foreach(file, test_js_files) {
22  es2abc_gen_abc("gen_${file}_abc") {
23    test_js = "${test_js_path}${file}.js"
24    test_abc = "$target_out_dir/${file}.abc"
25
26    # Only targets in this file can depend on this.
27    extra_visibility = [ ":*" ]
28    src_js = rebase_path(test_js)
29    dst_file = rebase_path(test_abc)
30    extra_args = []
31    extra_args += [ "--module" ]
32    extra_args += [ "--merge-abc" ]
33    in_puts = [ test_js ]
34    out_puts = [ test_abc ]
35  }
36}
37
38module_output_path = "arkcompiler/ets_runtime"
39
40host_unittest_action("CpuProfilerTest") {
41  module_out_path = module_output_path
42
43  sources = [
44    # test file
45    "cpu_profiler_test.cpp",
46    "samples_record_test.cpp",
47  ]
48
49  configs = [ "../../../../:ecma_test_config" ]
50
51  deps = [
52    "$ark_third_party_root/icu/icu4c:shared_icui18n",
53    "$ark_third_party_root/icu/icu4c:shared_icuuc",
54    "../../../../:libark_jsruntime_test",
55  ]
56
57  foreach(file, test_js_files) {
58    deps += [ ":gen_${file}_abc" ]
59  }
60
61  if (is_ohos && is_standard_system) {
62    test_abc_dir = "/data/test"
63  } else {
64    test_abc_dir = rebase_path(target_out_dir)
65  }
66
67  test_js_dir = rebase_path(test_js_path)
68
69  defines = [
70    "DEBUGGER_ABC_DIR=\"${test_abc_dir}/\"",
71    "DEBUGGER_JS_DIR=\"${test_js_dir}\"",
72  ]
73
74  # hiviewdfx libraries
75  external_deps = hiviewdfx_ext_deps
76  deps += hiviewdfx_deps
77}
78
79group("unittest") {
80  testonly = true
81  deps = [ ":CpuProfilerTest" ]
82}
83
84group("host_unittest") {
85  testonly = true
86  deps = [ ":CpuProfilerTestAction" ]
87  if (is_mac) {
88    deps -= [ ":CpuProfilerTestAction" ]
89  }
90}
91