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. 13import("//build/test.gni") 14import("../../../base/config.gni") 15 16module_output_path = "${OHOS_PROFILER_TEST_MODULE_OUTPUT_PATH}/device" 17 18config("module_private_config") { 19 visibility = [ ":*" ] 20 defines = [ 21 "is_ohos=1", 22 "HAVE_LIBUNWIND=1", 23 "HIPERF_DEBUG", 24 "CONFIG_NO_HILOG", 25 "target_cpu_${target_cpu}", 26 ] 27 28 if (current_toolchain != host_toolchain) { 29 defines += [ "HAVE_HILOG" ] 30 } 31} 32 33ohos_unittest("nativehook_ut") { 34 module_out_path = module_output_path 35 sources = [ 36 "../../memory_plugin/src/buffer_splitter.cpp", 37 "unittest/check_hook_data_test.cpp", 38 "unittest/hook_client_test.cpp", 39 "unittest/hook_socket_client_test.cpp", 40 "unittest/stack_writer_test.cpp", 41 ] 42 43 public_deps = [ 44 "${OHOS_PROFILER_DIR}/device/services/profiler_service:profiler_service", 45 "${OHOS_PROFILER_DIR}/device/services/shared_memory:shared_memory", 46 "${OHOS_PROFILER_DIR}/protos/services:plugin_services_proto", 47 "${OHOS_PROFILER_DIR}/protos/services:service_types_proto", 48 ] 49 deps = [ 50 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon:native_daemon", 51 "${OHOS_PROFILER_DIR}/device/plugins/native_hook:native_hook", 52 "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp", 53 "//third_party/googletest:gtest_main", 54 "//utils/native/base:utilsecurec", 55 ] 56 57 include_dirs = [ 58 "../include", 59 "../../native_daemon/include", 60 "../../api/include", 61 "../../api/src", 62 "../../memory_plugin/include", 63 "../../../base/include/", 64 "${OHOS_PROFILER_DIR}/interfaces/kits", 65 "${OHOS_PROFILER_DIR}/device/services/ipc/include", 66 "${OHOS_PROFILER_DIR}/device/services/shared_memory/include", 67 "${OHOS_PROFILER_DIR}/device/services/profiler_service/include", 68 "//third_party/googletest/googletest/include/gtest", 69 "//third_party/musl/include/musl_preinit_common.h", 70 "//utils/native/base/include", 71 ] 72 73 cflags = [ 74 "-Wno-inconsistent-missing-override", 75 "-Dprivate=public", #allow test code access private members 76 "-Dprotected=public", #allow test code access private members 77 ] 78 79 external_deps = [ "hiviewdfx_hilog_native:libhilog" ] 80 configs = [ ":module_private_config" ] 81 subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" 82 part_name = "${OHOS_PROFILER_PART_NAME}" 83} 84group("unittest") { 85 testonly = true 86 deps = [ ":nativehook_ut" ] 87} 88