xref: /aosp_15_r20/external/perfetto/test/BUILD.gn (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1# Copyright (C) 2018 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")
17
18if (!build_with_chromium && enable_perfetto_integration_tests) {
19  source_set("perfetto_end_to_end_integrationtests") {
20    testonly = true
21    deps = [
22      ":test_helper",
23      "../gn:default_deps",
24      "../gn:gtest_and_gmock",
25      "../include/perfetto/ext/ipc",
26      "../include/perfetto/ext/traced",
27      "../include/perfetto/ext/tracing/core:test_support",
28      "../include/perfetto/protozero",
29      "../protos/perfetto/config:cpp",
30      "../protos/perfetto/config:zero",
31      "../protos/perfetto/config/power:zero",
32      "../protos/perfetto/config/sys_stats:cpp",
33      "../protos/perfetto/trace:cpp",
34      "../protos/perfetto/trace:zero",
35      "../protos/perfetto/trace/ftrace:cpp",
36      "../protos/perfetto/trace/perfetto:cpp",
37      "../protos/perfetto/trace/power:cpp",
38      "../protos/perfetto/trace/sys_stats:cpp",
39      "../src/base:base",
40      "../src/base:test_support",
41      "../src/perfetto_cmd:bugreport_path",
42      "../src/protozero/filtering:bytecode_generator",
43    ]
44    if (enable_perfetto_traced_probes) {
45      deps += [
46        "../src/traced/probes/ftrace",
47        "../src/traced/probes/ftrace:ftrace_procfs",
48      ]
49    }
50
51    # These binaries are requires by the cmdline tests, which invoke perfetto
52    # and trigger_perfetto via Subprocess.
53    data_deps = [
54      "../src/perfetto_cmd:perfetto",
55      "../src/perfetto_cmd:trigger_perfetto",
56    ]
57
58    sources = [
59      "android_integrationtest.cc",
60      "cmdline_integrationtest.cc",
61      "ftrace_integrationtest.cc",
62      "traced_integrationtest.cc",
63    ]
64    if (start_daemons_for_testing) {
65      # In CTS mode we use /syste/bin/perfetto for the cmdline tests and the
66      # perfetto_cmd is not required. Outside of CTS mode, instead, we need to
67      # build the cmdline code as part of the test executable.
68      deps += [
69        "../src/perfetto_cmd",
70        "../src/perfetto_cmd:trigger_perfetto_cmd",
71      ]
72    }
73
74    if (enable_perfetto_trace_processor &&
75        enable_perfetto_trace_processor_sqlite &&
76        !perfetto_build_with_android && !is_android) {
77      sources += [ "trace_processor_shell_integrationtest.cc" ]
78      data_deps += [ "../src/trace_processor:trace_processor_shell" ]
79      deps += [ "../protos/perfetto/trace_processor:cpp" ]
80    }
81  }
82
83  executable("client_api_example") {
84    sources = [ "client_api_example.cc" ]
85    deps = [
86      "..:libperfetto_client_experimental",
87      "../gn:default_deps",
88      "../include/perfetto/tracing",
89      "../protos/perfetto/config/gpu:zero",
90      "../protos/perfetto/trace:zero",
91      "../protos/perfetto/trace/gpu:zero",
92    ]
93  }
94}  # if (!build_with_chromium && enable_perfetto_integration_tests)
95
96perfetto_fuzzer_test("end_to_end_shared_memory_fuzzer") {
97  sources = [ "end_to_end_shared_memory_fuzzer.cc" ]
98  testonly = true
99  deps = [
100    ":test_helper",
101    "../gn:default_deps",
102    "../protos/perfetto/trace:zero",
103    "../src/base:test_support",
104    "../src/protozero",
105    "../src/tracing/core",
106    "../src/tracing/ipc/producer",
107    "../src/tracing/ipc/service",
108  ]
109}
110
111perfetto_fuzzer_test("producer_socket_fuzzer") {
112  sources = [ "producer_socket_fuzzer.cc" ]
113  testonly = true
114  deps = [
115    ":test_helper",
116    "../gn:default_deps",
117    "../protos/perfetto/trace:zero",
118    "../src/base:test_support",
119  ]
120}
121
122# perfetto_fuzzer_test() targets are no-ops if is_fuzzer = false.
123if (enable_perfetto_benchmarks || is_fuzzer ||
124    enable_perfetto_integration_tests) {
125  source_set("test_helper") {
126    testonly = true
127    public_deps = [
128      "../protos/perfetto/trace:cpp",
129      "../src/tracing/ipc/consumer",
130      "../src/tracing/ipc/producer",
131      "../src/tracing/ipc/service",
132    ]
133    deps = [
134      "../gn:default_deps",
135      "../protos/perfetto/config:cpp",
136      "../protos/perfetto/trace:zero",
137      "../src/base:test_support",
138      "../src/ipc:perfetto_ipc",
139      "../src/tracing/ipc:common",
140    ]
141    sources = [
142      "fake_producer.cc",
143      "fake_producer.h",
144      "test_helper.cc",
145      "test_helper.h",
146    ]
147    if (is_android) {
148      sources += [
149        "android_test_utils.cc",
150        "android_test_utils.h",
151      ]
152    }
153    if (!build_with_chromium && enable_perfetto_traced_probes) {
154      deps += [
155        "../include/perfetto/ext/traced",
156        "../src/traced/probes:probes_src",
157      ]
158    }
159  }
160}
161
162if (enable_perfetto_integration_tests) {
163  source_set("integrationtest_initializer") {
164    testonly = true
165    deps = [ "../gn:default_deps" ]
166    sources = [ "integrationtest_initializer.h" ]
167  }
168  source_set("integrationtest_main") {
169    testonly = true
170    deps = [
171      ":integrationtest_initializer",
172      "../src/base",
173      "../gn:default_deps",
174      "../gn:gtest_and_gmock",
175    ]
176    sources = [ "integrationtest_main.cc" ]
177  }
178}
179
180if (enable_perfetto_benchmarks) {
181  source_set("end_to_end_benchmarks") {
182    testonly = true
183    deps = [
184      ":test_helper",
185      "../gn:benchmark",
186      "../gn:default_deps",
187      "../gn:gtest_and_gmock",
188      "../include/perfetto/ext/traced",
189      "../protos/perfetto/config:cpp",
190      "../protos/perfetto/trace:cpp",
191      "../protos/perfetto/trace:zero",
192      "../src/base:test_support",
193    ]
194    sources = [ "end_to_end_benchmark.cc" ]
195  }
196
197  source_set("benchmark_main") {
198    testonly = true
199    deps = [
200      "../gn:benchmark",
201      "../gn:default_deps",
202    ]
203    sources = [ "benchmark_main.cc" ]
204  }
205}  # if (enable_perfetto_benchmarks)
206
207if (perfetto_build_with_android || (is_android && perfetto_build_standalone)) {
208  # This is used only in-tree builds. It's built in standalone builds just to
209  # get build coverage.
210  static_library("perfetto_gtest_logcat_printer") {
211    testonly = true
212    complete_static_lib = true
213    sources = [ "gtest_logcat_printer.cc" ]
214    deps = [
215      "../gn:default_deps",
216      "../gn:gtest_and_gmock",
217    ]
218  }
219}
220