• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
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.
13import("//build/test.gni")
14import("../../../base/config.gni")
15
16module_output_path = "${OHOS_PROFILER_TEST_MODULE_OUTPUT_PATH}/device"
17
18config("module_private_config") {
19  visibility = [ ":*" ]
20  defines = [
21    "HIPERF_DEBUG",
22    "CONFIG_NO_HILOG",
23    "target_cpu_${target_cpu}",
24  ]
25
26  if (current_toolchain != host_toolchain) {
27    defines += [ "HAVE_HILOG" ]
28  }
29  if (use_clang_coverage) {
30    defines += [ "COVERAGE_TEST" ]
31  }
32}
33
34ohos_unittest("nativehook_ut") {
35  module_out_path = module_output_path
36  sources = [
37    "../../memory_plugin/src/buffer_splitter.cpp",
38    "unittest/address_handler_test.cpp",
39    "unittest/check_hook_data_test.cpp",
40    "unittest/hook_client_test.cpp",
41    "unittest/hook_socket_client_test.cpp",
42    "unittest/sampling_test.cpp",
43    "unittest/stack_writer_test.cpp",
44  ]
45
46  public_deps = [
47    "${OHOS_PROFILER_DIR}/device/services/shared_memory:shared_memory_source",
48    "${OHOS_PROFILER_DIR}/protos/services:profiler_service_all_type_source",
49  ]
50  deps = [
51    "${OHOS_PROFILER_DIR}/device/base:mock_test_source",
52    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon:native_daemon",
53    "${OHOS_PROFILER_DIR}/device/plugins/native_hook:native_hook_source",
54    "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp",
55    "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp_standard",
56  ]
57
58  include_dirs = [
59    "../include",
60    "../../native_daemon/include",
61    "../../api/include",
62    "../../api/src",
63    "../../memory_plugin/include",
64    "../../../base/include/",
65    "${OHOS_PROFILER_DIR}/interfaces/kits",
66    "${OHOS_PROFILER_DIR}/device/services/ipc/include",
67    "${OHOS_PROFILER_DIR}/device/services/shared_memory/include",
68    "${OHOS_PROFILER_DIR}/device/services/profiler_service/include",
69  ]
70
71  cflags = [
72    "-Wno-inconsistent-missing-override",
73    "-Dprivate=public",  #allow test code access private members
74    "-Dprotected=public",  #allow test code access private members
75  ]
76  external_deps = [
77    "access_token:libaccesstoken_sdk",
78    "access_token:libtokensetproc_shared",
79    "bounds_checking_function:libsec_shared",
80    "cJSON:cjson",
81    "c_utils:utils",
82    "faultloggerd:libunwinder",
83    "googletest:gtest",
84    "hilog:libhilog_base",
85    "init:libbegetutil",
86    "protobuf:protobuf",
87  ]
88  configs = [ ":module_private_config" ]
89  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
90  part_name = "${OHOS_PROFILER_PART_NAME}"
91  resource_config_file = "${OHOS_PROFILER_DIR}/device/ohos_test.xml"
92}
93group("unittest") {
94  testonly = true
95  deps = [
96    ":nativehook_ut",
97    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon:native_daemon_client",
98    "${OHOS_PROFILER_DIR}/device/plugins/native_hook:nativetest_so",
99  ]
100}
101