1# Copyright (c) 2023 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
14#####################hydra-fuzz###################
15import("//build/config/features.gni")
16import("//build/ohos.gni")
17import("//build/test.gni")
18import("../../../time.gni")
19
20##############################fuzztest##########################################
21timeboundarycode_test = {
22  targetName = "TimeBoundaryCodeFuzzTest"
23  configFuzzer = "timeboundarycode_fuzzer"
24  source = "timeboundarycode_fuzzer/timeboundarycode_fuzzer.cpp"
25}
26timecreatetimer_test = {
27  targetName = "TimeCreateTimerFuzzTest"
28  configFuzzer = "timecreatetimer_fuzzer"
29  source = "timecreatetimer_fuzzer/timecreatetimer_fuzzer.cpp"
30}
31timedestroytimer_test = {
32  targetName = "TimeDestroyTimerFuzzTest"
33  configFuzzer = "timedestroytimer_fuzzer"
34  source = "timedestroytimer_fuzzer/timedestroytimer_fuzzer.cpp"
35}
36timegetthreadtimemilli_test = {
37  targetName = "TimeGetThreadTimeMilliFuzzTest"
38  configFuzzer = "timegetthreadtimemilli_fuzzer"
39  source = "timegetthreadtimemilli_fuzzer/timegetthreadtimemilli_fuzzer.cpp"
40}
41timegetthreadtimenano_test = {
42  targetName = "TimeGetThreadTimeNanoFuzzTest"
43  configFuzzer = "timegetthreadtimenano_fuzzer"
44  source = "timegetthreadtimenano_fuzzer/timegetthreadtimenano_fuzzer.cpp"
45}
46timegettimezone_test = {
47  targetName = "TimeGetTimeZoneFuzzTest"
48  configFuzzer = "timegettimezone_fuzzer"
49  source = "timegettimezone_fuzzer/timegettimezone_fuzzer.cpp"
50}
51timereceivedmessage_test = {
52  targetName = "TimeReceivedMessageFuzzTest"
53  configFuzzer = "timereceivedmessage_fuzzer"
54  source = "timereceivedmessage_fuzzer/timereceivedmessage_fuzzer.cpp"
55}
56timeservicesettimezone_test = {
57  targetName = "TimeServiceSetTimeZoneFuzzTest"
58  configFuzzer = "timeservicesettimezone_fuzzer"
59  source = "timeservicesettimezone_fuzzer/timeservicesettimezone_fuzzer.cpp"
60}
61timestarttimer_test = {
62  targetName = "TimeStartTimerFuzzTest"
63  configFuzzer = "timestarttimer_fuzzer"
64  source = "timestarttimer_fuzzer/timestarttimer_fuzzer.cpp"
65}
66timestoptimer_test = {
67  targetName = "TimeStopTimerFuzzTest"
68  configFuzzer = "timestoptimer_fuzzer"
69  source = "timestoptimer_fuzzer/timestoptimer_fuzzer.cpp"
70}
71timerproxy_test = {
72  targetName = "TimerProxyFuzzTest"
73  configFuzzer = "timerproxy_fuzzer"
74  source = "timerproxy_fuzzer/timerproxy_fuzzer.cpp"
75}
76timesntp_test = {
77  targetName = "TimeSntpFuzzTest"
78  configFuzzer = "timesntp_fuzzer"
79  source = "timesntp_fuzzer/timesntp_fuzzer.cpp"
80}
81
82time_fuzztests = [
83  timeboundarycode_test,
84  timecreatetimer_test,
85  timedestroytimer_test,
86  timegetthreadtimemilli_test,
87  timegetthreadtimenano_test,
88  timegettimezone_test,
89  timereceivedmessage_test,
90  timeservicesettimezone_test,
91  timestarttimer_test,
92  timestoptimer_test,
93  timerproxy_test,
94  timesntp_test,
95]
96
97foreach(item, time_fuzztests) {
98  ohos_fuzztest(item.targetName) {
99    module_out_path = "time_service/time"
100
101    fuzz_config_file = "${time_root_path}/test/fuzztest/timeservice_fuzzer/${item.configFuzzer}"
102
103    include_dirs = [
104      "${time_service_path}",
105      "${time_service_path}/dfx/include",
106      "${time_service_path}/time/include",
107      "${time_utils_path}/native/include",
108      "${time_service_path}/ipc/stub",
109      "${time_service_path}/ipc/base",
110      "${api_path}/include",
111      "${time_service_path}/timer/include",
112      "${time_root_path}/test/fuzztest/timeservice_fuzzer/common",
113    ]
114
115    cflags = [
116      "-g",
117      "-O0",
118      "-Wno-unused-variable",
119      "-fno-omit-frame-pointer",
120    ]
121
122    sources = [
123      "common/time_service_fuzz_utils.cpp",
124      item.source,
125    ]
126
127    deps = [ "${time_service_path}:time_system_ability_static" ]
128
129    external_deps = [
130      "ability_base:want",
131      "ability_runtime:wantagent_innerkits",
132      "access_token:libaccesstoken_sdk",
133      "access_token:libnativetoken",
134      "access_token:libtoken_setproc",
135      "bundle_framework:appexecfwk_core",
136      "c_utils:utils",
137      "common_event_service:cesfwk_innerkits",
138      "hilog:libhilog",
139      "init:libbegetutil",
140      "ipc:ipc_single",
141      "power_manager:powermgr_client",
142      "relational_store:native_dataability",
143      "relational_store:native_rdb",
144      "safwk:system_ability_fwk",
145      "samgr:samgr_proxy",
146    ]
147  }
148}
149
150###############################################################################
151group("fuzztest") {
152  testonly = true
153  deps = []
154  deps += [
155    # deps file
156    ":TimeBoundaryCodeFuzzTest",
157    ":TimeCreateTimerFuzzTest",
158    ":TimeDestroyTimerFuzzTest",
159    ":TimeGetThreadTimeMilliFuzzTest",
160    ":TimeGetThreadTimeNanoFuzzTest",
161    ":TimeGetTimeZoneFuzzTest",
162    ":TimeReceivedMessageFuzzTest",
163    ":TimeServiceSetTimeZoneFuzzTest",
164    ":TimeSntpFuzzTest",
165    ":TimeStartTimerFuzzTest",
166    ":TimeStopTimerFuzzTest",
167    ":TimerProxyFuzzTest",
168  ]
169}
170###############################################################################
171