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("../../../base/config.gni") 16import("native_daemon.gni") 17 18module_output_path = "${OHOS_PROFILER_TEST_MODULE_OUTPUT_PATH}/device" 19 20sources_base = [ 21 "unittest/common/native/callstack_test.cpp", 22 "unittest/common/native/debug_logger_test.cpp", 23 "unittest/common/native/hashlist_test.cpp", 24 "unittest/common/native/hook_manager_test.cpp", 25 "unittest/common/native/hook_service_test.cpp", 26 "unittest/common/native/register_test.cpp", 27 "unittest/common/native/stack_preprocess_test.cpp", 28 "unittest/common/native/symbols_file_test.cpp", 29 "unittest/common/native/utilities_test.cpp", 30 "unittest/common/native/virtual_thread_test.cpp", 31 "unittest/common/native/virtual_runtime_test.cpp", 32 "../../api/src/buffer_writer.cpp", 33 "../../api/src/command_poller.cpp", 34 "../../api/src/writer_adapter.cpp", 35 "../src/hook_manager.cpp", 36 "../src/call_stack.cpp", 37 "../src/debug_logger.cpp", 38 "../src/dwarf_encoding.cpp", 39 "../src/get_thread_id.cpp", 40 "../src/hook_service.cpp", 41 "../src/register.cpp", 42 "../src/stack_data_repeater.cpp", 43 "../src/stack_preprocess.cpp", 44 "../src/symbols_file.cpp", 45 "../src/utilities.cpp", 46 "../src/virtual_runtime.cpp", 47 "../src/virtual_thread.cpp", 48 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_config.cpp", 49 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_death_recipient.cpp", 50 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_service.cpp", 51 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_stub.cpp", 52 "${OHOS_PROFILER_DIR}/device/services/profiler_service/src/trace_file_helper.cpp", 53 "${OHOS_PROFILER_DIR}/device/services/profiler_service/src/trace_file_writer.cpp", 54] 55 56common_deps = [ 57 "${OHOS_PROFILER_DIR}/device/plugins/network_profiler/service:network_profiler_service", 58 "${OHOS_PROFILER_DIR}/device/services/shared_memory:shared_memory_source", 59 "${OHOS_PROFILER_DIR}/proto_encoder:proto_encoder_source", 60 "${OHOS_PROFILER_DIR}/protos/services:plugin_service_proto", 61 "${OHOS_PROFILER_DIR}/protos/services:profiler_service_all_type_source", 62 "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp", 63 "${OHOS_PROFILER_DIR}/protos/types/plugins/native_hook:native_hook_cpp_standard", 64 "../../../base:hiprofiler_base", 65] 66 67config("native_daemon_test_config") { 68 cflags = code_check_flag 69 ldflags = [] 70 defines = [] 71 72 cflags += [ 73 "-Dprivate=public", 74 "-Dprotected=public", 75 ] # allow test code access private members 76 if (native_daemon_test_coverage && is_ohos) { 77 defines += [ "TEST_COVERAGE" ] 78 cflags += [ 79 "-fprofile-arcs", 80 "-ftest-coverage", 81 ] 82 ldflags += [ "--coverage" ] 83 } 84 85 defines += [ "DEFAULT_LOG_LEVEL=LEVEL_VERBOSE" ] 86 defines += [ 87 "HAVE_LIBUNWINDER=1", 88 "HIPERF_DEBUG", 89 "HIPERF_DEBUG_PRINTF", 90 "CONFIG_NO_HILOG", 91 ] 92 defines += [ "target_cpu_${target_cpu}" ] 93 94 include_dirs = [ 95 "../include", 96 "../../../base/include", 97 "../src/", 98 "../../api/include", 99 "../../api/src", 100 "../../native_hook/include", 101 "../../native_hook/src", 102 "${OHOS_PROFILER_DIR}/interfaces/kits", 103 "${OHOS_PROFILER_DIR}/device/services/ipc/include", 104 "${OHOS_PROFILER_DIR}/device/services/shared_memory/include", 105 "${native_daemon_path}/test/unittest/common/native/include", 106 "${native_daemon_path}/include", 107 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/include", 108 "${OHOS_PROFILER_DIR}/device/plugins/native_daemon/native_memory_profiler_sa/util/include", 109 "${OHOS_PROFILER_DIR}/device/services/profiler_service/src", 110 ] 111} 112 113ohos_unittest("native_daemon_ut") { 114 configs = [ ":native_daemon_test_config" ] 115 module_out_path = module_output_path 116 resource_config_file = "${OHOS_PROFILER_DIR}/device/ohos_test.xml" 117 deps = common_deps 118 use_exceptions = true 119 sources = sources_base 120 if (is_linux) { 121 static_link = false 122 } 123 external_deps = [ 124 "ability_base:extractortool", 125 "access_token:libaccesstoken_sdk", 126 "access_token:libtokensetproc_shared", 127 "bounds_checking_function:libsec_shared", 128 "c_utils:utils", 129 "faultloggerd:libunwinder", 130 "googletest:gtest", 131 "hisysevent:libhisysevent", 132 "init:libbegetutil", 133 "ipc:ipc_core", 134 "openssl:libcrypto_shared", 135 "protobuf:protobuf_lite", 136 "safwk:system_ability_fwk", 137 "samgr:samgr_proxy", 138 "zlib:libz", 139 ] 140 defines = [ "ENABLE_HAP_EXTRACTOR" ] 141 if (current_toolchain != host_toolchain) { 142 defines += [ "HAVE_HILOG" ] 143 external_deps += [ "hilog:libhilog" ] 144 } 145} 146 147group("unittest") { 148 testonly = true 149 if (native_daemon_target_host) { 150 deps = [ ":native_daemon_ut(${host_toolchain})" ] 151 } else { 152 deps = [ ":native_daemon_ut" ] 153 } 154} 155