• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/perfetto.gni")
16import("../../../../gn/proto_library.gni")
17import("../../../../gn/fuzzer.gni")
18import("../../../../gn/protozero_library.gni")
19
20# For use_libfuzzer.
21if (perfetto_build_standalone || perfetto_build_with_android) {
22  import("//gn/standalone/sanitizers/vars.gni")
23} else {
24  import("//build/config/sanitizers/sanitizers.gni")
25}
26
27source_set("test_support") {
28  testonly = true
29  deps = [
30    ":ftrace",
31    "../../../../gn:default_deps",
32    "../../../protozero",
33  ]
34  public_deps = [
35    "../../../protozero",
36  ]
37
38  sources = [
39    "test/cpu_reader_support.cc",
40    "test/cpu_reader_support.h",
41  ]
42}
43
44source_set("unittests") {
45  testonly = true
46  deps = [
47    ":format_parser",
48    ":ftrace",
49    ":test_messages_lite",
50    ":test_messages_zero",
51    ":test_support",
52    "../../../../gn:default_deps",
53    "../../../../gn:gtest_deps",
54    "../../../../protos/perfetto/trace/ftrace:lite",
55    "../../../base:test_support",
56    "../../../tracing:test_support",
57  ]
58  sources = [
59    "cpu_reader_unittest.cc",
60    "cpu_stats_parser_unittest.cc",
61    "event_info_unittest.cc",
62    "format_parser_unittest.cc",
63    "ftrace_config_muxer_unittest.cc",
64    "ftrace_config_unittest.cc",
65    "ftrace_controller_unittest.cc",
66    "ftrace_procfs_unittest.cc",
67    "page_pool_unittest.cc",
68    "proto_translation_table_unittest.cc",
69  ]
70}
71
72ftrace_reader_test_proto_sources = [ "test/test_messages.proto" ]
73
74protozero_library("test_messages_zero") {
75  sources = ftrace_reader_test_proto_sources
76  proto_in_dir = perfetto_root_path
77  proto_out_dir = perfetto_root_path
78  generator_plugin_options = "wrapper_namespace=pbzero"
79}
80
81proto_library("test_messages_lite") {
82  generate_python = false
83  sources = ftrace_reader_test_proto_sources
84  proto_in_dir = perfetto_root_path
85  proto_out_dir = perfetto_root_path
86}
87
88# These tests require access to a real ftrace implementation and must
89# run with sudo.
90source_set("integrationtests") {
91  testonly = true
92  deps = [
93    ":ftrace",
94    ":test_support",
95    "../../../../gn:default_deps",
96    "../../../../gn:gtest_deps",
97    "../../../../protos/perfetto/trace/ftrace:lite",
98    "../../../base",
99    "../../../tracing",
100  ]
101  sources = [
102    "ftrace_procfs_integrationtest.cc",
103  ]
104}
105
106source_set("ftrace") {
107  public_deps = [
108    "../../../../protos/perfetto/trace/ftrace:zero",
109    "../../../tracing",
110  ]
111  libs = [ "dl" ]  # for dlopen()
112  deps = [
113    ":format_parser",
114    "..:data_source",
115    "../../../../gn:default_deps",
116    "../../../../include/perfetto/traced",
117    "../../../android_internal:headers",
118    "../../../base",
119    "../../../protozero",
120  ]
121  sources = [
122    "atrace_hal_wrapper.cc",
123    "atrace_hal_wrapper.h",
124    "atrace_wrapper.cc",
125    "atrace_wrapper.h",
126    "cpu_reader.cc",
127    "cpu_reader.h",
128    "cpu_stats_parser.cc",
129    "cpu_stats_parser.h",
130    "event_info.cc",
131    "event_info.h",
132    "event_info_constants.cc",
133    "event_info_constants.h",
134    "ftrace_config.cc",
135    "ftrace_config.h",
136    "ftrace_config_muxer.cc",
137    "ftrace_config_muxer.h",
138    "ftrace_controller.cc",
139    "ftrace_controller.h",
140    "ftrace_data_source.cc",
141    "ftrace_data_source.h",
142    "ftrace_metadata.cc",
143    "ftrace_metadata.h",
144    "ftrace_procfs.cc",
145    "ftrace_procfs.h",
146    "ftrace_stats.cc",
147    "ftrace_stats.h",
148    "page_pool.cc",
149    "page_pool.h",
150    "proto_translation_table.cc",
151    "proto_translation_table.h",
152  ]
153}
154
155source_set("format_parser") {
156  deps = [
157    "../../../../gn:default_deps",
158    "../../../base",
159  ]
160  sources = [
161    "format_parser.cc",
162    "format_parser.h",
163  ]
164}
165
166if (perfetto_build_standalone) {
167  source_set("benchmarks") {
168    testonly = true
169    deps = [
170      ":ftrace",
171      ":test_support",
172      "../../../../gn:default_deps",
173      "//buildtools:benchmark",
174    ]
175    sources = [
176      "cpu_reader_benchmark.cc",
177    ]
178  }
179}
180
181perfetto_fuzzer_test("cpu_reader_fuzzer") {
182  testonly = true
183  sources = [
184    "cpu_reader_fuzzer.cc",
185  ]
186  deps = [
187    ":ftrace",
188    ":test_support",
189    "../../../../gn:default_deps",
190  ]
191}
192