• 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.
13
14import("//build/test.gni")
15import("../../../base/config.gni")
16import("native_daemon.gni")
17
18module_output_path = "${OHOS_PROFILER_TEST_MODULE_OUTPUT_PATH}/device"
19
20sources_base = [
21  "unittest/common/native/callstack_test.cpp",
22  "unittest/common/native/debug_logger_test.cpp",
23  "unittest/common/native/hashlist_test.cpp",
24  "unittest/common/native/hook_manager_test.cpp",
25  "unittest/common/native/hook_service_test.cpp",
26  "unittest/common/native/register_test.cpp",
27  "unittest/common/native/symbols_file_test.cpp",
28  "unittest/common/native/utilities_test.cpp",
29  "unittest/common/native/virtual_thread_test.cpp",
30  "unittest/common/native/virtual_runtime_test.cpp",
31  "../../api/src/buffer_writer.cpp",
32  "../../api/src/command_poller.cpp",
33  "../../api/src/writer_adapter.cpp",
34  "../src/hook_manager.cpp",
35  "../src/call_stack.cpp",
36  "../src/debug_logger.cpp",
37  "../src/dwarf_encoding.cpp",
38  "../src/get_thread_id.cpp",
39  "../src/hook_service.cpp",
40  "../src/register.cpp",
41  "../src/stack_data_repeater.cpp",
42  "../src/stack_preprocess.cpp",
43  "../src/symbols_file.cpp",
44  "../src/utilities.cpp",
45  "../src/virtual_runtime.cpp",
46  "../src/virtual_thread.cpp",
47  "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp",
48  "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_death_recipient.cpp",
49  "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_service.cpp",
50  "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_stub.cpp",
51  "${OHOS_PROFILER_DIR}/device/services/profiler_service/src/trace_file_helper.cpp",
52  "${OHOS_PROFILER_DIR}/device/services/profiler_service/src/trace_file_writer.cpp",
53]
54
55common_deps = [
56  "${OHOS_PROFILER_DIR}/device/services/shared_memory:shared_memory_source",
57  "${OHOS_PROFILER_DIR}/proto_encoder:proto_encoder_source",
58  "${OHOS_PROFILER_DIR}/protos/services:plugin_service_proto",
59  "${OHOS_PROFILER_DIR}/protos/services:profiler_service_all_type_source",
60  "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp",
61  "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp_standard",
62  "../../../base:hiprofiler_base",
63]
64
65config("native_daemon_test_config") {
66  cflags = code_check_flag
67  ldflags = []
68  defines = []
69
70  cflags += [
71    "-Dprivate=public",
72    "-Dprotected=public",
73  ]  # allow test code access private members
74  if (native_daemon_test_coverage && is_ohos) {
75    defines += [ "TEST_COVERAGE" ]
76    cflags += [
77      "-fprofile-arcs",
78      "-ftest-coverage",
79    ]
80    ldflags += [ "--coverage" ]
81  }
82
83  defines += [ "DEFAULT_LOG_LEVEL=LEVEL_VERBOSE" ]
84  defines += [
85    "HAVE_LIBUNWINDER=1",
86    "HIPERF_DEBUG",
87    "HIPERF_DEBUG_PRINTF",
88    "CONFIG_NO_HILOG",
89  ]
90  defines += [ "target_cpu_${target_cpu}" ]
91
92  include_dirs = [
93    "../include",
94    "../../../base/include",
95    "../src/",
96    "../../api/include",
97    "../../api/src",
98    "../../native_hook/include",
99    "../../native_hook/src",
100    "${OHOS_PROFILER_DIR}/interfaces/kits",
101    "${OHOS_PROFILER_DIR}/device/services/ipc/include",
102    "${OHOS_PROFILER_DIR}/device/services/shared_memory/include",
103    "${native_daemon_path}/test/unittest/common/native/include",
104    "${native_daemon_path}/include",
105    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include",
106    "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include",
107    "${OHOS_PROFILER_DIR}/device/services/profiler_service/src",
108  ]
109}
110
111ohos_unittest("native_daemon_ut") {
112  configs = [ ":native_daemon_test_config" ]
113  module_out_path = module_output_path
114  resource_config_file = "${OHOS_PROFILER_DIR}/device/ohos_test.xml"
115  deps = common_deps
116  use_exceptions = true
117  sources = sources_base
118  if (is_linux) {
119    static_link = false
120  }
121  external_deps = [
122    "ability_base:extractortool",
123    "access_token:libaccesstoken_sdk",
124    "access_token:libtokensetproc_shared",
125    "bounds_checking_function:libsec_shared",
126    "faultloggerd:libunwinder",
127    "googletest:gtest",
128    "init:libbegetutil",
129    "openssl:libcrypto_shared",
130    "protobuf:protobuf_lite",
131    "safwk:system_ability_fwk",
132    "zlib:libz",
133  ]
134  defines = [ "ENABLE_HAP_EXTRACTOR" ]
135  if (current_toolchain != host_toolchain) {
136    defines += [ "HAVE_HILOG" ]
137    external_deps += [ "hilog:libhilog" ]
138  }
139}
140
141group("unittest") {
142  testonly = true
143  if (native_daemon_target_host) {
144    deps = [ ":native_daemon_ut(${host_toolchain})" ]
145  } else {
146    deps = [ ":native_daemon_ut" ]
147  }
148}
149