1# Copyright (c) Huawei Technologies Co., Ltd. 2023. 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/ohos.gni") 15import("../build/test.gni") 16import("../build/ts.gni") 17import("test_ts.gni") 18 19if (is_test) { 20 ohos_unittest("trace_streamer_ut") { 21 sources = [ 22 "unittest/base/export_test.cpp", # Don't comment, for common method 23 "unittest/base/file_test.cpp", 24 "unittest/ebpf/bio_parser_test.cpp", 25 "unittest/ebpf/ebpf_file_system_test.cpp", 26 "unittest/ebpf/ebpf_parser_test.cpp", 27 "unittest/ebpf/paged_memory_parser_test.cpp", 28 "unittest/filter/animation_filter_test.cpp", 29 "unittest/filter/app_start_filter_test.cpp", 30 "unittest/filter/binder_filter_test.cpp", 31 "unittest/filter/clock_filter_test.cpp", 32 "unittest/filter/cpu_filter_test.cpp", 33 "unittest/filter/filter_filter_test.cpp", 34 "unittest/filter/frame_filter_test.cpp", 35 "unittest/filter/irq_filter_test.cpp", 36 "unittest/filter/measure_filter_test.cpp", 37 "unittest/filter/process_filter_test.cpp", 38 "unittest/filter/slice_filter_test.cpp", 39 "unittest/filter/task_pool_filter_test.cpp", 40 "unittest/interface/rpc_server_test.cpp", 41 "unittest/interface/split_file_data_test.cpp", 42 "unittest/interface/wasm_func_test.cpp", 43 "unittest/pbreader/parser_pbreader_test.cpp", 44 "unittest/pbreader/proto_reader_test.cpp", 45 "unittest/pbreader_parser/arkts/js_cpu_profiler_test.cpp", 46 "unittest/pbreader_parser/arkts/js_memory_test.cpp", 47 "unittest/pbreader_parser/diskio_parser_test.cpp", 48 "unittest/pbreader_parser/hidump_parser_test.cpp", 49 "unittest/pbreader_parser/hilog_parser_test.cpp", 50 "unittest/pbreader_parser/hisys_event_parser_test.cpp", 51 "unittest/pbreader_parser/htrace_binder_event_test.cpp", 52 "unittest/pbreader_parser/htrace_cpu_detail_parser_test.cpp", 53 "unittest/pbreader_parser/htrace_event_parser_test.cpp", 54 "unittest/pbreader_parser/htrace_irq_event_test.cpp", 55 "unittest/pbreader_parser/native_memory/native_hook_parser_test.cpp", 56 "unittest/pbreader_parser/pbreader_cpu_data_parser_test.cpp", 57 "unittest/pbreader_parser/pbreader_ffrt_parser_test.cpp", 58 "unittest/pbreader_parser/pbreader_mem_parser_test.cpp", 59 "unittest/pbreader_parser/pbreader_network_parser_test.cpp", 60 "unittest/pbreader_parser/pbreader_process_parser_test.cpp", 61 "unittest/pbreader_parser/pbreader_sys_mem_parser_test.cpp", 62 "unittest/pbreader_parser/pbreader_sys_vmem_parser_test.cpp", 63 "unittest/pbreader_parser/pbreader_xpower_parser_test.cpp", 64 "unittest/pbreader_parser/smaps_parser_test.cpp", 65 "unittest/ptreader_parser/event_parser_test.cpp", 66 "unittest/ptreader_parser/ptreader_parser_test.cpp", 67 "unittest/query/query_file_test.cpp", 68 "unittest/query/query_metrics_test.cpp", 69 "unittest/query/span_join_test.cpp", 70 "unittest/query/sqllite_prepar_cache_data_test.cpp", 71 "unittest/rawtrace/ftrace_field_processor_test.cpp", 72 "unittest/rawtrace/rawtrace_cpu_detail_parse_test.cpp", 73 "unittest/rawtrace/rawtrace_parser_test.cpp", 74 "unittest/table/table_test.cpp", 75 ] 76 77 deps = [ 78 "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/smartperf_host:ts_all_sph_cpp", 79 "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/cpu_data:ts_cpu_data_cpp", 80 "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/diskio_data:ts_diskio_data_cpp", 81 "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/ffrt_profiler:ts_ffrt_profiler_cpp", 82 "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/ftrace_data/${device_kernel_version}:ts_ftrace_data_cpp", 83 "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hidump_data:ts_hidump_data_cpp", 84 "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hilog_data:ts_hilog_data_cpp", 85 "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hisysevent_data:ts_hisysevent_data_cpp", 86 "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/js_memory:ts_js_memory_data_cpp", 87 "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/memory_data:ts_memory_data_cpp", 88 "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/native_hook:ts_native_hook_cpp", 89 "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/network_data:ts_network_data_cpp", 90 "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/process_data:ts_process_data_cpp", 91 "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/test_data:test_data_cpp", 92 "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/xpower_data:ts_xpower_data_cpp", 93 "${SRC}/parser/rawtrace_parser:rawtrace_parser", 94 "${THIRD_PARTY}/bounds_checking_function:libsec_static", 95 "${THIRD_PARTY}/googletest:gtest", 96 "${THIRD_PARTY}/googletest:gtest_main", 97 "${THIRD_PARTY}/protobuf:protobuf_lite_static", 98 "${THIRD_PARTY}/protobuf:protobuf_static", 99 "../src:trace_streamer_source", 100 "../src/parser/pbreader_parser:pbreader_parser_src", 101 "../src/proto_reader:proto_reader", 102 ] 103 public_configs = [] 104 if (enable_stream_extend) { 105 sources += 106 [ "${EXTEND_TEST}/unittest/pbreader/pbreader_stream_parser_test.cpp" ] 107 public_configs += 108 [ "${EXTEND_SRC}/parser/pbreader_stream_parser:pbreader_stream_cfg" ] 109 deps += 110 [ "${EXTEND_SRC}/parser/pbreader_stream_parser:stream_extend_parser" ] 111 } 112 include_dirs = [ 113 "${SRC}", 114 "${SRC}/trace_data", 115 "${SRC}/table", 116 "${SRC}/table/base", 117 "${SRC}/filter", 118 "${SRC}/metrics", 119 "${SRC}/base", 120 "${SRC}/rpc", 121 "${SRC}/metrics", 122 "${SRC}/include", 123 "${SRC}/trace_streamer", 124 "${SRC}/parser/ptreader_parser", 125 "${SRC}/parser/ptreader_parser/bytrace_parser", 126 "${SRC}/parser", 127 "${SRC}/cfg", 128 "${SRC}/metrics", 129 "${SRC}/parser/ebpf_parser", 130 "${SRC}/parser/hiperf_parser", 131 "${SRC}/parser/hiperf_parser/include", 132 "${SRC}/proto_reader", 133 "${SRC}/proto_reader/include", 134 "${SRC}/table/base/include", 135 "..", 136 "unittest/base", 137 "${THIRD_PARTY}/googletest/googletest/include/gtest", 138 "${THIRD_PARTY}/protobuf/src", 139 "${THIRD_PARTY}/protobuf/src/google/protobuf", 140 "${THIRD_PARTY}/json/single_include/nlohmann", 141 "${THIRD_PARTY}/perf_include/libbpf", 142 "${THIRD_PARTY}/perf_include/include", 143 "${THIRD_PARTY}/perf_include", 144 "${THIRD_PARTY}/perf_include/linux", 145 "${THIRD_PARTY}/sqlite/include", 146 "${THIRD_PARTY}/bounds_checking_function/include", 147 "${THIRD_PARTY}/json/single_include/nlohmann", 148 "${SRC}/parser/pbreader_parser", 149 "${SRC}/parser/pbreader_parser/htrace_parser", 150 "${SRC}/proto_reader", 151 "${SRC}/proto_reader/include", 152 "${SRC}/metrics", 153 "${SRC}/parser/rawtrace_parser", 154 ] 155 156 cflags = [ 157 "-Wno-inconsistent-missing-override", 158 "-Dprivate=public", #allow test code access private members 159 "-Dprotected=public", #allow test code access protect members 160 "-fprofile-arcs", 161 "-ftest-coverage", 162 "-Wno-unused-command-line-argument", 163 "-Wno-format", 164 "-Wno-unused-const-variable", 165 "-Wno-unused-variable", 166 "-Wno-used-but-marked-unused", 167 ] 168 ldflags = [ 169 "-fprofile-arcs", 170 "-ftest-coverage", 171 "--coverage", 172 ] 173 cflags += [ 174 # clang coverage options: 175 "--coverage", 176 "-mllvm", 177 "-limited-coverage-experimental=true", 178 "-fno-use-cxa-atexit", 179 "-DIS_UT", 180 "-DIS_WASM", 181 ] 182 if (is_mac) { 183 lib_dirs = [ "/usr/local/opt/llvm/lib" ] 184 } 185 libs = [ "LLVMCore" ] 186 } 187} 188 189# this is the dest for ohos.build 190if (is_test) { 191 group("unittest") { 192 testonly = true 193 deps = [ ":trace_streamer_ut" ] 194 } 195} else if (target == "fuzz") { 196 group("fuzztest") { 197 testonly = true 198 deps = [ 199 "test_fuzzer/bytrace_fuzzer:fuzztest", 200 "test_fuzzer/htrace_fuzzer:fuzztest", 201 "test_fuzzer/selector_fuzzer:fuzztest", 202 ] 203 } 204} 205