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