xref: /developtools/profiler/hiebpf/test/BUILD.gn (revision 06f6ba60)
106f6ba60Sopenharmony_ci# Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
206f6ba60Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
306f6ba60Sopenharmony_ci# you may not use this file except in compliance with the License.
406f6ba60Sopenharmony_ci# You may obtain a copy of the License at
506f6ba60Sopenharmony_ci#
606f6ba60Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
706f6ba60Sopenharmony_ci#
806f6ba60Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
906f6ba60Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
1006f6ba60Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1106f6ba60Sopenharmony_ci# See the License for the specific language governing permissions and
1206f6ba60Sopenharmony_ci# limitations under the License.
1306f6ba60Sopenharmony_ci
1406f6ba60Sopenharmony_ciimport("//build/test.gni")
1506f6ba60Sopenharmony_ciimport("//developtools/profiler/device/base/config.gni")
1606f6ba60Sopenharmony_ci
1706f6ba60Sopenharmony_cimodule_output_path = "${OHOS_PROFILER_TEST_MODULE_OUTPUT_PATH}/hiebpf"
1806f6ba60Sopenharmony_ciconfig("module_private_config") {
1906f6ba60Sopenharmony_ci  visibility = [ ":*" ]
2006f6ba60Sopenharmony_ci  if (current_toolchain != host_toolchain) {
2106f6ba60Sopenharmony_ci    defines = [
2206f6ba60Sopenharmony_ci      "HAVE_HILOG",
2306f6ba60Sopenharmony_ci      "BPF_LOGGER_DEBUG",
2406f6ba60Sopenharmony_ci      "HH_LOGGER_DEBUG",
2506f6ba60Sopenharmony_ci    ]
2606f6ba60Sopenharmony_ci  }
2706f6ba60Sopenharmony_ci}
2806f6ba60Sopenharmony_ci
2906f6ba60Sopenharmony_ciohos_unittest("hiebpf_ut") {
3006f6ba60Sopenharmony_ci  module_out_path = module_output_path
3106f6ba60Sopenharmony_ci  sources = [
3206f6ba60Sopenharmony_ci    "unittest/bpf_controller_test.cpp",
3306f6ba60Sopenharmony_ci    "unittest/bpf_log_reader_test.cpp",
3406f6ba60Sopenharmony_ci    "unittest/command_helper_test.cpp",
3506f6ba60Sopenharmony_ci    "unittest/elf_symbol_info_test.cpp",
3606f6ba60Sopenharmony_ci    "unittest/hhlog_test.cpp",
3706f6ba60Sopenharmony_ci    "unittest/hiebpf_data_file_test.cpp",
3806f6ba60Sopenharmony_ci    "unittest/ipc_unix_socket_test.cpp",
3906f6ba60Sopenharmony_ci    "unittest/kernel_symbol_info_test.cpp",
4006f6ba60Sopenharmony_ci    "unittest/libbpf_logger_test.cpp",
4106f6ba60Sopenharmony_ci    "unittest/maps_info_test.cpp",
4206f6ba60Sopenharmony_ci    "unittest/ringbuffer_test.cpp",
4306f6ba60Sopenharmony_ci  ]
4406f6ba60Sopenharmony_ci  deps = [ "${OHOS_PROFILER_DIR}/hiebpf:hiebpf_source_common" ]
4506f6ba60Sopenharmony_ci  include_dirs = [
4606f6ba60Sopenharmony_ci    "unittest/include",
4706f6ba60Sopenharmony_ci    "${OHOS_PROFILER_DIR}/hiebpf/include",
4806f6ba60Sopenharmony_ci  ]
4906f6ba60Sopenharmony_ci  cflags = [
5006f6ba60Sopenharmony_ci    "-Wno-inconsistent-missing-override",
5106f6ba60Sopenharmony_ci    "-Dprivate=public",  #allow test code access private members
5206f6ba60Sopenharmony_ci  ]
5306f6ba60Sopenharmony_ci  external_deps = [
5406f6ba60Sopenharmony_ci    "bounds_checking_function:libsec_shared",
5506f6ba60Sopenharmony_ci    "googletest:gtest",
5606f6ba60Sopenharmony_ci    "hilog:libhilog_base",
5706f6ba60Sopenharmony_ci  ]
5806f6ba60Sopenharmony_ci  configs = [ ":module_private_config" ]
5906f6ba60Sopenharmony_ci  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
6006f6ba60Sopenharmony_ci  part_name = "${OHOS_PROFILER_PART_NAME}"
6106f6ba60Sopenharmony_ci  resource_config_file = "ohos_test.xml"
6206f6ba60Sopenharmony_ci}
6306f6ba60Sopenharmony_ci
6406f6ba60Sopenharmony_cigroup("unittest") {
6506f6ba60Sopenharmony_ci  testonly = true
6606f6ba60Sopenharmony_ci  if (target_cpu == "arm64" && !is_asan && use_musl) {
6706f6ba60Sopenharmony_ci    if (build_variant == "root") {
6806f6ba60Sopenharmony_ci      deps = [ ":hiebpf_ut" ]
6906f6ba60Sopenharmony_ci    }
7006f6ba60Sopenharmony_ci  }
7106f6ba60Sopenharmony_ci}
7206f6ba60Sopenharmony_ci
7306f6ba60Sopenharmony_ciohos_executable("hiebpf_test_demo") {
7406f6ba60Sopenharmony_ci  cflags = [ "-O0" ]
7506f6ba60Sopenharmony_ci  sources = [ "hiebpf_test_demo.cpp" ]
7606f6ba60Sopenharmony_ci  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
7706f6ba60Sopenharmony_ci  part_name = "${OHOS_PROFILER_PART_NAME}"
7806f6ba60Sopenharmony_ci}
79