1# Copyright (c) 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 14#####################hydra-fuzz################### 15import("//build/config/features.gni") 16import("//build/ohos.gni") 17import("//build/test.gni") 18import("../../../services/samgr/var.gni") 19module_output_path = "samgr/samgr" 20samgr_dir = "../../../" 21samgr_services_dir = "${samgr_dir}/services/samgr/native" 22 23config("sam_fuzz_test_config") { 24 include_dirs = [ 25 "${samgr_dir}/services/dfx/include", 26 "${samgr_dir}/services/lsamgr/include", 27 "${samgr_dir}/services/samgr/native/test/unittest/include", 28 "${samgr_dir}/test/fuzztest/samgr_fuzzer/include", 29 ] 30} 31 32##############################fuzztest########################################## 33cancelunloadsystemability_test = { 34 targetName = "CancelUnloadSystemAbilityFuzzTest" 35 configFuzzer = "cancelunloadsystemability_fuzzer" 36 source = "src/cancelunloadsystemability_fuzzer.cpp" 37} 38 39checkremotesystemability_test = { 40 targetName = "CheckRemoteSystemAbilityFuzzTest" 41 configFuzzer = "checkremotesystemability_fuzzer" 42 source = "src/checkremotesystemability_fuzzer.cpp" 43} 44 45getextensionsaids_test = { 46 targetName = "GetExtensionSaIdsFuzzTest" 47 configFuzzer = "getextensionsaids_fuzzer" 48 source = "src/getextensionsaids_fuzzer.cpp" 49} 50 51getextensionsalist_test = { 52 targetName = "GetExtensionSaListFuzzTest" 53 configFuzzer = "getextensionsalist_fuzzer" 54 source = "src/getextensionsalist_fuzzer.cpp" 55} 56 57getondemandpolicy_test = { 58 targetName = "GetOnDemandPolicyFuzzTest" 59 configFuzzer = "getondemandpolicy_fuzzer" 60 source = "src/getondemandpolicy_fuzzer.cpp" 61} 62 63getsystemability_test = { 64 targetName = "GetSystemAbilityFuzzTest" 65 configFuzzer = "getsystemability_fuzzer" 66 source = "src/getsystemability_fuzzer.cpp" 67} 68 69getsaextensioninfo_test = { 70 targetName = "GetSaExtensionInfoFuzzTest" 71 configFuzzer = "getsaextensioninfo_fuzzer" 72 source = "src/getsaextensioninfo_fuzzer.cpp" 73} 74 75loadremotesystemability_test = { 76 targetName = "LoadRemoteSystemAbilityFuzzTest" 77 configFuzzer = "loadremotesystemability_fuzzer" 78 source = "src/loadremotesystemability_fuzzer.cpp" 79} 80 81unloadallidlesystemability_test = { 82 targetName = "UnloadAllIdleSystemAbilityFuzzTest" 83 configFuzzer = "unloadallidlesystemability_fuzzer" 84 source = "src/unloadallidlesystemability_fuzzer.cpp" 85} 86 87unsubscribesystemprocess_test = { 88 targetName = "UnSubscribeSystemProcessFuzzTest" 89 configFuzzer = "unsubscribesystemprocess_fuzzer" 90 source = "src/unsubscribesystemprocess_fuzzer.cpp" 91} 92 93unsubscribesystemability_test = { 94 targetName = "UnSubscribeSystemAbilityFuzzTest" 95 configFuzzer = "unsubscribesystemability_fuzzer" 96 source = "src/unsubscribesystemability_fuzzer.cpp" 97} 98 99addsystemability_test = { 100 targetName = "AddSystemAbilityFuzzTest" 101 configFuzzer = "addsystemability_fuzzer" 102 source = "src/addsystemability_fuzzer.cpp" 103} 104 105addsystemprocess_test = { 106 targetName = "AddSystemProcessFuzzTest" 107 configFuzzer = "addsystemprocess_fuzzer" 108 source = "src/addsystemprocess_fuzzer.cpp" 109} 110 111samgr_fuzztests = [ 112 cancelunloadsystemability_test, 113 checkremotesystemability_test, 114 getextensionsaids_test, 115 getextensionsalist_test, 116 getondemandpolicy_test, 117 getsystemability_test, 118 getsaextensioninfo_test, 119 loadremotesystemability_test, 120 unloadallidlesystemability_test, 121 unsubscribesystemprocess_test, 122 unsubscribesystemability_test, 123 addsystemability_test, 124 addsystemprocess_test, 125] 126foreach(item, samgr_fuzztests) { 127 ohos_fuzztest(item.targetName) { 128 module_out_path = module_output_path 129 130 fuzz_config_file = 131 "${samgr_dir}/test/fuzztest/samgr_fuzzer/project/${item.configFuzzer}" 132 133 configs = [ 134 ":sam_fuzz_test_config", 135 "${samgr_dir}/services/samgr/native:sam_config", 136 "${samgr_dir}/test/resource:coverage_flags", 137 ] 138 139 cflags = [ 140 "-g", 141 "-O0", 142 "-Wno-unused-variable", 143 "-fno-omit-frame-pointer", 144 ] 145 sources = [ 146 "${samgr_dir}/services/dfx/source/hisysevent_adapter.cpp", 147 "${samgr_dir}/utils/native/source/tools.cpp", 148 "${samgr_services_dir}/source/ability_death_recipient.cpp", 149 "${samgr_services_dir}/source/collect/device_param_collect.cpp", 150 "${samgr_services_dir}/source/collect/device_status_collect_manager.cpp", 151 "${samgr_services_dir}/source/collect/device_timed_collect.cpp", 152 "${samgr_services_dir}/source/collect/icollect_plugin.cpp", 153 "${samgr_services_dir}/source/ffrt_handler.cpp", 154 "${samgr_services_dir}/source/memory_guard.cpp", 155 "${samgr_services_dir}/source/rpc_callback_imp.cpp", 156 "${samgr_services_dir}/source/samgr_time_handler.cpp", 157 "${samgr_services_dir}/source/schedule/system_ability_event_handler.cpp", 158 "${samgr_services_dir}/source/schedule/system_ability_state_machine.cpp", 159 "${samgr_services_dir}/source/schedule/system_ability_state_scheduler.cpp", 160 "${samgr_services_dir}/source/system_ability_manager.cpp", 161 "${samgr_services_dir}/source/system_ability_manager_dumper.cpp", 162 "${samgr_services_dir}/source/system_ability_manager_stub.cpp", 163 "${samgr_services_dir}/source/system_ability_manager_util.cpp", 164 "${samgr_services_dir}/test/unittest/src/mock_accesstoken_kit.cpp", 165 "${samgr_services_dir}/test/unittest/src/mock_permission.cpp", 166 "src/fuzztest_utils.cpp", 167 item.source, 168 ] 169 deps = [] 170 171 external_deps = [ 172 "access_token:libaccesstoken_sdk", 173 "access_token:libnativetoken_shared", 174 "access_token:libtokensetproc_shared", 175 "c_utils:utils", 176 "eventhandler:libeventhandler", 177 "ffrt:libffrt", 178 "hilog:libhilog", 179 "hisysevent:libhisysevent", 180 "hitrace:hitrace_meter", 181 "init:libbeget_proxy", 182 "init:libbegetutil", 183 "ipc:ipc_core", 184 "ipc:libdbinder", 185 "safwk:system_ability_fwk", 186 "samgr:samgr_common", 187 "samgr:samgr_proxy", 188 ] 189 defines = [] 190 if (hicollie_able) { 191 external_deps += [ "hicollie:libhicollie" ] 192 defines += [ "HICOLLIE_ENABLE" ] 193 } 194 195 if (support_device_manager) { 196 sources += [ 197 "${samgr_services_dir}/source/collect/device_networking_collect.cpp", 198 ] 199 external_deps += [ "device_manager:devicemanagersdk" ] 200 defines += [ "SUPPORT_DEVICE_MANAGER" ] 201 } 202 } 203} 204 205############################################################################### 206group("fuzztest") { 207 testonly = true 208 deps = [] 209 deps += [ 210 # deps file 211 ":AddSystemAbilityFuzzTest", 212 ":AddSystemProcessFuzzTest", 213 ":CancelUnloadSystemAbilityFuzzTest", 214 ":CheckRemoteSystemAbilityFuzzTest", 215 ":GetExtensionSaIdsFuzzTest", 216 ":GetExtensionSaListFuzzTest", 217 ":GetOnDemandPolicyFuzzTest", 218 ":GetSaExtensionInfoFuzzTest", 219 ":GetSystemAbilityFuzzTest", 220 ":LoadRemoteSystemAbilityFuzzTest", 221 ":UnSubscribeSystemAbilityFuzzTest", 222 ":UnSubscribeSystemProcessFuzzTest", 223 ":UnloadAllIdleSystemAbilityFuzzTest", 224 ] 225} 226############################################################################### 227