1518678f8Sopenharmony_ci# Copyright (C) 2021-2023 Huawei Device Co., Ltd.
2518678f8Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3518678f8Sopenharmony_ci# you may not use this file except in compliance with the License.
4518678f8Sopenharmony_ci# You may obtain a copy of the License at
5518678f8Sopenharmony_ci#
6518678f8Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
7518678f8Sopenharmony_ci#
8518678f8Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9518678f8Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10518678f8Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11518678f8Sopenharmony_ci# See the License for the specific language governing permissions and
12518678f8Sopenharmony_ci# limitations under the License.
13518678f8Sopenharmony_ci
14518678f8Sopenharmony_ciimport("//build/test.gni")
15518678f8Sopenharmony_ciimport("//foundation/communication/dhcp/dhcp.gni")
16518678f8Sopenharmony_ci
17518678f8Sopenharmony_cimodule_output_path = "dhcp/dhcp_client_test"
18518678f8Sopenharmony_ci
19518678f8Sopenharmony_ciconfig("module_private_config") {
20518678f8Sopenharmony_ci  visibility = [ ":*" ]
21518678f8Sopenharmony_ci  include_dirs = [ "$DHCP_ROOT_DIR/services/dhcp_client/include" ]
22518678f8Sopenharmony_ci}
23518678f8Sopenharmony_ci
24518678f8Sopenharmony_ciohos_unittest("dhcp_client_unittest") {
25518678f8Sopenharmony_ci  module_out_path = module_output_path
26518678f8Sopenharmony_ci  sources = [
27518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_client_callback_proxy.cpp",
28518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_client_death_recipient.cpp",
29518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_client_service_impl.cpp",
30518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_client_state_machine.cpp",
31518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_client_stub.cpp",
32518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_function.cpp",
33518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_ipv6_client.cpp",
34518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_ipv6_event.cpp",
35518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_options.cpp",
36518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_result.cpp",
37518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_result_store_manager.cpp",
38518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_socket.cpp",
39518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/dhcp_client/src/dhcp_thread.cpp",
40518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/test/fuzztest/fuzz_common_func/mock_dhcp_permission_utils.cpp",
41518678f8Sopenharmony_ci    "dhcp_client_callback_proxy_test.cpp",
42518678f8Sopenharmony_ci    "dhcp_client_death_recipient_test.cpp",
43518678f8Sopenharmony_ci    "dhcp_client_service_impl_test.cpp",
44518678f8Sopenharmony_ci    "dhcp_client_state_machine_test.cpp",
45518678f8Sopenharmony_ci    "dhcp_client_stub_test.cpp",
46518678f8Sopenharmony_ci    "dhcp_client_test.cpp",
47518678f8Sopenharmony_ci    "dhcp_function_test.cpp",
48518678f8Sopenharmony_ci    "dhcp_ipv6_client_test.cpp",
49518678f8Sopenharmony_ci    "dhcp_options_test.cpp",
50518678f8Sopenharmony_ci    "dhcp_result_store_manager_test.cpp",
51518678f8Sopenharmony_ci    "dhcp_result_test.cpp",
52518678f8Sopenharmony_ci    "dhcp_socket_test.cpp",
53518678f8Sopenharmony_ci    "dhcp_thread_test.cpp",
54518678f8Sopenharmony_ci    "mock_custom_func.cpp",
55518678f8Sopenharmony_ci    "mock_system_func.cpp",
56518678f8Sopenharmony_ci  ]
57518678f8Sopenharmony_ci
58518678f8Sopenharmony_ci  include_dirs = [
59518678f8Sopenharmony_ci    "//third_party/openssl/include",
60518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/frameworks/native/include",
61518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/frameworks/native/interfaces",
62518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/frameworks/native/src",
63518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/frameworks/native/c_adapter/inc",
64518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/interfaces",
65518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/interfaces/inner_api",
66518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/interfaces/inner_api/include",
67518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/interfaces/kits/c",
68518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services",
69518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/dhcp_client/include",
70518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/dhcp_server/include",
71518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/test/fuzztest/fuzz_common_func",
72518678f8Sopenharmony_ci  ]
73518678f8Sopenharmony_ci
74518678f8Sopenharmony_ci  deps = [
75518678f8Sopenharmony_ci    "$DHCP_ROOT_DIR/services/utils:dhcp_utils",
76518678f8Sopenharmony_ci    "//third_party/googletest:gmock_main",
77518678f8Sopenharmony_ci    "//third_party/googletest:gtest_main",
78518678f8Sopenharmony_ci    "//third_party/openssl:libcrypto_shared",
79518678f8Sopenharmony_ci  ]
80518678f8Sopenharmony_ci
81518678f8Sopenharmony_ci  ldflags = [
82518678f8Sopenharmony_ci    "-fPIC",
83518678f8Sopenharmony_ci    "-Wl,-E",
84518678f8Sopenharmony_ci    "--coverage",
85518678f8Sopenharmony_ci    "-Wl,-rpath=/vendor/lib64/hw",
86518678f8Sopenharmony_ci    "-Wl,--wrap=open",
87518678f8Sopenharmony_ci    "-Wl,--wrap=close",
88518678f8Sopenharmony_ci    "-Wl,--wrap=write",
89518678f8Sopenharmony_ci    "-Wl,--wrap=read",
90518678f8Sopenharmony_ci    "-Wl,--wrap=socket",
91518678f8Sopenharmony_ci    "-Wl,--wrap=setsockopt",
92518678f8Sopenharmony_ci    "-Wl,--wrap=ioctl",
93518678f8Sopenharmony_ci    "-Wl,--wrap=bind",
94518678f8Sopenharmony_ci    "-Wl,--wrap=listen",
95518678f8Sopenharmony_ci    "-Wl,--wrap=connect",
96518678f8Sopenharmony_ci    "-Wl,--wrap=select",
97518678f8Sopenharmony_ci    "-Wl,--wrap=sendto",
98518678f8Sopenharmony_ci    "-Wl,--wrap=socketpair",
99518678f8Sopenharmony_ci    "-Wl,--wrap=GetDhcpRawPacket",
100518678f8Sopenharmony_ci    "-Wl,--wrap=GetDhcpKernelPacket",
101518678f8Sopenharmony_ci    "-Wl,--wrap=GetSelectRet",
102518678f8Sopenharmony_ci  ]
103518678f8Sopenharmony_ci
104518678f8Sopenharmony_ci  cflags_cc = [ "-Wno-unused-variable" ]
105518678f8Sopenharmony_ci
106518678f8Sopenharmony_ci  external_deps = [
107518678f8Sopenharmony_ci    "ability_runtime:wantagent_innerkits",
108518678f8Sopenharmony_ci    "access_token:libaccesstoken_sdk",
109518678f8Sopenharmony_ci    "access_token:libtokenid_sdk",
110518678f8Sopenharmony_ci    "c_utils:utils",
111518678f8Sopenharmony_ci    "hilog:libhilog",
112518678f8Sopenharmony_ci    "ipc:ipc_single",
113518678f8Sopenharmony_ci    "netmanager_base:net_native_manager_if",
114518678f8Sopenharmony_ci    "netmanager_base:netsys_controller",
115518678f8Sopenharmony_ci    "safwk:system_ability_fwk",
116518678f8Sopenharmony_ci    "samgr:samgr_proxy",
117518678f8Sopenharmony_ci    "time_service:time_client",
118518678f8Sopenharmony_ci  ]
119518678f8Sopenharmony_ci
120518678f8Sopenharmony_ci  configs = [ ":module_private_config" ]
121518678f8Sopenharmony_ci
122518678f8Sopenharmony_ci  defines = [
123518678f8Sopenharmony_ci    "private = public",
124518678f8Sopenharmony_ci    "protected = public",
125518678f8Sopenharmony_ci    "VENDOR_NAME_PREFIX=\"$VENDOR_NAME\"",
126518678f8Sopenharmony_ci    "DEFAULT_IPV4_DNS_PRI=\"$IPV4_DNS_PRI\"",
127518678f8Sopenharmony_ci    "DEFAULT_IPV4_DNS_SEC=\"$IPV4_DNS_SEC\"",
128518678f8Sopenharmony_ci  ]
129518678f8Sopenharmony_ci
130518678f8Sopenharmony_ci  if (defined(global_parts_info) &&
131518678f8Sopenharmony_ci      defined(global_parts_info.resourceschedule_ffrt)) {
132518678f8Sopenharmony_ci    external_deps += [ "ffrt:libffrt" ]
133518678f8Sopenharmony_ci    defines += [ "DHCP_FFRT_ENABLE" ]
134518678f8Sopenharmony_ci  }
135518678f8Sopenharmony_ci
136518678f8Sopenharmony_ci  part_name = "dhcp"
137518678f8Sopenharmony_ci  subsystem_name = "communication"
138518678f8Sopenharmony_ci  testonly = true
139518678f8Sopenharmony_ci}
140518678f8Sopenharmony_ci
141518678f8Sopenharmony_cigroup("unittest") {
142518678f8Sopenharmony_ci  testonly = true
143518678f8Sopenharmony_ci  deps = [ ":dhcp_client_unittest" ]
144518678f8Sopenharmony_ci}
145