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 14import("//build/config/features.gni") 15 16#####################hydra-fuzz################### 17import("//build/test.gni") 18import("//foundation/communication/netmanager_base/netmanager_base_config.gni") 19 20##############################fuzztest########################################## 21ohos_fuzztest("NetSysClientNetDiagFuzzTest") { 22 module_out_path = fuzz_test_path 23 fuzz_config_file = 24 "$NETMANAGER_BASE_ROOT/test/fuzztest/netsysclientnetdiag_fuzzer" 25 _cfi_blocklist_path = "$NETMANAGER_BASE_ROOT/test/fuzztest/netsysclientnetdiag_fuzzer/cfi_blocklist.txt" 26 27 include_dirs = [ 28 "$NETCONNMANAGER_COMMON_DIR/include", 29 "$NETCONNMANAGER_SOURCE_DIR/include", 30 "$NETMANAGER_BASE_ROOT/services/netmanagernative/bpf/include", 31 "$NETMANAGER_BASE_ROOT/test/commonduplicatedcode", 32 "$NETMANAGER_BASE_ROOT/utils/log/include", 33 "$NETSYSNATIVE_INNERKITS_SOURCE_DIR", 34 "$INNERKITS_ROOT/netmanagernative/include", 35 "$NETSYSCONTROLLER_ROOT_DIR/include", 36 "$NETSYSNATIVE_SOURCE_DIR/include", 37 "$NETSYSNATIVE_SOURCE_DIR/include/manager", 38 "$NETSYSNATIVE_SOURCE_DIR/include/netsys", 39 "$NETSYSNATIVE_SOURCE_DIR/include/netsys/wrapper", 40 ] 41 42 cflags = [ 43 "-g", 44 "-O0", 45 "-Wno-unused-variable", 46 "-fno-omit-frame-pointer", 47 ] 48 49 if (!(use_libfuzzer || use_clang_coverage)) { 50 cflags += [ 51 "-flto", 52 "-fsanitize=cfi", 53 "-fsanitize-cfi-cross-dso", 54 "-fvisibility=hidden", 55 "-fsanitize-blacklist=" + 56 rebase_path(_cfi_blocklist_path, root_build_dir), 57 ] 58 } 59 60 ldflags = [] 61 if (!(use_libfuzzer || use_clang_coverage)) { 62 ldflags += [ 63 "-flto", 64 "-fsanitize=cfi", 65 "-fsanitize-cfi-cross-dso", 66 ] 67 } 68 69 sources = [ "net_sys_client_netdiag_fuzzer.cpp" ] 70 71 deps = [ 72 "$NETMANAGER_BASE_ROOT/services/netmanagernative:netsys_native_manager_static", 73 "$NETMANAGER_BASE_ROOT/services/netmanagernative/bpf:netsys_bpf_utils", 74 "$NETMANAGER_BASE_ROOT/utils:net_manager_common", 75 "$NETSYSCONTROLLER_ROOT_DIR:netsys_controller", 76 ] 77 78 defines = [ 79 "HI_LOG_ENABLE", 80 "DH_LOG_TAG=\"NetSysClientNetDiagFuzzTest\"", 81 "LOG_DOMAIN=0xD004100", 82 ] 83 84 external_deps = [ 85 "access_token:libaccesstoken_sdk", 86 "access_token:libnativetoken", 87 "access_token:libtoken_setproc", 88 "bundle_framework:appexecfwk_base", 89 "bundle_framework:appexecfwk_core", 90 "c_utils:utils", 91 "dhcp:dhcp_sdk", 92 "eventhandler:libeventhandler", 93 "ffrt:libffrt", 94 "hilog:libhilog", 95 "init:libbegetutil", 96 "ipc:ipc_core", 97 "safwk:system_ability_fwk", 98 "samgr:samgr_proxy", 99 ] 100} 101 102############################################################################### 103group("fuzztest") { 104 testonly = true 105 106 deps = [ ":NetSysClientNetDiagFuzzTest" ] 107} 108 109############################################################################### 110 111