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/filemanagement/app_file_service/backup.gni")
16
17ohos_unittest("b_error_test") {
18  branch_protector_ret = "pac_ret"
19  sanitize = {
20    integer_overflow = true
21    cfi = true
22    cfi_cross_dso = true
23    debug = false
24  }
25
26  module_out_path = path_module_out_tests
27
28  sources = [ "b_error/b_error_test.cpp" ]
29
30  deps = [
31    "${path_backup}/tests/utils:backup_test_utils",
32    "${path_backup}/utils/:backup_utils",
33  ]
34
35  external_deps = [ "hilog:libhilog" ]
36
37  use_exceptions = true
38}
39
40ohos_unittest("b_file_test") {
41  branch_protector_ret = "pac_ret"
42  sanitize = {
43    integer_overflow = true
44    cfi = true
45    cfi_cross_dso = true
46    debug = false
47  }
48
49  module_out_path = path_module_out_tests
50
51  sources = [
52    "b_filesystem/b_dir_test.cpp",
53    "b_filesystem/b_file_hash_test.cpp",
54    "b_filesystem/b_file_test.cpp",
55  ]
56
57  include_dirs = [ "${path_backup}/utils/src/b_filesystem" ]
58
59  deps = [
60    "${path_backup}/tests/utils:backup_test_utils",
61    "${path_backup}/utils/:backup_utils",
62    "${path_jsoncpp}:jsoncpp",
63  ]
64
65  external_deps = [
66    "c_utils:utils",
67    "hilog:libhilog",
68  ]
69
70  use_exceptions = true
71}
72
73ohos_unittest("b_jsonutil_test") {
74  branch_protector_ret = "pac_ret"
75  sanitize = {
76    integer_overflow = true
77    cfi = true
78    cfi_cross_dso = true
79    debug = false
80  }
81
82  module_out_path = path_module_out_tests
83
84  sources = [ "b_jsonutil/b_jsonutil_test.cpp" ]
85
86  deps = [
87    "${path_backup}/tests/utils:backup_test_utils",
88    "${path_backup}/utils/:backup_utils",
89    "${path_jsoncpp}:jsoncpp",
90  ]
91
92  external_deps = [
93    "cJSON:cjson",
94    "c_utils:utils",
95    "hilog:libhilog",
96  ]
97
98  use_exceptions = true
99}
100
101ohos_unittest("b_json_test") {
102  branch_protector_ret = "pac_ret"
103
104  module_out_path = path_module_out_tests
105
106  sources = [
107    "${path_backup}/utils/src/b_json/b_json_entity_extension_config.cpp",
108    "${path_backup}/utils/src/b_json/b_json_service_disposal_config.cpp",
109    "b_json/b_json_cached_entity_test.cpp",
110    "b_json/b_json_entity_ext_manage_test.cpp",
111    "b_json/b_json_entity_extension_config_test.cpp",
112    "b_json/b_json_service_disposal_config_test.cpp",
113    "b_json/b_report_entity_test.cpp",
114  ]
115  sources += backup_mock_parameter_src
116
117  include_dirs = [
118    "${path_backup}/utils",
119    "${path_base}/include",
120  ]
121  include_dirs += backup_mock_parameter_include_dirs
122
123  deps = [
124    "${path_backup}/interfaces/innerkits/native:sandbox_helper_native",
125    "${path_backup}/tests/utils:backup_test_utils",
126    "${path_backup}/utils/:backup_utils",
127    "${path_googletest}:gmock_main",
128    "${path_jsoncpp}:jsoncpp",
129  ]
130
131  external_deps = [
132    "cJSON:cjson",
133    "c_utils:utils",
134    "hilog:libhilog",
135  ]
136
137  defines = [
138    "LOG_TAG=\"app_file_service\"",
139    "LOG_DOMAIN=0xD004303",
140    "private = public",
141    "protected = public",
142  ]
143
144  sanitize = {
145    integer_overflow = true
146    cfi = true
147    cfi_cross_dso = true
148    debug = false
149  }
150
151  use_exceptions = true
152}
153
154ohos_unittest("b_tarball_cmdline_test") {
155  branch_protector_ret = "pac_ret"
156  sanitize = {
157    integer_overflow = true
158    cfi = true
159    cfi_cross_dso = true
160    debug = false
161  }
162
163  module_out_path = path_module_out_tests
164
165  sources = [
166    "${path_backup_mock}/b_process/b_process_mock.cpp",
167    "b_tarball/b_tarball_cmdline_test.cpp",
168  ]
169
170  include_dirs = [
171    "${path_base}/include",
172    "${path_backup}/utils/include",
173  ]
174
175  deps = [
176    "${path_backup}/tests/utils:backup_test_utils",
177    "${path_backup}/utils/:backup_utils",
178    "${path_googletest}:gmock_main",
179  ]
180
181  external_deps = [
182    "c_utils:utils",
183    "hilog:libhilog",
184  ]
185
186  use_exceptions = true
187}
188
189ohos_unittest("b_tarball_factory_test") {
190  branch_protector_ret = "pac_ret"
191  sanitize = {
192    integer_overflow = true
193    cfi = true
194    cfi_cross_dso = true
195    debug = false
196  }
197
198  module_out_path = path_module_out_tests
199
200  sources = [
201    "${path_backup_mock}/b_tarball/b_tarball_cmdline_mock.cpp",
202    "b_tarball/b_tarball_factory_test.cpp",
203  ]
204
205  include_dirs = [
206    "${path_base}/include",
207    "${path_backup}/utils/include",
208  ]
209
210  deps = [
211    "${path_backup}/tests/utils:backup_test_utils",
212    "${path_googletest}:gmock_main",
213  ]
214  external_deps = [ "c_utils:utils" ]
215  use_exceptions = true
216}
217
218ohos_unittest("b_process_test") {
219  branch_protector_ret = "pac_ret"
220  sanitize = {
221    integer_overflow = true
222    cfi = true
223    cfi_cross_dso = true
224    debug = false
225  }
226
227  module_out_path = path_module_out_tests
228
229  sources = [ "b_process/b_process_test.cpp" ]
230
231  include_dirs = [
232    "${path_base}/include",
233    "${path_backup}/utils/include",
234  ]
235
236  deps = [
237    "${path_backup}/tests/utils:backup_test_utils",
238    "${path_backup}/utils/:backup_utils",
239    "${path_jsoncpp}:jsoncpp",
240  ]
241  external_deps = [
242    "c_utils:utils",
243    "hilog:libhilog",
244  ]
245
246  use_exceptions = true
247}
248
249ohos_unittest("b_json_other_test") {
250  module_out_path = path_module_out_tests
251
252  sources = [
253    "${path_backup}/tests/mock/cJson/src/cJsonMock.cpp",
254    "${path_backup}/tests/unittests/backup_utils/b_json/b_json_service_disposal_config_other_test.cpp",
255    "${path_backup}/utils/src/b_json/b_json_service_disposal_config.cpp",
256  ]
257  sources += backup_mock_parameter_src
258
259  include_dirs = [
260    "${path_backup}/utils",
261    "${path_base}/include",
262    "${path_backup}/tests/mock/cJson/include",
263  ]
264  include_dirs += backup_mock_parameter_include_dirs
265
266  deps = [
267    "${path_backup}/interfaces/innerkits/native:sandbox_helper_native",
268    "${path_backup}/tests/utils:backup_test_utils",
269    "${path_backup}/utils/:backup_utils",
270    "${path_googletest}:gmock_main",
271    "${path_jsoncpp}:jsoncpp",
272  ]
273
274  external_deps = [
275    "cJSON:cjson",
276    "c_utils:utils",
277    "hilog:libhilog",
278  ]
279
280  defines = [
281    "LOG_TAG=\"app_file_service\"",
282    "LOG_DOMAIN=0xD004303",
283    "private = public",
284    "protected = public",
285  ]
286
287  use_exceptions = true
288}
289
290group("backup_test") {
291  testonly = true
292
293  deps = [
294    ":b_error_test",
295    ":b_file_test",
296    ":b_json_other_test",
297    ":b_json_test",
298    ":b_jsonutil_test",
299    ":b_process_test",
300    ":b_tarball_cmdline_test",
301    ":b_tarball_factory_test",
302  ]
303}
304