1# Copyright (c) 2021-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("NetStatsClientFuzzTest") {
22  module_out_path = fuzz_test_path
23  fuzz_config_file = "$NETMANAGER_BASE_ROOT/test/fuzztest/netstatsclient_fuzzer"
24  _cfi_blocklist_path = "$NETMANAGER_BASE_ROOT/test/fuzztest/netstatsclient_fuzzer/cfi_blocklist.txt"
25
26  include_dirs = [
27    "$INNERKITS_ROOT/netstatsclient/include",
28    "$NETCONNMANAGER_COMMON_DIR/include",
29    "$NETSTATSMANAGER_SOURCE_DIR/include/stub",
30    "$NETSTATSMANAGER_SOURCE_DIR/include",
31    "$NETSYSCONTROLLER_ROOT_DIR/include",
32    "$NETSYSNATIVE_SOURCE_DIR/include/manager",
33    "$NETSYSNATIVE_SOURCE_DIR/include/netsys/wrapper",
34    "$NETMANAGERNATIVE_ROOT/netsys_bpf_map/include",
35  ]
36
37  cflags = [
38    "-g",
39    "-O0",
40    "-Wno-unused-variable",
41    "-fno-omit-frame-pointer",
42    "-flto",
43    "-fsanitize=cfi",
44    "-fsanitize-cfi-cross-dso",
45    "-fvisibility=hidden",
46    "-fsanitize-blacklist=" + rebase_path(_cfi_blocklist_path, root_build_dir),
47  ]
48
49  ldflags = [
50    "-flto",
51    "-fsanitize=cfi",
52    "-fsanitize-cfi-cross-dso",
53  ]
54
55  sources = [
56    "mock_net_permission.cpp",
57    "net_stats_client_fuzzer.cpp",
58  ]
59
60  deps = [
61    "$INNERKITS_ROOT/netstatsclient:net_stats_manager_if",
62    "$NETMANAGER_BASE_ROOT/services/netstatsmanager:net_stats_manager_static",
63    "$NETMANAGER_BASE_ROOT/utils:net_manager_common",
64    "$NETSYSCONTROLLER_ROOT_DIR:netsys_controller",
65  ]
66
67  defines = [
68    "HI_LOG_ENABLE",
69    "DH_LOG_TAG=\"NetStatsClientFuzzTest\"",
70    "LOG_DOMAIN=0xD004100",
71  ]
72
73  external_deps = [
74    "bundle_framework:appexecfwk_base",
75    "bundle_framework:appexecfwk_core",
76    "c_utils:utils",
77    "eventhandler:libeventhandler",
78    "ffrt:libffrt",
79    "hilog:libhilog",
80    "init:libbegetutil",
81    "ipc:ipc_core",
82    "ipc:ipc_core",
83    "safwk:system_ability_fwk",
84    "samgr:samgr_proxy",
85  ]
86}
87
88###############################################################################
89group("fuzztest") {
90  testonly = true
91
92  deps = [ ":NetStatsClientFuzzTest" ]
93}
94
95###############################################################################
96
97