1# Copyright (c) 2023-2024 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. 13 14import("//base/hiviewdfx/hiview/hiview.gni") 15import("//build/test.gni") 16 17config("ucollection_utility_test_config") { 18 visibility = [ ":*" ] 19 20 include_dirs = [ 21 ".", 22 "$hiview_framework/native/unified_collection/collector/inner_include", 23 ] 24 25 cflags = [ "-D__UNITTEST__" ] 26} 27 28ohos_unittest("UCollectionUtilityUnitTest") { 29 module_out_path = hiview_module 30 31 configs = [ ":ucollection_utility_test_config" ] 32 33 sources = [ 34 "cpu_collector_test.cpp", 35 "gpu_collector_test.cpp", 36 "graphic_memory_collector_test.cpp", 37 "hiebpf_collector_test.cpp", 38 "hilog_collector_test.cpp", 39 "io_collector_test.cpp", 40 "memory_collector_test.cpp", 41 "network_collector_test.cpp", 42 "perf_collector_test.cpp", 43 "thermal_collector_test.cpp", 44 "wm_collector_test.cpp", 45 ] 46 47 deps = [ 48 "$hiview_base:hiviewbase", 49 "$hiview_base/event_report:hiview_event_report", 50 "$hiview_base/utility:hiview_utility", 51 "$hiview_interfaces/inner_api/unified_collection/utility:libucollection_utility", 52 ] 53 54 external_deps = [ 55 "access_token:libaccesstoken_sdk", 56 "access_token:libnativetoken", 57 "access_token:libtoken_setproc", 58 "c_utils:utils", 59 "ffrt:libffrt", 60 "googletest:gtest_main", 61 "hilog:libhilog", 62 "hisysevent:libhisysevent", 63 "init:libbegetutil", 64 "ipc:ipc_single", 65 "samgr:samgr_proxy", 66 "selinux_adapter:librestorecon", 67 "zlib:libz", 68 ] 69 70 defines = [] 71 if (hiview_unified_collector_ebpf_enable) { 72 defines += [ "UNIFIED_COLLECTOR_EBPF_ENABLE" ] 73 } 74 75 if (hiview_unified_collector_network_enable) { 76 defines += [ "UNIFIED_COLLECTOR_NETWORK_ENABLE" ] 77 } 78 79 if (hiview_unified_collector_graphic_enable) { 80 defines += [ "UNIFIED_COLLECTOR_GRAPHIC_ENABLE" ] 81 } 82 83 if (hiview_unified_collector_gpu_enable) { 84 defines += [ "UNIFIED_COLLECTOR_GPU_ENABLE" ] 85 } 86 87 if (hiview_unified_collector_cpu_enable) { 88 defines += [ "UNIFIED_COLLECTOR_CPU_ENABLE" ] 89 } 90 91 if (hiview_unified_collector_io_enable) { 92 defines += [ "UNIFIED_COLLECTOR_IO_ENABLE" ] 93 } 94 95 if (hiview_unified_collector_memory_enable) { 96 defines += [ "UNIFIED_COLLECTOR_MEMORY_ENABLE" ] 97 } 98 99 if (hiview_unified_collector_hilog_enable) { 100 defines += [ "UNIFIED_COLLECTOR_HILOG_ENABLE" ] 101 } 102 103 if (hiview_unified_collector_wm_enable) { 104 defines += [ "UNIFIED_COLLECTOR_WM_ENABLE" ] 105 } 106 107 if (hiview_unified_collector_process_enable) { 108 defines += [ "UNIFIED_COLLECTOR_PROCESS_ENABLE" ] 109 } 110 111 cflags = [] 112 if (has_hiperf && hiview_unified_collector_perf_enable) { 113 cflags += [ "-DHAS_HIPERF" ] 114 } 115 116 if (hiview_unified_collector_thermal_enable) { 117 defines += [ "UNIFIED_COLLECTOR_THERMAL_ENABLE" ] 118 } 119 120 if (has_hiprofiler && hiview_unified_collector_mem_profiler_enable) { 121 sources += [ "mem_profiler_collector_test.cpp" ] 122 external_deps += [ "hiprofiler:libnative_daemon_client" ] 123 } 124 125 if (thermal_manager_enable) { 126 cflags += [ "-DTHERMAL_MANAGER_ENABLE" ] 127 } 128 129 if (is_wifi_enable) { 130 external_deps += [ "wifi:wifi_sdk" ] 131 defines += [ "COMMUNICATION_WIFI_ENABLE" ] 132 } 133} 134 135config("ucollection_trace_test_config") { 136 visibility = [ ":*" ] 137 138 include_dirs = [ 139 ".", 140 "$hiview_framework/native/unified_collection/collector/impl/trace/utils/include", 141 "$hiview_framework/native/unified_collection/collector/impl/trace/include", 142 "$hiview_framework/native/unified_collection/trace_manager/include", 143 "$hiview_interfaces/inner_api/unified_collection/utility:libucollection_utility", 144 ] 145 146 cflags = [ "-D__UNITTEST__" ] 147} 148 149ohos_unittest("UCollectionTraceUnitTest") { 150 module_out_path = hiview_module 151 152 configs = [ ":ucollection_trace_test_config" ] 153 154 sources = [ "trace_collector_test.cpp" ] 155 156 deps = [ 157 "$hiview_base:hiviewbase", 158 "$hiview_base/event_report:hiview_event_report", 159 "$hiview_base/utility:hiview_utility", 160 "$hiview_framework/native/unified_collection/trace_manager:libtrace_manager", 161 "$hiview_interfaces/inner_api/unified_collection/utility:libucollection_utility", 162 ] 163 164 external_deps = [ 165 "access_token:libaccesstoken_sdk", 166 "access_token:libnativetoken", 167 "access_token:libtoken_setproc", 168 "cJSON:cjson", 169 "c_utils:utils", 170 "ffrt:libffrt", 171 "googletest:gtest_main", 172 "hilog:libhilog", 173 "init:libbegetutil", 174 "zlib:libz", 175 ] 176 177 defines = [ "UNIFIED_COLLECTOR_TRACE_ENABLE" ] 178} 179