• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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")
15import(
16    "//developtools/profiler/device/plugins/native_daemon/test/native_daemon.gni")
17import("../../../base/config.gni")
18
19module_output_path = "${OHOS_PROFILER_TEST_MODULE_OUTPUT_PATH}/device"
20
21sources_base = [
22  "unittest/common/native/callstack_test.cpp",
23  "unittest/common/native/debug_logger_test.cpp",
24  "unittest/common/native/elf_parser_test.cpp",
25  "unittest/common/native/hashlist_test.cpp",
26  "unittest/common/native/hook_manager_test.cpp",
27  "unittest/common/native/hook_service_test.cpp",
28  "unittest/common/native/register_test.cpp",
29  "unittest/common/native/symbols_file_test.cpp",
30  "unittest/common/native/utilities_test.cpp",
31  "unittest/common/native/virtual_thread_test.cpp",
32  "unittest/common/native/virtual_runtime_test.cpp",
33  "../../api/src/buffer_writer.cpp",
34  "../../api/src/command_poller.cpp",
35  "../src/hook_manager.cpp",
36  "../src/call_stack.cpp",
37  "../src/debug_logger.cpp",
38  "../src/dwarf_encoding.cpp",
39  "../src/elf_file.cpp",
40  "../src/elf_header.cpp",
41  "../src/elf_symbol.cpp",
42  "../src/get_thread_id.cpp",
43  "../src/hook_service.cpp",
44  "../src/program_header.cpp",
45  "../src/register.cpp",
46  "../src/section_header.cpp",
47  "../src/stack_data_repeater.cpp",
48  "../src/stack_preprocess.cpp",
49  "../src/symbols_file.cpp",
50  "../src/utilities.cpp",
51  "../src/virtual_runtime.cpp",
52  "../src/virtual_thread.cpp",
53]
54
55common_deps = [
56  "${OHOS_PROFILER_DIR}/device/services/shared_memory:shared_memory_source",
57  "${OHOS_PROFILER_DIR}/protos/services:plugin_service_proto",
58  "${OHOS_PROFILER_DIR}/protos/services:profiler_service_all_type_source",
59  "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp",
60  "../../../base:hiprofiler_base",
61  "//base/startup/init/interfaces/innerkits:libbegetutil",
62  "//third_party/bounds_checking_function:libsec_static",
63  "//third_party/googletest:gmock_main",
64  "//third_party/googletest:gtest_main",
65  "//third_party/libunwind:unwind_source_${target_cpu}",
66  "//third_party/zlib:libz",
67]
68
69config("native_daemon_test_config") {
70  cflags = code_check_flag
71  ldflags = []
72  defines = []
73
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 += [ "is_ohos=1" ]
85  defines += [
86    "HAVE_LIBUNWIND=1",
87    "HIPERF_DEBUG",
88    "HIPERF_DEBUG_PRINTF",
89    "CONFIG_NO_HILOG",
90  ]
91  defines += [ "target_cpu_${target_cpu}" ]
92
93  include_dirs = [
94    "../include",
95    "../../../base/include",
96    "../src/",
97    "../../api/include",
98    "../../api/src",
99    "../../native_hook/include",
100    "../../native_hook/src",
101    "${OHOS_PROFILER_DIR}/interfaces/kits",
102    "${OHOS_PROFILER_DIR}/device/services/ipc/include",
103    "${OHOS_PROFILER_DIR}/device/services/shared_memory/include",
104    "//base/startup/init/services/include/param",
105    "//third_party/googletest/googletest/include/gtest",
106    "//third_party/bounds_checking_function/include",
107    "${native_daemon_path}/test/unittest/common/native/include",
108    "${native_daemon_path}/include",
109  ]
110}
111
112ohos_unittest("native_daemon_ut") {
113  configs = [ ":native_daemon_test_config" ]
114  module_out_path = module_output_path
115  resource_config_file = "${OHOS_PROFILER_DIR}/device/ohos_test.xml"
116  deps = common_deps
117  use_exceptions = true
118  sources = sources_base
119  if (is_linux) {
120    static_link = false
121  }
122  if (current_toolchain != host_toolchain) {
123    defines = [ "HAVE_HILOG" ]
124    external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
125  }
126}
127
128group("unittest") {
129  testonly = true
130  if (native_daemon_target_host) {
131    deps = [ ":native_daemon_ut(${host_toolchain})" ]
132  } else {
133    deps = [ ":native_daemon_ut" ]
134  }
135}
136