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