1b1b8bc3fSopenharmony_ci# Copyright (c) 2022-2024 Huawei Device Co., Ltd.
2b1b8bc3fSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3b1b8bc3fSopenharmony_ci# you may not use this file except in compliance with the License.
4b1b8bc3fSopenharmony_ci# You may obtain a copy of the License at
5b1b8bc3fSopenharmony_ci#
6b1b8bc3fSopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
7b1b8bc3fSopenharmony_ci#
8b1b8bc3fSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9b1b8bc3fSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10b1b8bc3fSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11b1b8bc3fSopenharmony_ci# See the License for the specific language governing permissions and
12b1b8bc3fSopenharmony_ci# limitations under the License.
13b1b8bc3fSopenharmony_ci
14b1b8bc3fSopenharmony_ciimport("//build/config/features.gni")
15b1b8bc3fSopenharmony_ci
16b1b8bc3fSopenharmony_ci#####################hydra-fuzz###################
17b1b8bc3fSopenharmony_ciimport("//build/test.gni")
18b1b8bc3fSopenharmony_ciimport("//foundation/communication/netmanager_base/netmanager_base_config.gni")
19b1b8bc3fSopenharmony_ci
20b1b8bc3fSopenharmony_ci##############################fuzztest##########################################
21b1b8bc3fSopenharmony_ciohos_fuzztest("NetSysClientFuzzTest") {
22b1b8bc3fSopenharmony_ci  module_out_path = fuzz_test_path
23b1b8bc3fSopenharmony_ci  fuzz_config_file = "$NETMANAGER_BASE_ROOT/test/fuzztest/netsysclient_fuzzer"
24b1b8bc3fSopenharmony_ci  _cfi_blocklist_path = "$NETMANAGER_BASE_ROOT/test/fuzztest/netsysclient_fuzzer/cfi_blocklist.txt"
25b1b8bc3fSopenharmony_ci
26b1b8bc3fSopenharmony_ci  include_dirs = [
27b1b8bc3fSopenharmony_ci    "$NETCONNMANAGER_SOURCE_DIR/include",
28b1b8bc3fSopenharmony_ci    "$NETCONNMANAGER_COMMON_DIR/include",
29b1b8bc3fSopenharmony_ci    "$NETMANAGER_BASE_ROOT/utils/log/include",
30b1b8bc3fSopenharmony_ci    "$NETMANAGER_BASE_ROOT/services/netmanagernative/bpf/include",
31b1b8bc3fSopenharmony_ci    "$NETMANAGER_BASE_ROOT/test/commonduplicatedcode",
32b1b8bc3fSopenharmony_ci    "$NETSYSNATIVE_INNERKITS_SOURCE_DIR",
33b1b8bc3fSopenharmony_ci    "$INNERKITS_ROOT/netmanagernative/include",
34b1b8bc3fSopenharmony_ci    "$NETSYSNATIVE_SOURCE_DIR/include/netsys/wrapper",
35b1b8bc3fSopenharmony_ci    "$NETSYSNATIVE_SOURCE_DIR/include/netsys",
36b1b8bc3fSopenharmony_ci    "$NETSYSNATIVE_SOURCE_DIR/include/manager",
37b1b8bc3fSopenharmony_ci    "$NETSYSNATIVE_SOURCE_DIR/include",
38b1b8bc3fSopenharmony_ci    "$NETSYSCONTROLLER_ROOT_DIR/include",
39b1b8bc3fSopenharmony_ci  ]
40b1b8bc3fSopenharmony_ci
41b1b8bc3fSopenharmony_ci  cflags = [
42b1b8bc3fSopenharmony_ci    "-g",
43b1b8bc3fSopenharmony_ci    "-O0",
44b1b8bc3fSopenharmony_ci    "-Wno-unused-variable",
45b1b8bc3fSopenharmony_ci    "-fno-omit-frame-pointer",
46b1b8bc3fSopenharmony_ci  ]
47b1b8bc3fSopenharmony_ci
48b1b8bc3fSopenharmony_ci  if (!(use_libfuzzer || use_clang_coverage)) {
49b1b8bc3fSopenharmony_ci    cflags += [
50b1b8bc3fSopenharmony_ci      "-flto",
51b1b8bc3fSopenharmony_ci      "-fsanitize=cfi",
52b1b8bc3fSopenharmony_ci      "-fsanitize-cfi-cross-dso",
53b1b8bc3fSopenharmony_ci      "-fvisibility=hidden",
54b1b8bc3fSopenharmony_ci      "-fsanitize-blacklist=" +
55b1b8bc3fSopenharmony_ci          rebase_path(_cfi_blocklist_path, root_build_dir),
56b1b8bc3fSopenharmony_ci    ]
57b1b8bc3fSopenharmony_ci  }
58b1b8bc3fSopenharmony_ci
59b1b8bc3fSopenharmony_ci  ldflags = []
60b1b8bc3fSopenharmony_ci  if (!(use_libfuzzer || use_clang_coverage)) {
61b1b8bc3fSopenharmony_ci    ldflags += [
62b1b8bc3fSopenharmony_ci      "-flto",
63b1b8bc3fSopenharmony_ci      "-fsanitize=cfi",
64b1b8bc3fSopenharmony_ci      "-fsanitize-cfi-cross-dso",
65b1b8bc3fSopenharmony_ci    ]
66b1b8bc3fSopenharmony_ci  }
67b1b8bc3fSopenharmony_ci
68b1b8bc3fSopenharmony_ci  sources = [ "net_sys_client_fuzzer.cpp" ]
69b1b8bc3fSopenharmony_ci
70b1b8bc3fSopenharmony_ci  deps = [
71b1b8bc3fSopenharmony_ci    "$NETMANAGER_BASE_ROOT/services/netmanagernative:netsys_native_manager_static",
72b1b8bc3fSopenharmony_ci    "$NETMANAGER_BASE_ROOT/services/netmanagernative/bpf:netsys_bpf_utils",
73b1b8bc3fSopenharmony_ci    "$NETMANAGER_BASE_ROOT/utils:net_manager_common",
74b1b8bc3fSopenharmony_ci    "$NETSYSCONTROLLER_ROOT_DIR:netsys_controller",
75b1b8bc3fSopenharmony_ci  ]
76b1b8bc3fSopenharmony_ci
77b1b8bc3fSopenharmony_ci  defines = [
78b1b8bc3fSopenharmony_ci    "HI_LOG_ENABLE",
79b1b8bc3fSopenharmony_ci    "DH_LOG_TAG=\"NetSysClientFuzzTest\"",
80b1b8bc3fSopenharmony_ci    "LOG_DOMAIN=0xD004100",
81b1b8bc3fSopenharmony_ci  ]
82b1b8bc3fSopenharmony_ci
83b1b8bc3fSopenharmony_ci  external_deps = [
84b1b8bc3fSopenharmony_ci    "access_token:libaccesstoken_sdk",
85b1b8bc3fSopenharmony_ci    "access_token:libnativetoken",
86b1b8bc3fSopenharmony_ci    "access_token:libtoken_setproc",
87b1b8bc3fSopenharmony_ci    "bundle_framework:appexecfwk_base",
88b1b8bc3fSopenharmony_ci    "bundle_framework:appexecfwk_core",
89b1b8bc3fSopenharmony_ci    "c_utils:utils",
90b1b8bc3fSopenharmony_ci    "dhcp:dhcp_sdk",
91b1b8bc3fSopenharmony_ci    "eventhandler:libeventhandler",
92b1b8bc3fSopenharmony_ci    "ffrt:libffrt",
93b1b8bc3fSopenharmony_ci    "hilog:libhilog",
94b1b8bc3fSopenharmony_ci    "init:libbegetutil",
95b1b8bc3fSopenharmony_ci    "ipc:ipc_core",
96b1b8bc3fSopenharmony_ci    "safwk:system_ability_fwk",
97b1b8bc3fSopenharmony_ci    "samgr:samgr_proxy",
98b1b8bc3fSopenharmony_ci  ]
99b1b8bc3fSopenharmony_ci}
100b1b8bc3fSopenharmony_ci
101b1b8bc3fSopenharmony_ci###############################################################################
102b1b8bc3fSopenharmony_cigroup("fuzztest") {
103b1b8bc3fSopenharmony_ci  testonly = true
104b1b8bc3fSopenharmony_ci
105b1b8bc3fSopenharmony_ci  deps = [ ":NetSysClientFuzzTest" ]
106b1b8bc3fSopenharmony_ci}
107b1b8bc3fSopenharmony_ci
108b1b8bc3fSopenharmony_ci###############################################################################
109b1b8bc3fSopenharmony_ci
110