• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2022-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("//build/test.gni")
15import("//foundation/ability/ability_runtime/ability_runtime.gni")
16
17module_output_path = "ability_runtime/ability_runtime/abilitymgr"
18
19config("coverage_flags") {
20  cflags = [ "--coverage" ]
21  ldflags = [ "--coverage" ]
22}
23
24ohos_unittest("quickfix_callback_test") {
25  module_out_path = module_output_path
26
27  include_dirs = [
28    "${ability_runtime_native_path}/runtime",
29    "${ability_runtime_native_path}/runtime/utils/include",
30  ]
31
32  sources = [ "js_quickfix_callback_test.cpp" ]
33
34  configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
35  deps = []
36
37  external_deps = [
38    "ability_runtime:runtime",
39    "c_utils:utils",
40  ]
41}
42
43ohos_unittest("runtime_test") {
44  module_out_path = module_output_path
45
46  include_dirs = [
47    "${ability_runtime_native_path}/runtime",
48    "${ability_runtime_native_path}/runtime/utils/include",
49  ]
50
51  sources = [
52    # add mock file
53    "js_module_reader_test.cpp",
54  ]
55
56  configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
57  deps = []
58
59  external_deps = [
60    "ability_base:extractortool",
61    "ability_runtime:runtime",
62    "c_utils:utils",
63    "zlib:libz",
64    "zlib:shared_libz",
65  ]
66}
67
68ohos_unittest("js_runtime_test") {
69  module_out_path = module_output_path
70  sanitize = {
71    cfi = true
72    cfi_cross_dso = true
73    debug = false
74    blocklist = "../../cfi_blocklist.txt"
75  }
76  branch_protector_ret = "pac_ret"
77
78  include_dirs = [
79    "${ability_runtime_native_path}/runtime",
80    "${ability_runtime_native_path}/runtime/utils/include",
81  ]
82
83  sources = [
84    # add mock file
85    "js_runtime_test.cpp",
86    "mock_jsnapi.cpp",
87  ]
88
89  configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
90
91  external_deps = [
92    "ability_runtime:js_environment",
93    "ability_runtime:runtime",
94    "bundle_framework:appexecfwk_base",
95    "bundle_framework:appexecfwk_core",
96    "c_utils:utils",
97    "ets_runtime:libark_jsruntime",
98    "eventhandler:libeventhandler",
99    "ffrt:libffrt",
100    "googletest:gmock_main",
101    "googletest:gtest_main",
102    "hilog:libhilog",
103    "ipc:ipc_core",
104    "napi:ace_napi",
105    "zlib:libz",
106    "zlib:shared_libz",
107  ]
108}
109
110ohos_unittest("js_runtime_first_test") {
111  module_out_path = module_output_path
112  sanitize = {
113    cfi = true
114    cfi_cross_dso = true
115    debug = false
116    blocklist = "../../cfi_blocklist.txt"
117  }
118  branch_protector_ret = "pac_ret"
119
120  include_dirs = [
121    "${ability_runtime_native_path}/runtime",
122    "${ability_runtime_native_path}/runtime/utils/include",
123  ]
124
125  sources = [
126    # add mock file
127    "js_runtime_first_test.cpp",
128    "mock_jsnapi.cpp",
129  ]
130
131  configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
132
133  external_deps = [
134    "ability_runtime:js_environment",
135    "ability_runtime:runtime",
136    "bundle_framework:appexecfwk_base",
137    "bundle_framework:appexecfwk_core",
138    "c_utils:utils",
139    "ets_runtime:libark_jsruntime",
140    "eventhandler:libeventhandler",
141    "ffrt:libffrt",
142    "googletest:gmock_main",
143    "googletest:gtest_main",
144    "hilog:libhilog",
145    "ipc:ipc_core",
146    "napi:ace_napi",
147    "zlib:libz",
148    "zlib:shared_libz",
149  ]
150}
151
152ohos_unittest("hdc_register_test") {
153  module_out_path = module_output_path
154
155  include_dirs = [
156    "${ability_runtime_native_path}/runtime",
157    "${ability_runtime_native_path}/runtime/utils/include",
158  ]
159
160  sources = [
161    # add mock file
162    "${ability_runtime_native_path}/runtime/hdc_register.cpp",
163    "hdc_register_test.cpp",
164  ]
165
166  configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
167
168  external_deps = [
169    "bundle_framework:appexecfwk_core",
170    "c_utils:utils",
171    "googletest:gmock_main",
172    "googletest:gtest_main",
173    "hilog:libhilog",
174    "ipc:ipc_core",
175    "zlib:libz",
176    "zlib:shared_libz",
177  ]
178}
179
180ohos_unittest("ohos_js_environment_test") {
181  module_out_path = module_output_path
182
183  include_dirs = [ "${ability_runtime_native_path}/runtime" ]
184
185  sources = [ "ohos_js_environment_test.cpp" ]
186
187  configs = []
188
189  external_deps = [
190    "ability_runtime:js_environment",
191    "ability_runtime:runtime",
192    "c_utils:utils",
193    "ets_runtime:libark_jsruntime",
194    "eventhandler:libeventhandler",
195    "googletest:gmock_main",
196    "googletest:gtest_main",
197    "hilog:libhilog",
198    "napi:ace_napi",
199  ]
200}
201
202ohos_unittest("js_worker_test") {
203  module_out_path = module_output_path
204
205  include_dirs = [
206    "${ability_runtime_native_path}/runtime",
207    "${ability_runtime_native_path}/runtime/utils/include",
208  ]
209
210  sources = [
211    # add mock file
212    "js_worker_test.cpp",
213  ]
214
215  configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
216  deps = []
217
218  external_deps = [
219    "ability_base:extractortool",
220    "ability_runtime:js_environment",
221    "ability_runtime:runtime",
222    "bundle_framework:appexecfwk_base",
223    "bundle_framework:appexecfwk_core",
224    "c_utils:utils",
225    "ets_runtime:libark_jsruntime",
226    "eventhandler:libeventhandler",
227    "hilog:libhilog",
228    "ipc:ipc_core",
229    "napi:ace_napi",
230    "zlib:libz",
231    "zlib:shared_libz",
232  ]
233}
234
235group("unittest") {
236  testonly = true
237
238  deps = [
239    ":hdc_register_test",
240    ":js_runtime_first_test",
241    ":js_runtime_test",
242    ":js_worker_test",
243    ":ohos_js_environment_test",
244    ":runtime_test",
245  ]
246}
247