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("//developtools/profiler/device/base/config.gni")
16
17module_output_path = "${OHOS_PROFILER_TEST_MODULE_OUTPUT_PATH}/hiebpf"
18config("module_private_config") {
19  visibility = [ ":*" ]
20  if (current_toolchain != host_toolchain) {
21    defines = [
22      "HAVE_HILOG",
23      "BPF_LOGGER_DEBUG",
24      "HH_LOGGER_DEBUG",
25    ]
26  }
27}
28
29ohos_unittest("hiebpf_ut") {
30  module_out_path = module_output_path
31  sources = [
32    "unittest/bpf_controller_test.cpp",
33    "unittest/bpf_log_reader_test.cpp",
34    "unittest/command_helper_test.cpp",
35    "unittest/elf_symbol_info_test.cpp",
36    "unittest/hhlog_test.cpp",
37    "unittest/hiebpf_data_file_test.cpp",
38    "unittest/ipc_unix_socket_test.cpp",
39    "unittest/kernel_symbol_info_test.cpp",
40    "unittest/libbpf_logger_test.cpp",
41    "unittest/maps_info_test.cpp",
42    "unittest/ringbuffer_test.cpp",
43  ]
44  deps = [ "${OHOS_PROFILER_DIR}/hiebpf:hiebpf_source_common" ]
45  include_dirs = [
46    "unittest/include",
47    "${OHOS_PROFILER_DIR}/hiebpf/include",
48  ]
49  cflags = [
50    "-Wno-inconsistent-missing-override",
51    "-Dprivate=public",  #allow test code access private members
52  ]
53  external_deps = [
54    "bounds_checking_function:libsec_shared",
55    "googletest:gtest",
56    "hilog:libhilog_base",
57  ]
58  configs = [ ":module_private_config" ]
59  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
60  part_name = "${OHOS_PROFILER_PART_NAME}"
61  resource_config_file = "ohos_test.xml"
62}
63
64group("unittest") {
65  testonly = true
66  if (target_cpu == "arm64" && !is_asan && use_musl) {
67    if (build_variant == "root") {
68      deps = [ ":hiebpf_ut" ]
69    }
70  }
71}
72
73ohos_executable("hiebpf_test_demo") {
74  cflags = [ "-O0" ]
75  sources = [ "hiebpf_test_demo.cpp" ]
76  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
77  part_name = "${OHOS_PROFILER_PART_NAME}"
78}
79