1# Copyright (c) 2022-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/test.gni") 17import("//foundation/communication/netmanager_ext/netmanager_ext_config.gni") 18##############################fuzztest########################################## 19EXT_SECURITY_PATH = "../../.." 20 21ohos_fuzztest("NetShareClientFuzzTest") { 22 module_out_path = fuzz_test_path 23 fuzz_config_file = "$NETMANAGER_EXT_ROOT/test/networksharemanager/fuzztest/netshareclient_fuzzer" 24 _cfi_blocklist_path = "$NETMANAGER_EXT_ROOT/test/networksharemanager/fuzztest/netshareclient_fuzzer/cfi_blocklist.txt" 25 26 include_dirs = [ 27 "$EXT_INNERKITS_ROOT/ethernetclient/include", 28 "$EXT_INNERKITS_ROOT/netshareclient/include", 29 "$EXT_INNERKITS_ROOT/netshareclient/include/proxy", 30 "$EXT_INNERKITS_ROOT/netshareclient/include/proxy/ipccallback", 31 "$EXT_INNERKITS_ROOT/include", 32 "$EXT_INNERKITS_ROOT/include/proxy", 33 "$EXT_SECURITY_PATH/security", 34 "$NETMANAGER_EXT_ROOT/utils/log/include", 35 "$NETWORKSHAREMANAGER_SOURCE_DIR/include", 36 "$NETWORKSHAREMANAGER_SOURCE_DIR/include/stub", 37 "$NETWORKSHAREMANAGER_UTILS_DIR/event_report/include", 38 ] 39 40 cflags = [ 41 "-g", 42 "-O0", 43 "-Wno-unused-variable", 44 "-fno-omit-frame-pointer", 45 ] 46 47 if (!(use_libfuzzer || use_clang_coverage)) { 48 cflags += [ 49 "-flto", 50 "-fsanitize=cfi", 51 "-fsanitize-cfi-cross-dso", 52 "-fvisibility=hidden", 53 "-fsanitize-blacklist=" + 54 rebase_path(_cfi_blocklist_path, root_build_dir), 55 ] 56 } 57 58 ldflags = [] 59 if (!(use_libfuzzer || use_clang_coverage)) { 60 ldflags += [ 61 "-flto", 62 "-fsanitize=cfi", 63 "-fsanitize-cfi-cross-dso", 64 ] 65 } 66 67 sources = [ 68 "$EXT_SECURITY_PATH/security/netmanager_ext_test_security.cpp", 69 "netshare_client_fuzzer.cpp", 70 ] 71 72 deps = [ 73 "$NETMANAGER_EXT_ROOT/services/networksharemanager:net_tether_manager_static", 74 ] 75 deps += 76 [ "$EXT_INNERKITS_ROOT/netshareclient:netshare_service_interface_stub" ] 77 external_deps = [ 78 "access_token:libaccesstoken_sdk", 79 "access_token:libnativetoken_shared", 80 "access_token:libtoken_setproc", 81 "bluetooth:btframework", 82 "c_utils:utils", 83 "common_event_service:cesfwk_innerkits", 84 "dhcp:dhcp_sdk", 85 "eventhandler:libeventhandler", 86 "ffrt:libffrt", 87 "hicollie:libhicollie", 88 "hilog:libhilog", 89 "hisysevent:libhisysevent", 90 "ipc:ipc_core", 91 "netmanager_base:netsys_controller", 92 "netmanager_base:net_conn_manager_if", 93 "netmanager_base:net_manager_common", 94 "safwk:system_ability_fwk", 95 ] 96 97 external_deps += [ "samgr:samgr_proxy" ] 98 99 defines = [] 100 101 if (communication_wifi_switch_enable) { 102 defines += [ "WIFI_MODOULE" ] 103 external_deps += [ "wifi:wifi_sdk" ] 104 } 105 106 defines += [ 107 "NETMGR_LOG_TAG = \"NetShareManager\"", 108 "LOG_DOMAIN = 0xD0015B0", 109 ] 110 111 if (communication_bluetooth_switch_enable) { 112 defines += [ "BLUETOOTH_MODOULE=1" ] 113 external_deps += [ "bluetooth:btframework" ] 114 } 115} 116 117############################################################################### 118group("fuzztest") { 119 testonly = true 120 121 deps = [ ":NetShareClientFuzzTest" ] 122} 123############################################################################### 124