15ba71b47Sopenharmony_ci# Copyright (c) 2024 Huawei Device Co., Ltd. 25ba71b47Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 35ba71b47Sopenharmony_ci# you may not use this file except in compliance with the License. 45ba71b47Sopenharmony_ci# You may obtain a copy of the License at 55ba71b47Sopenharmony_ci# 65ba71b47Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 75ba71b47Sopenharmony_ci# 85ba71b47Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 95ba71b47Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 105ba71b47Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 115ba71b47Sopenharmony_ci# See the License for the specific language governing permissions and 125ba71b47Sopenharmony_ci# limitations under the License. 135ba71b47Sopenharmony_ci 145ba71b47Sopenharmony_ci#####################hydra-fuzz################### 155ba71b47Sopenharmony_ciimport("//build/config/features.gni") 165ba71b47Sopenharmony_ciimport("//build/ohos.gni") 175ba71b47Sopenharmony_ciimport("//build/test.gni") 185ba71b47Sopenharmony_ciimport("../../../services/samgr/var.gni") 195ba71b47Sopenharmony_cimodule_output_path = "samgr/samgr" 205ba71b47Sopenharmony_cisamgr_dir = "../../../" 215ba71b47Sopenharmony_cisamgr_services_dir = "${samgr_dir}/services/samgr/native" 225ba71b47Sopenharmony_ci 235ba71b47Sopenharmony_ciconfig("sam_fuzz_test_config") { 245ba71b47Sopenharmony_ci include_dirs = [ 255ba71b47Sopenharmony_ci "${samgr_dir}/services/dfx/include", 265ba71b47Sopenharmony_ci "${samgr_dir}/services/lsamgr/include", 275ba71b47Sopenharmony_ci "${samgr_dir}/services/samgr/native/test/unittest/include", 285ba71b47Sopenharmony_ci "${samgr_dir}/test/fuzztest/samgr_fuzzer/include", 295ba71b47Sopenharmony_ci ] 305ba71b47Sopenharmony_ci} 315ba71b47Sopenharmony_ci 325ba71b47Sopenharmony_ci##############################fuzztest########################################## 335ba71b47Sopenharmony_cicancelunloadsystemability_test = { 345ba71b47Sopenharmony_ci targetName = "CancelUnloadSystemAbilityFuzzTest" 355ba71b47Sopenharmony_ci configFuzzer = "cancelunloadsystemability_fuzzer" 365ba71b47Sopenharmony_ci source = "src/cancelunloadsystemability_fuzzer.cpp" 375ba71b47Sopenharmony_ci} 385ba71b47Sopenharmony_ci 395ba71b47Sopenharmony_cicheckremotesystemability_test = { 405ba71b47Sopenharmony_ci targetName = "CheckRemoteSystemAbilityFuzzTest" 415ba71b47Sopenharmony_ci configFuzzer = "checkremotesystemability_fuzzer" 425ba71b47Sopenharmony_ci source = "src/checkremotesystemability_fuzzer.cpp" 435ba71b47Sopenharmony_ci} 445ba71b47Sopenharmony_ci 455ba71b47Sopenharmony_cigetextensionsaids_test = { 465ba71b47Sopenharmony_ci targetName = "GetExtensionSaIdsFuzzTest" 475ba71b47Sopenharmony_ci configFuzzer = "getextensionsaids_fuzzer" 485ba71b47Sopenharmony_ci source = "src/getextensionsaids_fuzzer.cpp" 495ba71b47Sopenharmony_ci} 505ba71b47Sopenharmony_ci 515ba71b47Sopenharmony_cigetextensionsalist_test = { 525ba71b47Sopenharmony_ci targetName = "GetExtensionSaListFuzzTest" 535ba71b47Sopenharmony_ci configFuzzer = "getextensionsalist_fuzzer" 545ba71b47Sopenharmony_ci source = "src/getextensionsalist_fuzzer.cpp" 555ba71b47Sopenharmony_ci} 565ba71b47Sopenharmony_ci 575ba71b47Sopenharmony_cigetondemandpolicy_test = { 585ba71b47Sopenharmony_ci targetName = "GetOnDemandPolicyFuzzTest" 595ba71b47Sopenharmony_ci configFuzzer = "getondemandpolicy_fuzzer" 605ba71b47Sopenharmony_ci source = "src/getondemandpolicy_fuzzer.cpp" 615ba71b47Sopenharmony_ci} 625ba71b47Sopenharmony_ci 635ba71b47Sopenharmony_cigetsystemability_test = { 645ba71b47Sopenharmony_ci targetName = "GetSystemAbilityFuzzTest" 655ba71b47Sopenharmony_ci configFuzzer = "getsystemability_fuzzer" 665ba71b47Sopenharmony_ci source = "src/getsystemability_fuzzer.cpp" 675ba71b47Sopenharmony_ci} 685ba71b47Sopenharmony_ci 695ba71b47Sopenharmony_cigetsaextensioninfo_test = { 705ba71b47Sopenharmony_ci targetName = "GetSaExtensionInfoFuzzTest" 715ba71b47Sopenharmony_ci configFuzzer = "getsaextensioninfo_fuzzer" 725ba71b47Sopenharmony_ci source = "src/getsaextensioninfo_fuzzer.cpp" 735ba71b47Sopenharmony_ci} 745ba71b47Sopenharmony_ci 755ba71b47Sopenharmony_ciloadremotesystemability_test = { 765ba71b47Sopenharmony_ci targetName = "LoadRemoteSystemAbilityFuzzTest" 775ba71b47Sopenharmony_ci configFuzzer = "loadremotesystemability_fuzzer" 785ba71b47Sopenharmony_ci source = "src/loadremotesystemability_fuzzer.cpp" 795ba71b47Sopenharmony_ci} 805ba71b47Sopenharmony_ci 815ba71b47Sopenharmony_ciunloadallidlesystemability_test = { 825ba71b47Sopenharmony_ci targetName = "UnloadAllIdleSystemAbilityFuzzTest" 835ba71b47Sopenharmony_ci configFuzzer = "unloadallidlesystemability_fuzzer" 845ba71b47Sopenharmony_ci source = "src/unloadallidlesystemability_fuzzer.cpp" 855ba71b47Sopenharmony_ci} 865ba71b47Sopenharmony_ci 875ba71b47Sopenharmony_ciunsubscribesystemprocess_test = { 885ba71b47Sopenharmony_ci targetName = "UnSubscribeSystemProcessFuzzTest" 895ba71b47Sopenharmony_ci configFuzzer = "unsubscribesystemprocess_fuzzer" 905ba71b47Sopenharmony_ci source = "src/unsubscribesystemprocess_fuzzer.cpp" 915ba71b47Sopenharmony_ci} 925ba71b47Sopenharmony_ci 935ba71b47Sopenharmony_ciunsubscribesystemability_test = { 945ba71b47Sopenharmony_ci targetName = "UnSubscribeSystemAbilityFuzzTest" 955ba71b47Sopenharmony_ci configFuzzer = "unsubscribesystemability_fuzzer" 965ba71b47Sopenharmony_ci source = "src/unsubscribesystemability_fuzzer.cpp" 975ba71b47Sopenharmony_ci} 985ba71b47Sopenharmony_ci 995ba71b47Sopenharmony_ciaddsystemability_test = { 1005ba71b47Sopenharmony_ci targetName = "AddSystemAbilityFuzzTest" 1015ba71b47Sopenharmony_ci configFuzzer = "addsystemability_fuzzer" 1025ba71b47Sopenharmony_ci source = "src/addsystemability_fuzzer.cpp" 1035ba71b47Sopenharmony_ci} 1045ba71b47Sopenharmony_ci 1055ba71b47Sopenharmony_ciaddsystemprocess_test = { 1065ba71b47Sopenharmony_ci targetName = "AddSystemProcessFuzzTest" 1075ba71b47Sopenharmony_ci configFuzzer = "addsystemprocess_fuzzer" 1085ba71b47Sopenharmony_ci source = "src/addsystemprocess_fuzzer.cpp" 1095ba71b47Sopenharmony_ci} 1105ba71b47Sopenharmony_ci 1115ba71b47Sopenharmony_cisamgr_fuzztests = [ 1125ba71b47Sopenharmony_ci cancelunloadsystemability_test, 1135ba71b47Sopenharmony_ci checkremotesystemability_test, 1145ba71b47Sopenharmony_ci getextensionsaids_test, 1155ba71b47Sopenharmony_ci getextensionsalist_test, 1165ba71b47Sopenharmony_ci getondemandpolicy_test, 1175ba71b47Sopenharmony_ci getsystemability_test, 1185ba71b47Sopenharmony_ci getsaextensioninfo_test, 1195ba71b47Sopenharmony_ci loadremotesystemability_test, 1205ba71b47Sopenharmony_ci unloadallidlesystemability_test, 1215ba71b47Sopenharmony_ci unsubscribesystemprocess_test, 1225ba71b47Sopenharmony_ci unsubscribesystemability_test, 1235ba71b47Sopenharmony_ci addsystemability_test, 1245ba71b47Sopenharmony_ci addsystemprocess_test, 1255ba71b47Sopenharmony_ci] 1265ba71b47Sopenharmony_ciforeach(item, samgr_fuzztests) { 1275ba71b47Sopenharmony_ci ohos_fuzztest(item.targetName) { 1285ba71b47Sopenharmony_ci module_out_path = module_output_path 1295ba71b47Sopenharmony_ci 1305ba71b47Sopenharmony_ci fuzz_config_file = 1315ba71b47Sopenharmony_ci "${samgr_dir}/test/fuzztest/samgr_fuzzer/project/${item.configFuzzer}" 1325ba71b47Sopenharmony_ci 1335ba71b47Sopenharmony_ci configs = [ 1345ba71b47Sopenharmony_ci ":sam_fuzz_test_config", 1355ba71b47Sopenharmony_ci "${samgr_dir}/services/samgr/native:sam_config", 1365ba71b47Sopenharmony_ci "${samgr_dir}/test/resource:coverage_flags", 1375ba71b47Sopenharmony_ci ] 1385ba71b47Sopenharmony_ci 1395ba71b47Sopenharmony_ci cflags = [ 1405ba71b47Sopenharmony_ci "-g", 1415ba71b47Sopenharmony_ci "-O0", 1425ba71b47Sopenharmony_ci "-Wno-unused-variable", 1435ba71b47Sopenharmony_ci "-fno-omit-frame-pointer", 1445ba71b47Sopenharmony_ci ] 1455ba71b47Sopenharmony_ci sources = [ 1465ba71b47Sopenharmony_ci "${samgr_dir}/services/dfx/source/hisysevent_adapter.cpp", 1475ba71b47Sopenharmony_ci "${samgr_dir}/utils/native/source/tools.cpp", 1485ba71b47Sopenharmony_ci "${samgr_services_dir}/source/ability_death_recipient.cpp", 1495ba71b47Sopenharmony_ci "${samgr_services_dir}/source/collect/device_param_collect.cpp", 1505ba71b47Sopenharmony_ci "${samgr_services_dir}/source/collect/device_status_collect_manager.cpp", 1515ba71b47Sopenharmony_ci "${samgr_services_dir}/source/collect/device_timed_collect.cpp", 1525ba71b47Sopenharmony_ci "${samgr_services_dir}/source/collect/icollect_plugin.cpp", 1535ba71b47Sopenharmony_ci "${samgr_services_dir}/source/collect/ref_count_collect.cpp", 1545ba71b47Sopenharmony_ci "${samgr_services_dir}/source/ffrt_handler.cpp", 1555ba71b47Sopenharmony_ci "${samgr_services_dir}/source/memory_guard.cpp", 1565ba71b47Sopenharmony_ci "${samgr_services_dir}/source/rpc_callback_imp.cpp", 1575ba71b47Sopenharmony_ci "${samgr_services_dir}/source/samgr_time_handler.cpp", 1585ba71b47Sopenharmony_ci "${samgr_services_dir}/source/schedule/system_ability_event_handler.cpp", 1595ba71b47Sopenharmony_ci "${samgr_services_dir}/source/schedule/system_ability_state_machine.cpp", 1605ba71b47Sopenharmony_ci "${samgr_services_dir}/source/schedule/system_ability_state_scheduler.cpp", 1615ba71b47Sopenharmony_ci "${samgr_services_dir}/source/system_ability_manager.cpp", 1625ba71b47Sopenharmony_ci "${samgr_services_dir}/source/system_ability_manager_dumper.cpp", 1635ba71b47Sopenharmony_ci "${samgr_services_dir}/source/system_ability_manager_stub.cpp", 1645ba71b47Sopenharmony_ci "${samgr_services_dir}/source/system_ability_manager_util.cpp", 1655ba71b47Sopenharmony_ci "${samgr_services_dir}/test/unittest/src/mock_accesstoken_kit.cpp", 1665ba71b47Sopenharmony_ci "${samgr_services_dir}/test/unittest/src/mock_permission.cpp", 1675ba71b47Sopenharmony_ci "src/fuzztest_utils.cpp", 1685ba71b47Sopenharmony_ci item.source, 1695ba71b47Sopenharmony_ci ] 1705ba71b47Sopenharmony_ci deps = [] 1715ba71b47Sopenharmony_ci 1725ba71b47Sopenharmony_ci external_deps = [ 1735ba71b47Sopenharmony_ci "access_token:libaccesstoken_sdk", 1745ba71b47Sopenharmony_ci "access_token:libnativetoken_shared", 1755ba71b47Sopenharmony_ci "access_token:libtokensetproc_shared", 1765ba71b47Sopenharmony_ci "c_utils:utils", 1775ba71b47Sopenharmony_ci "eventhandler:libeventhandler", 1785ba71b47Sopenharmony_ci "ffrt:libffrt", 1795ba71b47Sopenharmony_ci "hilog:libhilog", 1805ba71b47Sopenharmony_ci "hisysevent:libhisysevent", 1815ba71b47Sopenharmony_ci "hitrace:hitrace_meter", 1825ba71b47Sopenharmony_ci "init:libbeget_proxy", 1835ba71b47Sopenharmony_ci "init:libbegetutil", 1845ba71b47Sopenharmony_ci "ipc:ipc_core", 1855ba71b47Sopenharmony_ci "ipc:libdbinder", 1865ba71b47Sopenharmony_ci "safwk:system_ability_fwk", 1875ba71b47Sopenharmony_ci "samgr:samgr_common", 1885ba71b47Sopenharmony_ci "samgr:samgr_proxy", 1895ba71b47Sopenharmony_ci ] 1905ba71b47Sopenharmony_ci defines = [] 1915ba71b47Sopenharmony_ci if (hicollie_able) { 1925ba71b47Sopenharmony_ci external_deps += [ "hicollie:libhicollie" ] 1935ba71b47Sopenharmony_ci defines += [ "HICOLLIE_ENABLE" ] 1945ba71b47Sopenharmony_ci } 1955ba71b47Sopenharmony_ci 1965ba71b47Sopenharmony_ci if (support_device_manager) { 1975ba71b47Sopenharmony_ci sources += [ 1985ba71b47Sopenharmony_ci "${samgr_services_dir}/source/collect/device_networking_collect.cpp", 1995ba71b47Sopenharmony_ci ] 2005ba71b47Sopenharmony_ci external_deps += [ "device_manager:devicemanagersdk" ] 2015ba71b47Sopenharmony_ci defines += [ "SUPPORT_DEVICE_MANAGER" ] 2025ba71b47Sopenharmony_ci } 2035ba71b47Sopenharmony_ci } 2045ba71b47Sopenharmony_ci} 2055ba71b47Sopenharmony_ci 2065ba71b47Sopenharmony_ci############################################################################### 2075ba71b47Sopenharmony_cigroup("fuzztest") { 2085ba71b47Sopenharmony_ci testonly = true 2095ba71b47Sopenharmony_ci deps = [] 2105ba71b47Sopenharmony_ci deps += [ 2115ba71b47Sopenharmony_ci # deps file 2125ba71b47Sopenharmony_ci ":AddSystemAbilityFuzzTest", 2135ba71b47Sopenharmony_ci ":AddSystemProcessFuzzTest", 2145ba71b47Sopenharmony_ci ":CancelUnloadSystemAbilityFuzzTest", 2155ba71b47Sopenharmony_ci ":CheckRemoteSystemAbilityFuzzTest", 2165ba71b47Sopenharmony_ci ":GetExtensionSaIdsFuzzTest", 2175ba71b47Sopenharmony_ci ":GetExtensionSaListFuzzTest", 2185ba71b47Sopenharmony_ci ":GetOnDemandPolicyFuzzTest", 2195ba71b47Sopenharmony_ci ":GetSaExtensionInfoFuzzTest", 2205ba71b47Sopenharmony_ci ":GetSystemAbilityFuzzTest", 2215ba71b47Sopenharmony_ci ":LoadRemoteSystemAbilityFuzzTest", 2225ba71b47Sopenharmony_ci ":UnSubscribeSystemAbilityFuzzTest", 2235ba71b47Sopenharmony_ci ":UnSubscribeSystemProcessFuzzTest", 2245ba71b47Sopenharmony_ci ":UnloadAllIdleSystemAbilityFuzzTest", 2255ba71b47Sopenharmony_ci ] 2265ba71b47Sopenharmony_ci} 2275ba71b47Sopenharmony_ci############################################################################### 228