• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_runtime/js_runtime_config.gni")
15import("//arkcompiler/ets_runtime/test/test_helper.gni")
16
17test_js_path = "//arkcompiler/ets_runtime/ecmascript/napi/test/js/"
18test_ts_path = "//arkcompiler/ets_runtime/ecmascript/napi/test/ts/"
19
20test_js_files = [
21  "termination_1",
22  "termination_2",
23  "termination_3",
24  "termination",
25]
26
27test_ts_files = [
28  "module_export"
29]
30
31foreach(file, test_ts_files) {
32  es2abc_gen_abc("gen_${file}_abc") {
33    test_ts = "${test_ts_path}${file}.ts"
34    test_abc = "$target_out_dir/${file}.abc"
35
36    # Only targets in this file can depend on this.
37    extra_visibility = [ ":*" ]
38    src_js = rebase_path(test_ts)
39    dst_file = rebase_path(test_abc)
40    extra_args = []
41    extra_args += [ "--module" ]
42    extra_args += [ "--merge-abc" ]
43    in_puts = [ test_ts ]
44    out_puts = [ test_abc ]
45  }
46}
47
48foreach(file, test_js_files) {
49  es2abc_gen_abc("gen_${file}_abc") {
50    test_js = "${test_js_path}${file}.js"
51    test_abc = "$target_out_dir/${file}.abc"
52
53    # Only targets in this file can depend on this.
54    extra_visibility = [ ":*" ]
55    src_js = rebase_path(test_js)
56    dst_file = rebase_path(test_abc)
57    extra_args = []
58    extra_args += [ "--module" ]
59    extra_args += [ "--merge-abc" ]
60    in_puts = [ test_js ]
61    out_puts = [ test_abc ]
62  }
63}
64
65module_output_path = "ets_runtime"
66
67host_unittest_action("Jsnapi_001_Test") {
68  module_out_path = module_output_path
69
70  sources = [
71    # test file
72    "dfx_jsnapi_tests.cpp",
73  ]
74
75  configs = [ "../../../:ecma_test_config" ]
76
77  deps = [ "$js_root:libark_jsruntime_test" ]
78
79  foreach(file, test_js_files) {
80    deps += [ ":gen_${file}_abc" ]
81  }
82
83  foreach(file, test_ts_files) {
84    deps += [ ":gen_${file}_abc" ]
85  }
86
87  if (is_ohos && is_standard_system) {
88    test_abc_dir = "/data/test/"
89  } else {
90    test_abc_dir = rebase_path(target_out_dir)
91  }
92  defines = ["ABC_PATH=\"${test_abc_dir}/\""]
93
94  # hiviewdfx libraries
95  external_deps = hiviewdfx_ext_deps
96  deps += hiviewdfx_deps
97  external_deps += [
98    "icu:shared_icui18n",
99    "icu:shared_icuuc",
100    "zlib:libz",
101  ]
102}
103
104host_unittest_action("Jsnapi_002_Test") {
105  module_out_path = module_output_path
106
107  sources = [
108    # test file
109    "jsnapi_first_tests.cpp",
110  ]
111
112  configs = [ "../../../:ecma_test_config" ]
113
114  deps = [ "$js_root:libark_jsruntime_test" ]
115
116  foreach(file, test_js_files) {
117    deps += [ ":gen_${file}_abc" ]
118  }
119
120  # hiviewdfx libraries
121  external_deps = hiviewdfx_ext_deps
122  external_deps += [
123    "icu:shared_icui18n",
124    "icu:shared_icuuc",
125    "zlib:libz",
126  ]
127  deps += hiviewdfx_deps
128}
129
130host_unittest_action("Jsnapi_003_Test") {
131  module_out_path = module_output_path
132
133  sources = [
134    # test file
135    "jsnapi_second_tests.cpp",
136  ]
137
138  configs = [ "../../../:ecma_test_config" ]
139
140  deps = [ "$js_root:libark_jsruntime_test" ]
141
142  foreach(file, test_js_files) {
143    deps += [ ":gen_${file}_abc" ]
144  }
145
146  # hiviewdfx libraries
147  external_deps = hiviewdfx_ext_deps
148  external_deps += [
149    "icu:shared_icui18n",
150    "icu:shared_icuuc",
151    "zlib:libz",
152  ]
153  deps += hiviewdfx_deps
154}
155
156host_unittest_action("Jsnapi_004_Test") {
157  module_out_path = module_output_path
158
159  sources = [
160    # test file
161    "jsnapi_third_tests.cpp",
162  ]
163
164  configs = [ "../../../:ecma_test_config" ]
165
166  deps = [ "$js_root:libark_jsruntime_test" ]
167
168  foreach(file, test_js_files) {
169    deps += [ ":gen_${file}_abc" ]
170  }
171
172  # hiviewdfx libraries
173  external_deps = hiviewdfx_ext_deps
174  external_deps += [
175    "icu:shared_icui18n",
176    "icu:shared_icuuc",
177    "zlib:libz",
178  ]
179  deps += hiviewdfx_deps
180}
181
182host_unittest_action("Jsnapi_Sendable_Test") {
183  module_out_path = module_output_path
184
185  sources = [ "jsnapi_sendable_tests.cpp" ]
186
187  configs = [ "../../../:ecma_test_config" ]
188
189  deps = [ "$js_root:libark_jsruntime_test" ]
190
191  foreach(file, test_js_files) {
192    deps += [ ":gen_${file}_abc" ]
193  }
194
195  external_deps = hiviewdfx_ext_deps
196  external_deps += [
197    "icu:shared_icui18n",
198    "icu:shared_icuuc",
199  ]
200  deps += hiviewdfx_deps
201}
202
203host_unittest_action("FFIWorkLoadTest") {
204  module_out_path = module_output_path
205
206  sources = [
207    # test file
208    "ffi_workload.cpp",
209  ]
210
211  configs = [ "$js_root:ecma_test_config" ]
212
213  deps = [ "$js_root:libark_jsruntime_test" ]
214
215  # hiviewdfx libraries
216  external_deps = hiviewdfx_ext_deps
217  external_deps += [
218    "icu:shared_icui18n",
219    "icu:shared_icuuc",
220  ]
221  deps += hiviewdfx_deps
222}
223
224host_unittest_action("JsnapiSample") {
225  module_out_path = module_output_path
226
227  sources = [ "jsnapi_sample.cpp" ]
228
229  configs = [
230    "$js_root:ecma_test_config",
231  ]
232
233  if (ark_standalone_build || is_arkui_x) {
234    configs += [
235      "$ark_root/assembler:arkassembler_public_config",
236    ]
237  }
238
239  deps = [
240    "$js_root:libark_jsruntime_test",
241  ]
242
243  # hiviewdfx libraries
244  external_deps = hiviewdfx_ext_deps
245  external_deps += [
246    "icu:shared_icui18n",
247    "icu:shared_icuuc",
248    "runtime_core:libarkassembler_static",
249  ]
250  if (!ark_standalone_build && !is_arkui_x) {
251    external_deps += [
252      "runtime_core:arkassembler_public_headers",
253    ]
254  }
255  deps += hiviewdfx_deps
256}
257
258group("unittest") {
259  testonly = true
260  deps = [
261    ":JsnapiSample",
262    ":Jsnapi_001_Test",
263    ":Jsnapi_002_Test",
264    ":Jsnapi_003_Test",
265    ":Jsnapi_004_Test",
266    ":Jsnapi_Sendable_Test",
267  ]
268}
269
270group("host_unittest") {
271  testonly = true
272  deps = [
273    ":Jsnapi_001_TestAction",
274    ":Jsnapi_002_TestAction",
275    ":Jsnapi_003_TestAction",
276    ":Jsnapi_004_TestAction",
277    ":Jsnapi_Sendable_TestAction",
278  ]
279
280  if (is_mac) {
281    deps -= [
282      ":Jsnapi_001_TestAction",
283      ":Jsnapi_002_TestAction",
284      ":Jsnapi_003_TestAction",
285      ":Jsnapi_004_TestAction",
286      ":Jsnapi_Sendable_TestAction",
287    ]
288  }
289}
290
291group("workload_test") {
292  testonly = true
293  deps = [ ":FFIWorkLoadTest" ]
294}
295