1# Copyright (C) 2021 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") 15 16SUBSYSTEM_DIR = "//foundation/communication/ipc" 17IPC_TEST_ROOT = "$SUBSYSTEM_DIR/ipc/test" 18IPC_CORE_ROOT = "$SUBSYSTEM_DIR/ipc/native" 19MODULE_OUTPUT_PATH = "ipc" 20 21ohos_unittest("IPCNativeUnitTest") { 22 module_out_path = MODULE_OUTPUT_PATH 23 24 include_dirs = [ 25 "$IPC_CORE_ROOT/c/rpc/include", 26 "$IPC_CORE_ROOT/c/ipc_adapter/include", 27 "$IPC_CORE_ROOT/src/core/include", 28 "$IPC_CORE_ROOT/src/mock/include", 29 "$SUBSYSTEM_DIR/interfaces/innerkits/ipc_core/include", 30 "$SUBSYSTEM_DIR/interfaces/innerkits/libdbinder/include", 31 "$SUBSYSTEM_DIR/native/src/core/include", 32 ] 33 34 sources = [ 35 "buffer_object_unittest.cpp", 36 "dbinder_callback_stub_unittest.cpp", 37 "dbinder_session_object_unittest.cpp", 38 "ipc_core_unittest.cpp", 39 "ipc_object_proxy_unittest.cpp", 40 "ipc_object_stub_unittest.cpp", 41 "ipc_payload_statistics_impl_unittest.cpp", 42 "ipc_payload_statistics_unittest.cpp", 43 "ipc_process_skeleton_unittest.cpp", 44 "ipc_skeleton_unittest.cpp", 45 "ipc_thread_pool_unittest.cpp", 46 "ipc_thread_skeleton_unittest.cpp", 47 "iremote_object_unitest.cpp", 48 "message_parcel_unittest.cpp", 49 "process_skeleton_unittest.cpp", 50 ] 51 52 configs = [ 53 "$SUBSYSTEM_DIR/config:ipc_util_config", 54 "$IPC_TEST_ROOT:ipc_test_config", 55 ] 56 57 deps = [ 58 "$IPC_CORE_ROOT/src/core:ipc_common", 59 "$IPC_TEST_ROOT/auxiliary/native:TestAssistance", 60 ] 61 62 external_deps = [ 63 "c_utils:utils", 64 "googletest:gmock", 65 "hilog:libhilog", 66 "hitrace:libhitracechain", 67 "ipc:ipc_core", 68 "samgr:samgr_proxy", 69 ] 70 71 ldflags = [ "-lpthread" ] 72 73 resource_config_file = "$SUBSYSTEM_DIR/test/resource/ipc/ohos_test.xml" 74} 75 76ohos_unittest("IPCFileDescOpsTest") { 77 module_out_path = MODULE_OUTPUT_PATH 78 79 include_dirs = [ 80 "$IPC_CORE_ROOT/c/rpc/include", 81 "$IPC_CORE_ROOT/c/ipc_adapter/include", 82 "$SUBSYSTEM_DIR/interfaces/innerkits/ipc_core/include", 83 "$SUBSYSTEM_DIR/interfaces/innerkits/libdbinder/include", 84 "$SUBSYSTEM_DIR/ipc/native/src/core/include", 85 ] 86 87 sources = [ "ipc_file_desc_unittest.cpp" ] 88 89 configs = [ 90 "$SUBSYSTEM_DIR/config:ipc_util_config", 91 "$IPC_TEST_ROOT:ipc_test_config", 92 ] 93 94 deps = [ "$IPC_TEST_ROOT/auxiliary/native:TestAssistance" ] 95 96 external_deps = [ 97 "c_utils:utils", 98 "googletest:gmock", 99 "hilog:libhilog", 100 "ipc:ipc_core", 101 ] 102 103 resource_config_file = "$SUBSYSTEM_DIR/test/resource/ipc/ohos_test.xml" 104} 105 106ohos_unittest("BinderConnectorTest") { 107 module_out_path = MODULE_OUTPUT_PATH 108 109 sources = [ "ipc_connector_unittest.cpp" ] 110 111 configs = [ 112 "$SUBSYSTEM_DIR/config:ipc_util_config", 113 "$IPC_TEST_ROOT:ipc_test_config", 114 ] 115 116 deps = [ 117 "$IPC_CORE_ROOT/src/core:ipc_common", 118 "$IPC_TEST_ROOT/auxiliary/native:TestAssistance", 119 ] 120 121 external_deps = [ 122 "c_utils:utils", 123 "hilog:libhilog", 124 "ipc:ipc_core", 125 "samgr:samgr_proxy", 126 ] 127 128 resource_config_file = "$SUBSYSTEM_DIR/test/resource/ipc/ohos_test.xml" 129} 130 131ohos_unittest("BinderInvokerUnitTest") { 132 module_out_path = MODULE_OUTPUT_PATH 133 134 include_dirs = [ 135 "$IPC_CORE_ROOT/c/adapter/access_token/include", 136 "$IPC_CORE_ROOT/c/rpc/include", 137 ] 138 139 sources = [ "binder_invoker_unittest.cpp" ] 140 141 configs = [ 142 "$SUBSYSTEM_DIR/config:ipc_util_config", 143 "$IPC_TEST_ROOT:ipc_test_config", 144 ] 145 146 deps = [ 147 "$IPC_CORE_ROOT/src/core:ipc_common", 148 "$IPC_TEST_ROOT/auxiliary/native:TestAssistance", 149 ] 150 151 external_deps = [ 152 "c_utils:utils", 153 "hilog:libhilog", 154 "hitrace:libhitracechain", 155 "ipc:ipc_core", 156 "samgr:samgr_proxy", 157 ] 158 159 resource_config_file = "$SUBSYSTEM_DIR/test/resource/ipc/ohos_test.xml" 160} 161 162ohos_unittest("IPCHiTraceUnitTest") { 163 module_out_path = MODULE_OUTPUT_PATH 164 165 include_dirs = [] 166 167 sources = [ "ipc_hitrace_unittest.cpp" ] 168 169 configs = [ 170 "$SUBSYSTEM_DIR/config:ipc_util_config", 171 "$IPC_TEST_ROOT:ipc_test_config", 172 ] 173 174 deps = [ "$IPC_TEST_ROOT/auxiliary/native:TestAssistance" ] 175 176 external_deps = [ 177 "c_utils:utils", 178 "googletest:gmock", 179 "hilog:libhilog", 180 "hitrace:libhitracechain", 181 "ipc:ipc_core", 182 "samgr:samgr_proxy", 183 ] 184 185 resource_config_file = "$SUBSYSTEM_DIR/test/resource/ipc/ohos_test.xml" 186} 187 188if (support_jsapi) { 189 ohos_unittest("IPCNapiUnitTest") { 190 module_out_path = MODULE_OUTPUT_PATH 191 192 include_dirs = [ 193 "$IPC_CORE_ROOT/src/mock/include", 194 "$SUBSYSTEM_DIR/interfaces/innerkits/ipc_core/include", 195 ] 196 197 sources = [ "ipc_napi_unittest.cpp" ] 198 configs = [] 199 200 external_deps = [ 201 "bounds_checking_function:libsec_shared", 202 "googletest:gmock", 203 "hilog:libhilog", 204 "ipc:ipc_napi", 205 "napi:ace_napi", 206 ] 207 208 resource_config_file = "$SUBSYSTEM_DIR/test/resource/ipc/ohos_test.xml" 209 } 210} 211 212ohos_unittest("IPCMockUnitTest") { 213 module_out_path = MODULE_OUTPUT_PATH 214 215 include_dirs = [ 216 "$SUBSYSTEM_DIR/interfaces/innerkits/ipc_core/include", 217 "$IPC_CORE_ROOT/src/mock/include", 218 "$IPC_CORE_ROOT/c/rpc/include", 219 "$IPC_CORE_ROOT/c/adapter/access_token/include", 220 ] 221 222 sources = [ "ipc_binder_databus_invoker_unittest.cpp" ] 223 224 configs = [ 225 "$SUBSYSTEM_DIR/config:ipc_util_config", 226 "$IPC_TEST_ROOT:ipc_test_config", 227 ] 228 229 deps = [ "$IPC_TEST_ROOT/auxiliary/native:TestAssistance" ] 230 231 external_deps = [ 232 "c_utils:utils", 233 "googletest:gmock", 234 "hilog:libhilog", 235 "hitrace:libhitracechain", 236 "ipc:ipc_core", 237 "samgr:samgr_proxy", 238 ] 239 240 resource_config_file = "$SUBSYSTEM_DIR/test/resource/ipc/ohos_test.xml" 241} 242 243ohos_unittest("InvokerFactoryTest") { 244 module_out_path = MODULE_OUTPUT_PATH 245 246 include_dirs = [ 247 "$SUBSYSTEM_DIR/interfaces/innerkits/ipc_core/include", 248 "$IPC_CORE_ROOT/src/mock/include", 249 "$IPC_CORE_ROOT/c/rpc/include", 250 "$IPC_CORE_ROOT/c/adapter/access_token/include", 251 ] 252 253 sources = [ "invoker_factory_unittest.cpp" ] 254 255 configs = [ 256 "$SUBSYSTEM_DIR/config:ipc_util_config", 257 "$IPC_TEST_ROOT:ipc_test_config", 258 ] 259 260 deps = [ "$IPC_TEST_ROOT/auxiliary/native:TestAssistance" ] 261 262 external_deps = [ 263 "c_utils:utils", 264 "googletest:gmock", 265 "hilog:libhilog", 266 "hitrace:libhitracechain", 267 "ipc:ipc_core", 268 "samgr:samgr_proxy", 269 ] 270 271 resource_config_file = "$SUBSYSTEM_DIR/test/resource/ipc/ohos_test.xml" 272} 273 274ohos_unittest("RPCFeatureUnitTest") { 275 module_out_path = MODULE_OUTPUT_PATH 276 277 include_dirs = [ 278 "$SUBSYSTEM_DIR/interfaces/innerkits/ipc_core/include", 279 "$IPC_CORE_ROOT/src/mock/include", 280 "$IPC_CORE_ROOT/c/rpc/include", 281 "$IPC_CORE_ROOT/c/adapter/access_token/include", 282 "$IPC_CORE_ROOT/c/rpc/src/", 283 ] 284 285 sources = [ "rpc_feature_set_unittest.cpp" ] 286 287 configs = [ 288 "$SUBSYSTEM_DIR/config:ipc_util_config", 289 "$IPC_TEST_ROOT:ipc_test_config", 290 ] 291 292 deps = [ "$IPC_TEST_ROOT/auxiliary/native:TestAssistance" ] 293 294 external_deps = [ 295 "c_utils:utils", 296 "googletest:gmock", 297 "hilog:libhilog", 298 "hitrace:libhitracechain", 299 "ipc:ipc_core", 300 "samgr:samgr_proxy", 301 ] 302 303 resource_config_file = "$SUBSYSTEM_DIR/test/resource/ipc/ohos_test.xml" 304} 305 306ohos_unittest("IPCSoDlcloseTest") { 307 module_out_path = MODULE_OUTPUT_PATH 308 309 sources = [ "ipc_so_dlclose_unittest.cpp" ] 310 311 external_deps = [ "googletest:gmock" ] 312 313 resource_config_file = "$SUBSYSTEM_DIR/test/resource/ipc/ohos_test.xml" 314} 315 316ohos_unittest("IPCBlockThreadTest") { 317 module_out_path = MODULE_OUTPUT_PATH 318 319 include_dirs = [ "$SUBSYSTEM_DIR/utils/include" ] 320 321 sources = [ "ipc_block_thread_unittest.cpp" ] 322 323 external_deps = [ 324 "googletest:gmock", 325 "hilog:libhilog", 326 "ipc:ipc_core", 327 ] 328 329 resource_config_file = "$SUBSYSTEM_DIR/test/resource/ipc/ohos_test.xml" 330} 331 332ohos_unittest("IpcCApiUnitTest") { 333 module_out_path = MODULE_OUTPUT_PATH 334 335 include_dirs = [ "$SUBSYSTEM_DIR/interfaces/innerkits/ipc_core/include" ] 336 337 sources = [ 338 "ipc_capi_parcel_unittest.cpp", 339 "ipc_capi_remote_object_unittest.cpp", 340 "ipc_capi_skeleton_unittest.cpp", 341 ] 342 343 configs = [ 344 "$SUBSYSTEM_DIR/config:ipc_util_config", 345 "$IPC_TEST_ROOT:ipc_test_config", 346 ] 347 348 deps = [ 349 "$IPC_TEST_ROOT/auxiliary/native:TestAssistance", 350 "$SUBSYSTEM_DIR/interfaces/innerkits/c_api:ipc_capi", 351 ] 352 353 external_deps = [ 354 "c_utils:utils", 355 "googletest:gmock", 356 "hilog:libhilog", 357 "hitrace:libhitracechain", 358 "ipc:ipc_core", 359 "samgr:samgr_proxy", 360 ] 361 362 resource_config_file = "$SUBSYSTEM_DIR/test/resource/ipc/ohos_test.xml" 363} 364 365############################################################################### 366group("unittest") { 367 testonly = true 368 deps = [ 369 ":BinderConnectorTest", 370 ":BinderInvokerUnitTest", 371 ":IPCBlockThreadTest", 372 ":IPCFileDescOpsTest", 373 ":IPCHiTraceUnitTest", 374 ":IPCMockUnitTest", 375 ":IPCNativeUnitTest", 376 ":IPCSoDlcloseTest", 377 ":InvokerFactoryTest", 378 ":IpcCApiUnitTest", 379 ":RPCFeatureUnitTest", 380 ] 381 if (support_jsapi) { 382 deps += [ ":IPCNapiUnitTest" ] 383 } 384} 385 386############################################################################### 387 388