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") # nogncheck 25} else { 26 import("//build/config/sanitizers/sanitizers.gni") # nogncheck 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:unittests", 63 ] 64 65 sources = [ 66 "cpu_reader_unittest.cc", 67 "cpu_stats_parser_unittest.cc", 68 "event_info_unittest.cc", 69 "ftrace_config_muxer_unittest.cc", 70 "ftrace_config_unittest.cc", 71 "ftrace_controller_unittest.cc", 72 "ftrace_print_filter_unittest.cc", 73 "ftrace_procfs_unittest.cc", 74 "printk_formats_parser_unittest.cc", 75 "proto_translation_table_unittest.cc", 76 "vendor_tracepoints_unittest.cc", 77 ] 78} 79 80perfetto_proto_library("test_messages_@TYPE@") { 81 proto_generators = [ 82 "cpp", 83 "lite", 84 "zero", 85 ] 86 sources = [ "test/test_messages.proto" ] 87 proto_path = perfetto_root_path 88} 89 90# These tests require access to a real ftrace implementation and must 91# run with sudo. 92source_set("integrationtests") { 93 testonly = true 94 deps = [ 95 ":ftrace", 96 ":ftrace_procfs", 97 ":test_support", 98 "../../../../gn:default_deps", 99 "../../../../gn:gtest_and_gmock", 100 "../../../base", 101 "../../../tracing/core", 102 ] 103 sources = [ "ftrace_procfs_integrationtest.cc" ] 104} 105 106source_set("ftrace") { 107 public_deps = [ 108 "../../../../protos/perfetto/config/ftrace:cpp", 109 "../../../../protos/perfetto/trace/ftrace:zero", 110 "../../../tracing/core", 111 ] 112 deps = [ 113 ":ftrace_procfs", 114 "..:data_source", 115 "../../../../gn:default_deps", 116 "../../../../include/perfetto/ext/traced", 117 "../../../../protos/perfetto/common:zero", 118 "../../../../protos/perfetto/trace:zero", 119 "../../../../protos/perfetto/trace/interned_data:zero", 120 "../../../../protos/perfetto/trace/profiling:zero", 121 "../../../android_internal:lazy_library_loader", 122 "../../../base", 123 "../../../kallsyms", 124 "../../../kernel_utils:syscall_table", 125 "../../../protozero", 126 "format_parser", 127 ] 128 sources = [ 129 "atrace_hal_wrapper.cc", 130 "atrace_hal_wrapper.h", 131 "atrace_wrapper.cc", 132 "atrace_wrapper.h", 133 "compact_sched.cc", 134 "compact_sched.h", 135 "cpu_reader.cc", 136 "cpu_reader.h", 137 "cpu_stats_parser.cc", 138 "cpu_stats_parser.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_print_filter.cc", 153 "ftrace_print_filter.h", 154 "ftrace_stats.cc", 155 "ftrace_stats.h", 156 "printk_formats_parser.cc", 157 "printk_formats_parser.h", 158 "proto_translation_table.cc", 159 "proto_translation_table.h", 160 "vendor_tracepoints.cc", 161 "vendor_tracepoints.h", 162 ] 163} 164 165source_set("ftrace_procfs") { 166 deps = [ 167 "../../../../gn:default_deps", 168 "../../../base", 169 ] 170 sources = [ 171 "ftrace_procfs.cc", 172 "ftrace_procfs.h", 173 ] 174} 175 176if (enable_perfetto_benchmarks) { 177 source_set("benchmarks") { 178 testonly = true 179 deps = [ 180 ":ftrace", 181 ":test_support", 182 "../../../../gn:benchmark", 183 "../../../../gn:default_deps", 184 ] 185 sources = [ "cpu_reader_benchmark.cc" ] 186 } 187} 188 189perfetto_fuzzer_test("cpu_reader_fuzzer") { 190 testonly = true 191 sources = [ "cpu_reader_fuzzer.cc" ] 192 deps = [ 193 ":ftrace", 194 ":test_support", 195 "../../../../gn:default_deps", 196 ] 197} 198