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 "//third_party/googletest/googletest/include", 49 ] 50 cflags = [ 51 "-Wno-inconsistent-missing-override", 52 "-Dprivate=public", #allow test code access private members 53 ] 54 external_deps = [ "hilog:libhilog" ] 55 configs = [ ":module_private_config" ] 56 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 57 part_name = "${OHOS_PROFILER_PART_NAME}" 58 resource_config_file = "ohos_test.xml" 59} 60 61group("unittest") { 62 testonly = true 63 if (target_cpu == "arm64" && !is_asan && use_musl) { 64 deps = [ ":hiebpf_ut" ] 65 } 66} 67 68ohos_executable("hiebpf_test_demo") { 69 cflags = [ "-O0" ] 70 sources = [ "hiebpf_test_demo.cpp" ] 71 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 72 part_name = "${OHOS_PROFILER_PART_NAME}" 73} 74