blob: 46de5df0493d4bfe55f0aa58e7ed05e691efa3b8 [file] [log] [blame]
Primiano Tucci4f9b6d72017-12-05 20:59:16 +00001# 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
Hector Dearmancc6dcb02017-12-12 16:48:43 +000015import("../../gn/perfetto.gni")
16import("../../gn/proto_library.gni")
17import("../protozero/protozero_library.gni")
18
Hector Dearman7391c0f2018-02-02 14:20:09 +000019# For use_libfuzzer.
20if (!build_with_chromium) {
21 import("//gn/standalone/sanitizers/vars.gni")
22} else {
23 import("//build/config/sanitizers/sanitizers.gni")
24}
25
Primiano Tuccib03ba362017-12-06 09:47:41 +000026source_set("test_support") {
27 testonly = true
28 deps = [
Hector Dearmanbc8368e2018-01-25 17:34:11 +000029 ":ftrace_reader",
Primiano Tuccib03ba362017-12-06 09:47:41 +000030 "../../gn:default_deps",
31 "../protozero",
32 ]
33 sources = [
Hector Dearmanbc8368e2018-01-25 17:34:11 +000034 "test/cpu_reader_support.cc",
35 "test/cpu_reader_support.h",
Primiano Tuccib03ba362017-12-06 09:47:41 +000036 "test/scattered_stream_delegate_for_testing.cc",
37 "test/scattered_stream_delegate_for_testing.h",
38 ]
39}
40
Hector Dearman6cfec8a2018-03-14 16:54:09 +000041source_set("unittests") {
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000042 testonly = true
43 deps = [
44 ":ftrace_reader",
Hector Dearmancc6dcb02017-12-12 16:48:43 +000045 ":ftrace_reader_test_messages_lite",
46 ":ftrace_reader_test_messages_zero",
Primiano Tuccib03ba362017-12-06 09:47:41 +000047 ":test_support",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000048 "../../gn:default_deps",
49 "../../gn:gtest_deps",
Primiano Tucci20b760c2018-01-19 12:36:12 +000050 "../../protos/perfetto/trace/ftrace:lite",
Hector Dearman86cfbe12018-03-22 11:58:42 +000051 "../base:test_support",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000052 ]
53 sources = [
54 "cpu_reader_unittest.cc",
Hector Dearman83d98032017-12-11 16:37:43 +000055 "event_info_unittest.cc",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000056 "format_parser_unittest.cc",
Hector Dearman50139712018-02-23 15:43:41 +000057 "ftrace_config_muxer_unittest.cc",
Hector Dearmancb4ba322018-02-09 14:12:27 +000058 "ftrace_config_unittest.cc",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000059 "ftrace_controller_unittest.cc",
Hector Dearman50139712018-02-23 15:43:41 +000060 "ftrace_procfs_unittest.cc",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000061 "proto_translation_table_unittest.cc",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000062 ]
63}
64
Hector Dearmancc6dcb02017-12-12 16:48:43 +000065ftrace_reader_test_proto_sources = [ "test/test_messages.proto" ]
66
67protozero_library("ftrace_reader_test_messages_zero") {
68 sources = ftrace_reader_test_proto_sources
69 proto_in_dir = perfetto_root_path
Oystein Eftevaag51e06e52018-01-18 11:28:49 -080070 proto_out_dir = perfetto_root_path
Hector Dearmancc6dcb02017-12-12 16:48:43 +000071 generator_plugin_options = "wrapper_namespace=pbzero"
72}
73
74proto_library("ftrace_reader_test_messages_lite") {
Primiano Tucci20b760c2018-01-19 12:36:12 +000075 generate_python = false
Hector Dearmancc6dcb02017-12-12 16:48:43 +000076 sources = ftrace_reader_test_proto_sources
77 proto_in_dir = perfetto_root_path
Oystein Eftevaag51e06e52018-01-18 11:28:49 -080078 proto_out_dir = perfetto_root_path
Hector Dearmancc6dcb02017-12-12 16:48:43 +000079}
80
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000081# These tests require access to a real ftrace implementation and must
82# run with sudo.
Lalit Maganti79f2d7b2018-01-23 18:27:33 +000083source_set("ftrace_reader_integrationtests") {
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000084 testonly = true
85 deps = [
86 ":ftrace_reader",
Primiano Tuccib03ba362017-12-06 09:47:41 +000087 ":test_support",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000088 "../../gn:default_deps",
89 "../../gn:gtest_deps",
Primiano Tucci20b760c2018-01-19 12:36:12 +000090 "../../protos/perfetto/trace/ftrace:lite",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000091 "../base",
Hector Dearmancb4ba322018-02-09 14:12:27 +000092 "../tracing",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000093 ]
94 sources = [
95 "end_to_end_integrationtest.cc",
96 "ftrace_procfs_integrationtest.cc",
97 ]
98}
99
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000100source_set("ftrace_reader") {
101 public_deps = [
Hector Dearman3e712a02017-12-19 16:39:59 +0000102 "../../gn:gtest_prod_config",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000103 "../../include/perfetto/ftrace_reader",
Primiano Tucci20b760c2018-01-19 12:36:12 +0000104 "../../protos/perfetto/trace/ftrace:zero",
Hector Dearmancb4ba322018-02-09 14:12:27 +0000105 "../tracing",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000106 ]
107 deps = [
108 "../../gn:default_deps",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000109 "../base",
110 "../protozero",
111 ]
112 sources = [
Hector Dearmanc20f2212018-03-08 10:39:00 +0000113 "atrace_wrapper.cc",
114 "atrace_wrapper.h",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000115 "cpu_reader.cc",
116 "cpu_reader.h",
Hector Dearman83d98032017-12-11 16:37:43 +0000117 "event_info.cc",
118 "event_info.h",
Hector Dearman7f37dc82018-01-25 12:25:40 +0000119 "event_info_constants.cc",
120 "event_info_constants.h",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000121 "format_parser.cc",
Hector Dearmancb4ba322018-02-09 14:12:27 +0000122 "ftrace_config.cc",
Hector Dearman50139712018-02-23 15:43:41 +0000123 "ftrace_config_muxer.cc",
124 "ftrace_config_muxer.h",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000125 "ftrace_controller.cc",
126 "ftrace_procfs.cc",
127 "ftrace_procfs.h",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000128 "proto_translation_table.cc",
129 "proto_translation_table.h",
130 ]
131}
Hector Dearmanbc8368e2018-01-25 17:34:11 +0000132
133if (!build_with_chromium) {
134 source_set("ftrace_reader_benchmarks") {
135 testonly = true
136 deps = [
137 ":ftrace_reader",
138 ":test_support",
139 "../../gn:default_deps",
140 "//buildtools:benchmark",
141 ]
142 sources = [
143 "cpu_reader_benchmark.cc",
144 ]
145 }
146}
Hector Dearman7391c0f2018-02-02 14:20:09 +0000147
148if (use_libfuzzer) {
149 executable("cpu_reader_fuzzer") {
150 testonly = true
151 sources = [
152 "cpu_reader_fuzzer.cc",
153 ]
154 deps = [
155 ":ftrace_reader",
156 ":test_support",
157 "../../gn:default_deps",
158 ]
159 configs += [ "../../gn:fuzzer_config" ]
160 }
161}