1# Copyright (c) 2022 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/config/features.gni")
15import("//build/ohos.gni")
16import("//build/test.gni")
17
18#####################hydra-fuzz###################
19import("../../../screenlock.gni")
20
21##############################fuzztest##########################################
22screenlockisdisabled_test = {
23  targetName = "ScreenlockIsdisabledFuzzTest"
24  configFuzzer = "screenlockisdisabled_fuzzer"
25  source = "screenlockisdisabled_fuzzer/screenlockisdisabled_fuzzer.cpp"
26}
27screenlocksetdisabled_test = {
28  targetName = "ScreenlockSetdisabledFuzzTest"
29  configFuzzer = "screenlocksetdisabled_fuzzer"
30  source = "screenlocksetdisabled_fuzzer/screenlocksetdisabled_fuzzer.cpp"
31}
32screenlocksetauthstate_test = {
33  targetName = "ScreenlockSetAuthstateFuzzTest"
34  configFuzzer = "screenlocksetauthstate_fuzzer"
35  source = "screenlocksetauthstate_fuzzer/screenlocksetauthstate_fuzzer.cpp"
36}
37screenlockgetauthstate_test = {
38  targetName = "ScreenlockGetAuthstateFuzzTest"
39  configFuzzer = "screenlockgetauthstate_fuzzer"
40  source = "screenlockgetauthstate_fuzzer/screenlockgetauthstate_fuzzer.cpp"
41}
42screenlockrequeststrong_test = {
43  targetName = "ScreenlockRequestStrongFuzzTest"
44  configFuzzer = "screenlockrequeststrong_fuzzer"
45  source = "screenlockrequeststrong_fuzzer/screenlockrequeststrong_fuzzer.cpp"
46}
47screenlockgetstrongstate_test = {
48  targetName = "ScreenlockGetStrongStateFuzzTest"
49  configFuzzer = "screenlockgetstrongstate_fuzzer"
50  source = "screenlockgetstrongstate_fuzzer/screenlockgetstrongstate_fuzzer.cpp"
51}
52screenlockutils_test = {
53  targetName = "ScreenlockUtilsFuzzTest"
54  configFuzzer = "screenlockutils_fuzzer"
55  source = "screenlockutils_fuzzer/screenlockutils_fuzzer.cpp"
56}
57screenlockauthmanager_test = {
58  targetName = "ScreenlockAuthManagerFuzzTest"
59  configFuzzer = "screenlockauthmanager_fuzzer"
60  source = "screenlockauthmanager_fuzzer/screenlockauthmanager_fuzzer.cpp"
61}
62screenlockislocked_test = {
63  targetName = "ScreenlockIslockedFuzzTest"
64  configFuzzer = "screenlockislocked_fuzzer"
65  source = "screenlockislocked_fuzzer/screenlockislocked_fuzzer.cpp"
66}
67screenlockboundarycode_test = {
68  targetName = "ScreenlockBoundaryCodeFuzzTest"
69  configFuzzer = "screenlockboundarycode_fuzzer"
70  source = "screenlockboundarycode_fuzzer/screenlockboundarycode_fuzzer.cpp"
71}
72screenlockdump_test = {
73  targetName = "ScreenlockDumpFuzzTest"
74  configFuzzer = "screenlockdump_fuzzer"
75  source = "screenlockdump_fuzzer/screenlockdump_fuzzer.cpp"
76}
77screenlockisscreenlocked_test = {
78  targetName = "ScreenlockIsScreenlockedFuzzTest"
79  configFuzzer = "screenlockisscreenlocked_fuzzer"
80  source = "screenlockisscreenlocked_fuzzer/screenlockisscreenlocked_fuzzer.cpp"
81}
82screenlockissecuremode_test = {
83  targetName = "ScreenlockIsSecureModeFuzzTest"
84  configFuzzer = "screenlockissecuremode_fuzzer"
85  source = "screenlockissecuremode_fuzzer/screenlockissecuremode_fuzzer.cpp"
86}
87screenlocklock_test = {
88  targetName = "ScreenlockLockFuzzTest"
89  configFuzzer = "screenlocklock_fuzzer"
90  source = "screenlocklock_fuzzer/screenlocklock_fuzzer.cpp"
91}
92screenlockonsystemevent_test = {
93  targetName = "ScreenlockOnSystemEventFuzzTest"
94  configFuzzer = "screenlockonsystemevent_fuzzer"
95  source = "screenlockonsystemevent_fuzzer/screenlockonsystemevent_fuzzer.cpp"
96}
97screenlocksendscreenlockevent_test = {
98  targetName = "ScreenlockSendScreenlockEventFuzzTest"
99  configFuzzer = "screenlocksendscreenlockevent_fuzzer"
100  source = "screenlocksendscreenlockevent_fuzzer/screenlocksendscreenlockevent_fuzzer.cpp"
101}
102screenlockunlockscreen_test = {
103  targetName = "ScreenlockUnlockScreenFuzzTest"
104  configFuzzer = "screenlockunlockscreen_fuzzer"
105  source = "screenlockunlockscreen_fuzzer/screenlockunlockscreen_fuzzer.cpp"
106}
107screenlockunlock_test = {
108  targetName = "ScreenlockUnlockFuzzTest"
109  configFuzzer = "screenlockunlock_fuzzer"
110  source = "screenlockunlock_fuzzer/screenlockunlock_fuzzer.cpp"
111}
112screenlocklockscreen_test = {
113  targetName = "ScreenlockLockScreenFuzzTest"
114  configFuzzer = "screenlocklockscreen_fuzzer"
115  source = "screenlocklockscreen_fuzzer/screenlocklockscreen_fuzzer.cpp"
116}
117
118screenlock_fuzztests = [
119  screenlockauthmanager_test,
120  screenlockisdisabled_test,
121  screenlocksetdisabled_test,
122  screenlocksetauthstate_test,
123  screenlockgetauthstate_test,
124  screenlockrequeststrong_test,
125  screenlockgetstrongstate_test,
126  screenlockutils_test,
127  screenlockislocked_test,
128  screenlockboundarycode_test,
129  screenlockdump_test,
130  screenlockisscreenlocked_test,
131  screenlockissecuremode_test,
132  screenlocklock_test,
133  screenlockonsystemevent_test,
134  screenlocksendscreenlockevent_test,
135  screenlockunlockscreen_test,
136  screenlockunlock_test,
137  screenlocklockscreen_test,
138]
139
140foreach(item, screenlock_fuzztests) {
141  ohos_fuzztest(item.targetName) {
142    module_out_path = "screenlock_mgr/screenlock_mgr"
143
144    fuzz_config_file = "${screenlock_mgr_path}/test/fuzztest/screenlockservice_fuzzer/${item.configFuzzer}"
145
146    include_dirs = [
147      "${screenlock_mgr_path}/frameworks/js/napi/include",
148      "${screenlock_mgr_path}/services/include",
149      "${screenlock_mgr_path}/utils/include",
150      "${screenlock_mgr_path}/test/fuzztest/screenlockservice_fuzzer/common",
151    ]
152
153    cflags = [
154      "-g",
155      "-O0",
156      "-Wno-unused-variable",
157      "-fno-omit-frame-pointer",
158    ]
159
160    deps = [
161      "${screenlock_mgr_path}/frameworks/js/napi:screenlock_static",
162      "${screenlock_mgr_path}/interfaces/inner_api:screenlock_client_static",
163      "${screenlock_mgr_path}/services:screenlock_server_static",
164      "${screenlock_mgr_path}/utils:screenlock_utils",
165    ]
166
167    external_deps = [
168      "ability_base:want",
169      "ability_runtime:ability_manager",
170      "access_token:libaccesstoken_sdk",
171      "access_token:libtokenid_sdk",
172      "c_utils:utils",
173      "ffrt:libffrt",
174      "hilog:libhilog",
175      "ipc:ipc_single",
176      "napi:ace_napi",
177      "os_account:os_account_innerkits",
178      "preferences:native_preferences",
179      "time_service:time_client",
180      "user_auth_framework:userauth_client",
181      "window_manager:libdm",
182    ]
183
184    sources = [
185      "common/screenlock_service_fuzz_utils.cpp",
186      item.source,
187    ]
188  }
189}
190
191###############################################################################
192group("fuzztest") {
193  testonly = true
194  deps = []
195  deps += [
196    # deps file
197    ":ScreenlockAuthManagerFuzzTest",
198    ":ScreenlockBoundaryCodeFuzzTest",
199    ":ScreenlockDumpFuzzTest",
200    ":ScreenlockGetAuthstateFuzzTest",
201    ":ScreenlockGetStrongStateFuzzTest",
202    ":ScreenlockIsScreenlockedFuzzTest",
203    ":ScreenlockIsSecureModeFuzzTest",
204    ":ScreenlockIsdisabledFuzzTest",
205    ":ScreenlockIslockedFuzzTest",
206    ":ScreenlockLockFuzzTest",
207    ":ScreenlockLockScreenFuzzTest",
208    ":ScreenlockOnSystemEventFuzzTest",
209    ":ScreenlockRequestStrongFuzzTest",
210    ":ScreenlockSendScreenlockEventFuzzTest",
211    ":ScreenlockSetAuthstateFuzzTest",
212    ":ScreenlockSetdisabledFuzzTest",
213    ":ScreenlockUnlockFuzzTest",
214    ":ScreenlockUnlockScreenFuzzTest",
215    ":ScreenlockUtilsFuzzTest",
216  ]
217}
218###############################################################################
219