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 "$NETSYSCONTROLLER_ROOT_DIR/include", 39 ] 40 41 if (communication_wifi_switch_enable) { 42 include_dirs += [ 43 "$WIFI_MANAGER_ROOT/interfaces/kits/c", 44 "$WIFI_MANAGER_ROOT/frameworks/native/interfaces", 45 ] 46 } 47 48 cflags = [ 49 "-g", 50 "-O0", 51 "-Wno-unused-variable", 52 "-fno-omit-frame-pointer", 53 ] 54 55 if (!(use_libfuzzer || use_clang_coverage)) { 56 cflags += [ 57 "-flto", 58 "-fsanitize=cfi", 59 "-fsanitize-cfi-cross-dso", 60 "-fvisibility=hidden", 61 "-fsanitize-blacklist=" + 62 rebase_path(_cfi_blocklist_path, root_build_dir), 63 ] 64 } 65 66 ldflags = [] 67 if (!(use_libfuzzer || use_clang_coverage)) { 68 ldflags += [ 69 "-flto", 70 "-fsanitize=cfi", 71 "-fsanitize-cfi-cross-dso", 72 ] 73 } 74 75 sources = [ 76 "$EXT_SECURITY_PATH/security/netmanager_ext_test_security.cpp", 77 "netshare_client_fuzzer.cpp", 78 ] 79 80 deps = [ 81 "$NETMANAGER_EXT_ROOT/services/networksharemanager:net_tether_manager_static", 82 "$NETSYSCONTROLLER_ROOT_DIR:netsys_controller", 83 ] 84 85 external_deps = [ 86 "access_token:libaccesstoken_sdk", 87 "access_token:libnativetoken", 88 "access_token:libtoken_setproc", 89 "bluetooth:btframework", 90 "c_utils:utils", 91 "common_event_service:cesfwk_innerkits", 92 "dhcp:dhcp_sdk", 93 "ffrt:libffrt", 94 "hicollie:libhicollie", 95 "hilog:libhilog", 96 "hisysevent:libhisysevent", 97 "ipc:ipc_core", 98 "netmanager_base:net_conn_manager_if", 99 "netmanager_base:net_manager_common", 100 "safwk:system_ability_fwk", 101 ] 102 103 defines = [] 104 105 if (communication_wifi_switch_enable) { 106 defines += [ "WIFI_MODOULE" ] 107 external_deps += [ "wifi:wifi_sdk" ] 108 } 109 110 defines += [ 111 "NETMGR_LOG_TAG = \"NetShareManager\"", 112 "LOG_DOMAIN = 0xD0015B0", 113 ] 114 115 if (communication_bluetooth_switch_enable) { 116 defines += [ "BLUETOOTH_MODOULE=1" ] 117 external_deps += [ "bluetooth:btframework" ] 118 } 119} 120 121############################################################################### 122group("fuzztest") { 123 testonly = true 124 125 deps = [ ":NetShareClientFuzzTest" ] 126} 127############################################################################### 128