• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2021-2023 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/test.gni")
15import("//foundation/communication/dhcp/dhcp.gni")
16
17module_output_path = "dhcp/dhcp_client_test"
18
19config("module_private_config") {
20  visibility = [ ":*" ]
21  include_dirs = [ "$DHCP_ROOT_DIR/services/dhcp_client/include" ]
22}
23
24ohos_unittest("dhcp_client_unittest") {
25  module_out_path = module_output_path
26  sources = [
27    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_client_callback_proxy.cpp",
28    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_client_death_recipient.cpp",
29    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_client_service_impl.cpp",
30    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_client_state_machine.cpp",
31    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_client_stub.cpp",
32    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_function.cpp",
33    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_ipv6_client.cpp",
34    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_ipv6_event.cpp",
35    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_options.cpp",
36    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_result.cpp",
37    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_result_store_manager.cpp",
38    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_socket.cpp",
39    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_thread.cpp",
40    "$DHCP_ROOT_DIR/test/fuzztest/fuzz_common_func/mock_dhcp_permission_utils.cpp",
41    "dhcp_client_callback_proxy_test.cpp",
42    "dhcp_client_death_recipient_test.cpp",
43    "dhcp_client_service_impl_test.cpp",
44    "dhcp_client_state_machine_test.cpp",
45    "dhcp_client_stub_test.cpp",
46    "dhcp_client_test.cpp",
47    "dhcp_function_test.cpp",
48    "dhcp_ipv6_client_test.cpp",
49    "dhcp_options_test.cpp",
50    "dhcp_result_store_manager_test.cpp",
51    "dhcp_result_test.cpp",
52    "dhcp_socket_test.cpp",
53    "dhcp_thread_test.cpp",
54    "mock_custom_func.cpp",
55    "mock_system_func.cpp",
56  ]
57
58  include_dirs = [
59    "//third_party/openssl/include",
60    "$DHCP_ROOT_DIR/frameworks/native/include",
61    "$DHCP_ROOT_DIR/frameworks/native/interfaces",
62    "$DHCP_ROOT_DIR/frameworks/native/src",
63    "$DHCP_ROOT_DIR/frameworks/native/c_adapter/inc",
64    "$DHCP_ROOT_DIR/interfaces",
65    "$DHCP_ROOT_DIR/interfaces/inner_api",
66    "$DHCP_ROOT_DIR/interfaces/inner_api/include",
67    "$DHCP_ROOT_DIR/interfaces/kits/c",
68    "$DHCP_ROOT_DIR/services",
69    "$DHCP_ROOT_DIR/services/dhcp_client/include",
70    "$DHCP_ROOT_DIR/services/dhcp_server/include",
71    "$DHCP_ROOT_DIR/test/fuzztest/fuzz_common_func",
72  ]
73
74  deps = [
75    "$DHCP_ROOT_DIR/services/utils:dhcp_utils",
76    "//third_party/googletest:gmock_main",
77    "//third_party/googletest:gtest_main",
78    "//third_party/openssl:libcrypto_shared",
79  ]
80
81  ldflags = [
82    "-fPIC",
83    "-Wl,-E",
84    "--coverage",
85    "-Wl,-rpath=/vendor/lib64/hw",
86    "-Wl,--wrap=open",
87    "-Wl,--wrap=close",
88    "-Wl,--wrap=write",
89    "-Wl,--wrap=read",
90    "-Wl,--wrap=socket",
91    "-Wl,--wrap=setsockopt",
92    "-Wl,--wrap=ioctl",
93    "-Wl,--wrap=bind",
94    "-Wl,--wrap=listen",
95    "-Wl,--wrap=connect",
96    "-Wl,--wrap=select",
97    "-Wl,--wrap=sendto",
98    "-Wl,--wrap=socketpair",
99    "-Wl,--wrap=GetDhcpRawPacket",
100    "-Wl,--wrap=GetDhcpKernelPacket",
101    "-Wl,--wrap=GetSelectRet",
102  ]
103
104  cflags_cc = [ "-Wno-unused-variable" ]
105
106  external_deps = [
107    "ability_runtime:wantagent_innerkits",
108    "access_token:libaccesstoken_sdk",
109    "access_token:libtokenid_sdk",
110    "c_utils:utils",
111    "hilog:libhilog",
112    "ipc:ipc_single",
113    "netmanager_base:net_native_manager_if",
114    "netmanager_base:netsys_controller",
115    "safwk:system_ability_fwk",
116    "samgr:samgr_proxy",
117    "time_service:time_client",
118  ]
119
120  configs = [ ":module_private_config" ]
121
122  defines = [
123    "OHOS_EUPDATER",
124    "private = public",
125    "protected = public",
126    "VENDOR_NAME_PREFIX=\"$VENDOR_NAME\"",
127    "DEFAULT_IPV4_DNS_PRI=\"$IPV4_DNS_PRI\"",
128    "DEFAULT_IPV4_DNS_SEC=\"$IPV4_DNS_SEC\"",
129  ]
130
131  if (defined(global_parts_info) &&
132      defined(global_parts_info.resourceschedule_ffrt)) {
133    external_deps += [ "ffrt:libffrt" ]
134    defines += [ "DHCP_FFRT_ENABLE" ]
135  }
136
137  if (defined(global_parts_info) && defined(global_parts_info.startup_init)) {
138    external_deps += [ "init:libbegetutil" ]
139    defines += [ "INIT_LIB_ENABLE" ]
140  }
141
142  part_name = "dhcp"
143  subsystem_name = "communication"
144  testonly = true
145}
146
147group("unittest") {
148  testonly = true
149  deps = [ ":dhcp_client_unittest" ]
150}
151