1# Copyright (c) 2023-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/ohos.gni") 15import("//build/test.gni") 16import("//foundation/communication/netstack/netstack_config.gni") 17 18NETSTACK_NAPI_ROOT = "$SUBSYSTEM_DIR/netstack/frameworks/js/napi/" 19 20utils_include = [ 21 "$SUBSYSTEM_DIR/netstack/utils/common_utils/include", 22 "$SUBSYSTEM_DIR/netstack/utils/http_over_curl/include", 23 "$SUBSYSTEM_DIR/netstack/utils/log/include", 24 "$SUBSYSTEM_DIR/netstack/utils/profiler_utils/include", 25 "$SUBSYSTEM_DIR/netstack/utils/tlv_utils/include", 26] 27 28common_external_deps = [ 29 "c_utils:utils", 30 "curl:curl_shared", 31 "hilog:libhilog", 32] 33 34ohos_unittest("http_unittest") { 35 sanitize = { 36 cfi = true 37 cfi_cross_dso = true 38 debug = false 39 } 40 41 branch_protector_ret = "pac_ret" 42 43 module_out_path = "netstack/netstack/http_unittest" 44 45 include_dirs = [ 46 "$NETSTACK_NAPI_ROOT/http/async_context/include", 47 "$NETSTACK_NAPI_ROOT/http/async_work/include", 48 "$NETSTACK_NAPI_ROOT/http/cache/base64/include", 49 "$NETSTACK_NAPI_ROOT/http/cache/cache_constant/include", 50 "$NETSTACK_NAPI_ROOT/http/cache/cache_proxy/include", 51 "$NETSTACK_NAPI_ROOT/http/cache/cache_strategy/include", 52 "$NETSTACK_NAPI_ROOT/http/cache/lru_cache/include", 53 "$NETSTACK_NAPI_ROOT/http/constant/include", 54 "$NETSTACK_NAPI_ROOT/http/http_exec/include", 55 "$NETSTACK_NAPI_ROOT/http/http_module/include", 56 "$NETSTACK_NAPI_ROOT/http/options/include", 57 ] 58 include_dirs += utils_include 59 60 if (defined(global_parts_info) && 61 defined(global_parts_info.communication_netmanager_base) && 62 global_parts_info.communication_netmanager_base) { 63 include_dirs += [ 64 "$SUBSYSTEM_DIR/netstack/utils/netstack_chr_client/include", 65 ] 66 } 67 68 external_deps = common_external_deps 69 external_deps += [ "napi:ace_napi" ] 70 71 sources = [ 72 "$NETSTACK_NAPI_ROOT/http/async_context/src/request_context.cpp", 73 "$NETSTACK_NAPI_ROOT/http/constant/src/constant.cpp", 74 "$NETSTACK_NAPI_ROOT/http/http_exec/src/http_exec.cpp", 75 "$NETSTACK_NAPI_ROOT/http/http_exec/src/http_tls_config.cpp", 76 "$NETSTACK_NAPI_ROOT/http/options/src/http_request_options.cpp", 77 "$NETSTACK_NAPI_ROOT/http/options/src/http_response.cpp", 78 "$SUBSYSTEM_DIR/netstack/utils/common_utils/src/netstack_common_utils.cpp", 79 "$SUBSYSTEM_DIR/netstack/utils/netstack_chr_client/src/netstack_chr_client.cpp", 80 "$SUBSYSTEM_DIR/netstack/utils/netstack_chr_client/src/netstack_chr_report.cpp", 81 "$SUBSYSTEM_DIR/netstack/utils/http_over_curl/src/epoll_request_handler.cpp", 82 "$SUBSYSTEM_DIR/netstack/utils/profiler_utils/src/netstack_network_profiler.cpp", 83 "$SUBSYSTEM_DIR/netstack/utils/tlv_utils/src/tlv_utils.cpp", 84 "HttpExecTest.cpp", 85 "HttpRequestOptionsTest.cpp", 86 ] 87 88 deps = [ "$SUBSYSTEM_DIR/netstack/utils/napi_utils:napi_utils" ] 89 if (is_mingw || is_mac) { 90 sources += 91 [ "$NETSTACK_DIR/utils/common_utils/src/netstack_common_utils.cpp" ] 92 deps += [ 93 "napi:ace_napi", 94 "$NETSTACK_DIR/utils/napi_utils:napi_utils_static", 95 ] 96 external_deps += [ 97 "napi:ace_napi", 98 "bounds_checking_function:libsec_static", 99 ] 100 } else { 101 deps += [ 102 "$NETSTACK_DIR/utils:stack_utils_common", 103 "$NETSTACK_DIR/utils/napi_utils:napi_utils", 104 ] 105 external_deps += [ 106 "ability_runtime:wantagent_innerkits", 107 "hilog:libhilog", 108 "hiprofiler:libnetwork_profiler", 109 "hitrace:hitrace_meter", 110 "napi:ace_napi", 111 "time_service:time_client", 112 ] 113 if (netstack_http_boringssl) { 114 external_deps += [ 115 "crypto_boring:crypto_boring", 116 "crypto_boring:ssl_boring", 117 ] 118 } else { 119 external_deps += [ 120 "openssl:libcrypto_shared", 121 "openssl:libssl_shared", 122 ] 123 } 124 if (defined(global_parts_info) && 125 defined(global_parts_info.communication_netmanager_base) && 126 global_parts_info.communication_netmanager_base) { 127 external_deps += [ 128 "netmanager_base:net_conn_manager_if", 129 "netmanager_base:net_security_config_if", 130 "netmanager_base:netsys_client", 131 ] 132 defines = [ "HAS_NETMANAGER_BASE=1" ] 133 } else { 134 defines = [ "HAS_NETMANAGER_BASE=0" ] 135 } 136 if (product_name != "ohos-sdk") { 137 external_deps += [ "init:libbegetutil" ] 138 defines += [ 139 "HTTP_PROXY_ENABLE", 140 "HTTP_MULTIPATH_CERT_ENABLE", 141 "HTTP_ONLY_VERIFY_ROOT_CA_ENABLE", 142 ] 143 } 144 } 145 146 part_name = "netstack" 147 subsystem_name = "communication" 148} 149 150group("unittest") { 151 testonly = true 152 deps = [ ":http_unittest" ] 153} 154