1# Copyright (C) 2019 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/test.gni")
18
19perfetto_unittest_source_set("test_support") {
20  testonly = true
21  public_deps = [
22    "../../../include/perfetto/test:test_support",
23    "../core:test_support",
24  ]
25  deps = [
26    "../../../gn:default_deps",
27    "../../../gn:gtest_and_gmock",
28    "../../../protos/perfetto/trace:cpp",
29    "../../../protos/perfetto/trace:lite",
30    "../../../protos/perfetto/trace:zero",
31    "../../../protos/perfetto/trace/ftrace:cpp",
32    "../../../protos/perfetto/trace/track_event:lite",
33    "../../base",
34    "../../base:test_support",
35    "../core",
36    "../core:service",
37    "../core:test_support",
38  ]
39  sources = [
40    "aligned_buffer_test.cc",
41    "aligned_buffer_test.h",
42    "fake_packet.cc",
43    "fake_packet.h",
44    "test_shared_memory.cc",
45    "test_shared_memory.h",
46    "traced_value_test_support.cc",
47  ]
48
49  # These tests rely on test_task_runner.h which
50  # has no implementation for Windows or NaCL.
51  if (!is_win && !is_nacl) {
52    sources += [
53      "fake_producer_endpoint.h",
54      "mock_consumer.cc",
55      "mock_consumer.h",
56      "mock_producer.cc",
57      "mock_producer.h",
58    ]
59  }
60}
61
62if (enable_perfetto_ipc) {
63  perfetto_unittest_source_set("tracing_integration_test") {
64    testonly = true
65    deps = [
66      ":test_support",
67      "../../../gn:default_deps",
68      "../../../gn:gtest_and_gmock",
69      "../../base",
70      "../../base:test_support",
71      "../core:service",
72      "../ipc/consumer",
73      "../ipc/producer",
74      "../ipc/service",
75    ]
76    sources = [ "tracing_integration_test.cc" ]
77
78    # TODO(primiano): remove the build_with_chromium conditional once the root
79    # //BUILD.gn:libperfetto (in chromium) stops adding tracing:platform_fake.
80    # The problem is the following: in chrome builds we end up with duplicate
81    # symbol definitions in the test because both platorm (impl and fake) are
82    # present: impl added here and fake coming from chromium's base (full path:
83    # perfetto_unittests -> //(chromium)base:test_support -> //(chromium)base
84    # -> libperfetto -> platform_fake.
85    if (!build_with_chromium) {
86      deps += [
87        "..:client_api_without_backends",
88        "..:platform_impl",
89      ]
90      sources += [ "platform_unittest.cc" ]
91    }
92  }
93}
94
95if (enable_perfetto_integration_tests) {
96  source_set("client_api_integrationtests") {
97    testonly = true
98    deps = [
99      ":api_test_support",
100      "../:client_api",
101      "../:platform_impl",
102      "../../../:libperfetto_client_experimental",
103      "../../../gn:default_deps",
104      "../../../gn:gtest_and_gmock",
105      "../../../include/perfetto/tracing/core",
106      "../../../protos/perfetto/common:cpp",
107      "../../../protos/perfetto/common:zero",
108      "../../../protos/perfetto/config/track_event:cpp",
109      "../../../protos/perfetto/trace:cpp",
110      "../../../protos/perfetto/trace:zero",
111      "../../../protos/perfetto/trace/gpu:cpp",
112      "../../../protos/perfetto/trace/gpu:zero",
113      "../../../protos/perfetto/trace/interned_data:cpp",
114      "../../../protos/perfetto/trace/interned_data:zero",
115      "../../../protos/perfetto/trace/profiling:cpp",
116      "../../../protos/perfetto/trace/track_event:cpp",
117      "../../base",
118    ]
119    sources = [
120      "api_integrationtest.cc",
121      "tracing_module.cc",
122      "tracing_module.h",
123      "tracing_module2.cc",
124      "tracing_module_categories.h",
125    ]
126  }
127
128  # api_test_support needs to be self-contained and not leak any other perfetto
129  # deps. See comment in api_test_support.h
130  source_set("api_test_support") {
131    testonly = true
132    deps = [
133      "../../..:libperfetto_client_experimental",
134      "../../../gn:default_deps",
135      "../../base",
136      "../../tracing:client_api_without_backends",
137    ]
138
139    # The system tracing backend requires IPC support.
140    if (enable_perfetto_ipc) {
141      deps += [ "../../../test:test_helper" ]
142    }
143    sources = [
144      "api_test_support.cc",
145      "api_test_support.h",
146    ]
147  }
148}
149