1ce968135Sopenharmony_ci# Copyright (c) 2023 Huawei Device Co., Ltd.
2ce968135Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3ce968135Sopenharmony_ci# you may not use this file except in compliance with the License.
4ce968135Sopenharmony_ci# You may obtain a copy of the License at
5ce968135Sopenharmony_ci#
6ce968135Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
7ce968135Sopenharmony_ci#
8ce968135Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9ce968135Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10ce968135Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11ce968135Sopenharmony_ci# See the License for the specific language governing permissions and
12ce968135Sopenharmony_ci# limitations under the License.
13ce968135Sopenharmony_ci
14ce968135Sopenharmony_ciimport("../../../wallpaper.gni")
15ce968135Sopenharmony_ci
16ce968135Sopenharmony_ci#####################hydra-fuzz###################
17ce968135Sopenharmony_ciimport("//build/config/features.gni")
18ce968135Sopenharmony_ciimport("//build/ohos.gni")
19ce968135Sopenharmony_ciimport("//build/test.gni")
20ce968135Sopenharmony_ci
21ce968135Sopenharmony_ci##############################fuzztest##########################################
22ce968135Sopenharmony_ciboundarycode_test = {
23ce968135Sopenharmony_ci  targetName = "WallpaperBoundaryCodeFuzzTest"
24ce968135Sopenharmony_ci  configFuzzer = "wallpaperboundarycode_fuzzer"
25ce968135Sopenharmony_ci  source = "src/boundarycode_fuzzer.cpp"
26ce968135Sopenharmony_ci}
27ce968135Sopenharmony_cigetcolors_test = {
28ce968135Sopenharmony_ci  targetName = "WallpaperGetColorsFuzzTest"
29ce968135Sopenharmony_ci  configFuzzer = "wallpapergetcolors_fuzzer"
30ce968135Sopenharmony_ci  source = "src/getcolors_fuzzer.cpp"
31ce968135Sopenharmony_ci}
32ce968135Sopenharmony_cigetcolorsv9_test = {
33ce968135Sopenharmony_ci  targetName = "WallpaperGetColorsV9FuzzTest"
34ce968135Sopenharmony_ci  configFuzzer = "wallpapergetcolorsv9_fuzzer"
35ce968135Sopenharmony_ci  source = "src/getcolorsv9_fuzzer.cpp"
36ce968135Sopenharmony_ci}
37ce968135Sopenharmony_cigetfile_test = {
38ce968135Sopenharmony_ci  targetName = "WallpaperGetFileFuzzTest"
39ce968135Sopenharmony_ci  configFuzzer = "wallpapergetfile_fuzzer"
40ce968135Sopenharmony_ci  source = "src/getfile_fuzzer.cpp"
41ce968135Sopenharmony_ci}
42ce968135Sopenharmony_cigetpixelmap_test = {
43ce968135Sopenharmony_ci  targetName = "WallpaperGetPixelMapFuzzTest"
44ce968135Sopenharmony_ci  configFuzzer = "wallpapergetpixelmap_fuzzer"
45ce968135Sopenharmony_ci  source = "src/getpixelmap_fuzzer.cpp"
46ce968135Sopenharmony_ci}
47ce968135Sopenharmony_cigetpixelmapv9_test = {
48ce968135Sopenharmony_ci  targetName = "WallpaperGetPixelMapV9FuzzTest"
49ce968135Sopenharmony_ci  configFuzzer = "wallpapergetpixelmapv9_fuzzer"
50ce968135Sopenharmony_ci  source = "src/getpixelmapv9_fuzzer.cpp"
51ce968135Sopenharmony_ci}
52ce968135Sopenharmony_cigetwallpaperid_test = {
53ce968135Sopenharmony_ci  targetName = "WallpaperGetWallpaperIdFuzzTest"
54ce968135Sopenharmony_ci  configFuzzer = "wallpapergetwallpaperid_fuzzer"
55ce968135Sopenharmony_ci  source = "src/getwallpaperid_fuzzer.cpp"
56ce968135Sopenharmony_ci}
57ce968135Sopenharmony_ciischangepermitted_test = {
58ce968135Sopenharmony_ci  targetName = "WallpaperIsChangePermittedFuzzTest"
59ce968135Sopenharmony_ci  configFuzzer = "wallpaperischangepermitted_fuzzer"
60ce968135Sopenharmony_ci  source = "src/ischangepermitted_fuzzer.cpp"
61ce968135Sopenharmony_ci}
62ce968135Sopenharmony_ciisoperationallowed_test = {
63ce968135Sopenharmony_ci  targetName = "WallpaperIsOperationAllowedFuzzTest"
64ce968135Sopenharmony_ci  configFuzzer = "wallpaperisoperationallowed_fuzzer"
65ce968135Sopenharmony_ci  source = "src/isoperationallowed_fuzzer.cpp"
66ce968135Sopenharmony_ci}
67ce968135Sopenharmony_cioff_test = {
68ce968135Sopenharmony_ci  targetName = "WallpaperOffFuzzTest"
69ce968135Sopenharmony_ci  configFuzzer = "wallpaperoff_fuzzer"
70ce968135Sopenharmony_ci  source = "src/off_fuzzer.cpp"
71ce968135Sopenharmony_ci}
72ce968135Sopenharmony_cion_test = {
73ce968135Sopenharmony_ci  targetName = "WallpaperOnFuzzTest"
74ce968135Sopenharmony_ci  configFuzzer = "wallpaperon_fuzzer"
75ce968135Sopenharmony_ci  source = "src/on_fuzzer.cpp"
76ce968135Sopenharmony_ci}
77ce968135Sopenharmony_ciregistercallback_test = {
78ce968135Sopenharmony_ci  targetName = "WallpaperRegisterCallbackFuzzTest"
79ce968135Sopenharmony_ci  configFuzzer = "wallpaperregistercallback_fuzzer"
80ce968135Sopenharmony_ci  source = "src/registercallback_fuzzer.cpp"
81ce968135Sopenharmony_ci}
82ce968135Sopenharmony_ciresetwallpaper_test = {
83ce968135Sopenharmony_ci  targetName = "WallpaperResetWallpaperFuzzTest"
84ce968135Sopenharmony_ci  configFuzzer = "wallpaperresetwallpaper_fuzzer"
85ce968135Sopenharmony_ci  source = "src/resetwallpaper_fuzzer.cpp"
86ce968135Sopenharmony_ci}
87ce968135Sopenharmony_ciresetwallpaperv9_test = {
88ce968135Sopenharmony_ci  targetName = "WallpaperResetWallpaperV9FuzzTest"
89ce968135Sopenharmony_ci  configFuzzer = "wallpaperresetwallpaperv9_fuzzer"
90ce968135Sopenharmony_ci  source = "src/resetwallpaperv9_fuzzer.cpp"
91ce968135Sopenharmony_ci}
92ce968135Sopenharmony_cisendevent_test = {
93ce968135Sopenharmony_ci  targetName = "WallpaperSendEventFuzzTest"
94ce968135Sopenharmony_ci  configFuzzer = "wallpapersendevent_fuzzer"
95ce968135Sopenharmony_ci  source = "src/sendevent_fuzzer.cpp"
96ce968135Sopenharmony_ci}
97ce968135Sopenharmony_cisetcustom_test = {
98ce968135Sopenharmony_ci  targetName = "WallpaperSetCustomFuzzTest"
99ce968135Sopenharmony_ci  configFuzzer = "wallpapersetcustom_fuzzer"
100ce968135Sopenharmony_ci  source = "src/setcustom_fuzzer.cpp"
101ce968135Sopenharmony_ci}
102ce968135Sopenharmony_cisetvideo_test = {
103ce968135Sopenharmony_ci  targetName = "WallpaperSetVideoFuzzTest"
104ce968135Sopenharmony_ci  configFuzzer = "wallpapersetvideo_fuzzer"
105ce968135Sopenharmony_ci  source = "src/setvideo_fuzzer.cpp"
106ce968135Sopenharmony_ci}
107ce968135Sopenharmony_cisetwallpaper_test = {
108ce968135Sopenharmony_ci  targetName = "WallpaperSetWallpaperFuzzTest"
109ce968135Sopenharmony_ci  configFuzzer = "wallpapersetwallpaper_fuzzer"
110ce968135Sopenharmony_ci  source = "src/setwallpaper_fuzzer.cpp"
111ce968135Sopenharmony_ci}
112ce968135Sopenharmony_cisetwallpaperv9_test = {
113ce968135Sopenharmony_ci  targetName = "WallpaperSetWallpaperV9FuzzTest"
114ce968135Sopenharmony_ci  configFuzzer = "wallpapersetwallpaperv9_fuzzer"
115ce968135Sopenharmony_ci  source = "src/setwallpaperv9_fuzzer.cpp"
116ce968135Sopenharmony_ci}
117ce968135Sopenharmony_cisetwallpaperpixelmapv9_test = {
118ce968135Sopenharmony_ci  targetName = "WallpaperSetWallpaperPixelmapV9FuzzTest"
119ce968135Sopenharmony_ci  configFuzzer = "wallpapersetwallpaperpixelmapv9_fuzzer"
120ce968135Sopenharmony_ci  source = "src/setwallpaperpixelmapv9_fuzz.cpp"
121ce968135Sopenharmony_ci}
122ce968135Sopenharmony_ciwallpaperstub_test = {
123ce968135Sopenharmony_ci  targetName = "WallpaperStubFuzzTest"
124ce968135Sopenharmony_ci  configFuzzer = "wallpaperstub_fuzzer"
125ce968135Sopenharmony_ci  source = "src/wallpaperstub_fuzz.cpp"
126ce968135Sopenharmony_ci}
127ce968135Sopenharmony_ci
128ce968135Sopenharmony_ciwallpaper_fuzztests = [
129ce968135Sopenharmony_ci  boundarycode_test,
130ce968135Sopenharmony_ci  getcolors_test,
131ce968135Sopenharmony_ci  getcolorsv9_test,
132ce968135Sopenharmony_ci  getfile_test,
133ce968135Sopenharmony_ci  getpixelmap_test,
134ce968135Sopenharmony_ci  getpixelmapv9_test,
135ce968135Sopenharmony_ci  getwallpaperid_test,
136ce968135Sopenharmony_ci  ischangepermitted_test,
137ce968135Sopenharmony_ci  isoperationallowed_test,
138ce968135Sopenharmony_ci  off_test,
139ce968135Sopenharmony_ci  on_test,
140ce968135Sopenharmony_ci  registercallback_test,
141ce968135Sopenharmony_ci  resetwallpaper_test,
142ce968135Sopenharmony_ci  resetwallpaperv9_test,
143ce968135Sopenharmony_ci  sendevent_test,
144ce968135Sopenharmony_ci  setcustom_test,
145ce968135Sopenharmony_ci  setvideo_test,
146ce968135Sopenharmony_ci  setwallpaper_test,
147ce968135Sopenharmony_ci  setwallpaperv9_test,
148ce968135Sopenharmony_ci  setwallpaperpixelmapv9_test,
149ce968135Sopenharmony_ci  wallpaperstub_test,
150ce968135Sopenharmony_ci]
151ce968135Sopenharmony_ciforeach(item, wallpaper_fuzztests) {
152ce968135Sopenharmony_ci  ohos_fuzztest(item.targetName) {
153ce968135Sopenharmony_ci    module_out_path = "wallpaper_mgr/wallpaper_mgr"
154ce968135Sopenharmony_ci
155ce968135Sopenharmony_ci    fuzz_config_file = "${wallpaper_path}/test/fuzztest/wallpaperservice_fuzzer/${item.configFuzzer}"
156ce968135Sopenharmony_ci
157ce968135Sopenharmony_ci    include_dirs = [
158ce968135Sopenharmony_ci      "${wallpaper_path}/services/include",
159ce968135Sopenharmony_ci      "${wallpaper_path}/frameworks/native/include",
160ce968135Sopenharmony_ci      "${wallpaper_path}/utils/include",
161ce968135Sopenharmony_ci      "${wallpaper_path}/test/fuzztest/wallpaperservice_fuzzer/include",
162ce968135Sopenharmony_ci    ]
163ce968135Sopenharmony_ci
164ce968135Sopenharmony_ci    cflags = [
165ce968135Sopenharmony_ci      "-g",
166ce968135Sopenharmony_ci      "-O0",
167ce968135Sopenharmony_ci      "-Wno-unused-variable",
168ce968135Sopenharmony_ci      "-fno-omit-frame-pointer",
169ce968135Sopenharmony_ci    ]
170ce968135Sopenharmony_ci
171ce968135Sopenharmony_ci    sources = [
172ce968135Sopenharmony_ci      "src/fuzztest_utils.cpp",
173ce968135Sopenharmony_ci      item.source,
174ce968135Sopenharmony_ci    ]
175ce968135Sopenharmony_ci
176ce968135Sopenharmony_ci    deps = [
177ce968135Sopenharmony_ci      "${utils_path}:wallpaper_utils",
178ce968135Sopenharmony_ci      "${wallpaper_path}/services:wallpaper_service",
179ce968135Sopenharmony_ci    ]
180ce968135Sopenharmony_ci
181ce968135Sopenharmony_ci    external_deps = [
182ce968135Sopenharmony_ci      "ability_runtime:abilitykit_native",
183ce968135Sopenharmony_ci      "access_token:libaccesstoken_sdk",
184ce968135Sopenharmony_ci      "access_token:libtoken_setproc",
185ce968135Sopenharmony_ci      "c_utils:utils",
186ce968135Sopenharmony_ci      "hilog:libhilog",
187ce968135Sopenharmony_ci      "ipc:ipc_single",
188ce968135Sopenharmony_ci      "os_account:os_account_innerkits",
189ce968135Sopenharmony_ci      "window_manager:libwm",
190ce968135Sopenharmony_ci    ]
191ce968135Sopenharmony_ci  }
192ce968135Sopenharmony_ci}
193ce968135Sopenharmony_ci
194ce968135Sopenharmony_ci###############################################################################
195ce968135Sopenharmony_cigroup("fuzztest") {
196ce968135Sopenharmony_ci  testonly = true
197ce968135Sopenharmony_ci  deps = []
198ce968135Sopenharmony_ci  deps += [
199ce968135Sopenharmony_ci    # deps file
200ce968135Sopenharmony_ci    ":WallpaperBoundaryCodeFuzzTest",
201ce968135Sopenharmony_ci    ":WallpaperGetColorsFuzzTest",
202ce968135Sopenharmony_ci    ":WallpaperGetColorsV9FuzzTest",
203ce968135Sopenharmony_ci    ":WallpaperGetFileFuzzTest",
204ce968135Sopenharmony_ci    ":WallpaperGetPixelMapFuzzTest",
205ce968135Sopenharmony_ci    ":WallpaperGetPixelMapV9FuzzTest",
206ce968135Sopenharmony_ci    ":WallpaperGetWallpaperIdFuzzTest",
207ce968135Sopenharmony_ci    ":WallpaperIsChangePermittedFuzzTest",
208ce968135Sopenharmony_ci    ":WallpaperIsOperationAllowedFuzzTest",
209ce968135Sopenharmony_ci    ":WallpaperOffFuzzTest",
210ce968135Sopenharmony_ci    ":WallpaperOnFuzzTest",
211ce968135Sopenharmony_ci    ":WallpaperRegisterCallbackFuzzTest",
212ce968135Sopenharmony_ci    ":WallpaperResetWallpaperFuzzTest",
213ce968135Sopenharmony_ci    ":WallpaperResetWallpaperV9FuzzTest",
214ce968135Sopenharmony_ci    ":WallpaperSendEventFuzzTest",
215ce968135Sopenharmony_ci    ":WallpaperSetCustomFuzzTest",
216ce968135Sopenharmony_ci    ":WallpaperSetVideoFuzzTest",
217ce968135Sopenharmony_ci    ":WallpaperSetWallpaperFuzzTest",
218ce968135Sopenharmony_ci    ":WallpaperSetWallpaperPixelmapV9FuzzTest",
219ce968135Sopenharmony_ci    ":WallpaperSetWallpaperV9FuzzTest",
220ce968135Sopenharmony_ci    ":WallpaperStubFuzzTest",
221ce968135Sopenharmony_ci  ]
222ce968135Sopenharmony_ci}
223ce968135Sopenharmony_ci###############################################################################
224