1# Copyright (C) 2017 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15import("../../../../gn/fuzzer.gni") 16import("../../../../gn/perfetto.gni") 17import("../../../../gn/proto_library.gni") 18import("../../../../gn/test.gni") 19 20assert(target_os != "win") 21 22# For use_libfuzzer. 23if (perfetto_root_path == "//") { 24 import("//gn/standalone/sanitizers/vars.gni") 25} else { 26 import("//build/config/sanitizers/sanitizers.gni") 27} 28 29source_set("test_support") { 30 testonly = true 31 deps = [ 32 ":ftrace", 33 ":ftrace_procfs", 34 "../../../../gn:default_deps", 35 "../../../base:test_support", 36 "../../../protozero", 37 ] 38 public_deps = [ "../../../protozero" ] 39 40 sources = [ 41 "test/cpu_reader_support.cc", 42 "test/cpu_reader_support.h", 43 ] 44} 45 46perfetto_unittest_source_set("unittests") { 47 testonly = true 48 deps = [ 49 ":ftrace", 50 ":ftrace_procfs", 51 ":test_messages_cpp", 52 ":test_messages_lite", 53 ":test_messages_zero", 54 ":test_support", 55 "../../../../gn:default_deps", 56 "../../../../gn:gtest_and_gmock", 57 "../../../../protos/perfetto/trace:cpp", 58 "../../../../protos/perfetto/trace/ftrace:cpp", 59 "../../../../protos/perfetto/trace/ftrace:zero", 60 "../../../base:test_support", 61 "../../../tracing/test:test_support", 62 "format_parser", 63 "format_parser:unittests", 64 ] 65 sources = [ 66 "cpu_reader_unittest.cc", 67 "cpu_stats_parser_unittest.cc", 68 "discover_vendor_tracepoints_unittest.cc", 69 "event_info_unittest.cc", 70 "ftrace_config_muxer_unittest.cc", 71 "ftrace_config_unittest.cc", 72 "ftrace_controller_unittest.cc", 73 "ftrace_procfs_unittest.cc", 74 "printk_formats_parser_unittest.cc", 75 "proto_translation_table_unittest.cc", 76 ] 77} 78 79perfetto_proto_library("test_messages_@TYPE@") { 80 proto_generators = [ 81 "cpp", 82 "lite", 83 "zero", 84 ] 85 sources = [ "test/test_messages.proto" ] 86 proto_path = perfetto_root_path 87} 88 89# These tests require access to a real ftrace implementation and must 90# run with sudo. 91source_set("integrationtests") { 92 testonly = true 93 deps = [ 94 ":ftrace", 95 ":ftrace_procfs", 96 ":test_support", 97 "../../../../gn:default_deps", 98 "../../../../gn:gtest_and_gmock", 99 "../../../base", 100 "../../../tracing/core", 101 ] 102 sources = [ "ftrace_procfs_integrationtest.cc" ] 103} 104 105source_set("ftrace") { 106 public_deps = [ 107 "../../../../protos/perfetto/config/ftrace:cpp", 108 "../../../../protos/perfetto/trace/ftrace:zero", 109 "../../../tracing/core", 110 ] 111 deps = [ 112 ":ftrace_procfs", 113 "..:data_source", 114 "../../../../gn:default_deps", 115 "../../../../include/perfetto/ext/traced", 116 "../../../../protos/perfetto/common:zero", 117 "../../../../protos/perfetto/trace:zero", 118 "../../../../protos/perfetto/trace/interned_data:zero", 119 "../../../../protos/perfetto/trace/profiling:zero", 120 "../../../android_internal:lazy_library_loader", 121 "../../../base", 122 "../../../kallsyms", 123 "../../../protozero", 124 "format_parser", 125 ] 126 sources = [ 127 "atrace_hal_wrapper.cc", 128 "atrace_hal_wrapper.h", 129 "atrace_wrapper.cc", 130 "atrace_wrapper.h", 131 "compact_sched.cc", 132 "compact_sched.h", 133 "cpu_reader.cc", 134 "cpu_reader.h", 135 "cpu_stats_parser.cc", 136 "cpu_stats_parser.h", 137 "discover_vendor_tracepoints.cc", 138 "discover_vendor_tracepoints.h", 139 "event_info.cc", 140 "event_info.h", 141 "event_info_constants.cc", 142 "event_info_constants.h", 143 "ftrace_config_muxer.cc", 144 "ftrace_config_muxer.h", 145 "ftrace_config_utils.cc", 146 "ftrace_config_utils.h", 147 "ftrace_controller.cc", 148 "ftrace_controller.h", 149 "ftrace_data_source.cc", 150 "ftrace_data_source.h", 151 "ftrace_metadata.h", 152 "ftrace_stats.cc", 153 "ftrace_stats.h", 154 "printk_formats_parser.cc", 155 "printk_formats_parser.h", 156 "proto_translation_table.cc", 157 "proto_translation_table.h", 158 ] 159} 160 161source_set("ftrace_procfs") { 162 deps = [ 163 "../../../../gn:default_deps", 164 "../../../base", 165 ] 166 sources = [ 167 "ftrace_procfs.cc", 168 "ftrace_procfs.h", 169 ] 170} 171 172if (enable_perfetto_benchmarks) { 173 source_set("benchmarks") { 174 testonly = true 175 deps = [ 176 ":ftrace", 177 ":test_support", 178 "../../../../gn:benchmark", 179 "../../../../gn:default_deps", 180 ] 181 sources = [ "cpu_reader_benchmark.cc" ] 182 } 183} 184 185perfetto_fuzzer_test("cpu_reader_fuzzer") { 186 testonly = true 187 sources = [ "cpu_reader_fuzzer.cc" ] 188 deps = [ 189 ":ftrace", 190 ":test_support", 191 "../../../../gn:default_deps", 192 ] 193} 194