xref: /aosp_15_r20/external/pigweed/pw_unit_test/BUILD.bazel (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker# Copyright 2019 The Pigweed Authors
2*61c4878aSAndroid Build Coastguard Worker#
3*61c4878aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4*61c4878aSAndroid Build Coastguard Worker# use this file except in compliance with the License. You may obtain a copy of
5*61c4878aSAndroid Build Coastguard Worker# the License at
6*61c4878aSAndroid Build Coastguard Worker#
7*61c4878aSAndroid Build Coastguard Worker#     https://www.apache.org/licenses/LICENSE-2.0
8*61c4878aSAndroid Build Coastguard Worker#
9*61c4878aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*61c4878aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11*61c4878aSAndroid Build Coastguard Worker# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12*61c4878aSAndroid Build Coastguard Worker# License for the specific language governing permissions and limitations under
13*61c4878aSAndroid Build Coastguard Worker# the License.
14*61c4878aSAndroid Build Coastguard Worker
15*61c4878aSAndroid Build Coastguard Workerload("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS")
16*61c4878aSAndroid Build Coastguard Workerload("@rules_python//python:proto.bzl", "py_proto_library")
17*61c4878aSAndroid Build Coastguard Workerload("//pw_build:compatibility.bzl", "boolean_constraint_value", "incompatible_with_mcu")
18*61c4878aSAndroid Build Coastguard Workerload("//pw_build:pw_cc_binary.bzl", "pw_cc_binary")
19*61c4878aSAndroid Build Coastguard Workerload("//pw_build:pw_facade.bzl", "pw_facade")
20*61c4878aSAndroid Build Coastguard Workerload(
21*61c4878aSAndroid Build Coastguard Worker    "//pw_protobuf_compiler:pw_proto_library.bzl",
22*61c4878aSAndroid Build Coastguard Worker    "pwpb_proto_library",
23*61c4878aSAndroid Build Coastguard Worker    "raw_rpc_proto_library",
24*61c4878aSAndroid Build Coastguard Worker)
25*61c4878aSAndroid Build Coastguard Workerload("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
26*61c4878aSAndroid Build Coastguard Worker
27*61c4878aSAndroid Build Coastguard Workerpackage(default_visibility = ["//visibility:public"])
28*61c4878aSAndroid Build Coastguard Worker
29*61c4878aSAndroid Build Coastguard Workerlicenses(["notice"])
30*61c4878aSAndroid Build Coastguard Worker
31*61c4878aSAndroid Build Coastguard Workerlabel_flag(
32*61c4878aSAndroid Build Coastguard Worker    name = "main",
33*61c4878aSAndroid Build Coastguard Worker    build_setting_default = ":simple_printing_main",
34*61c4878aSAndroid Build Coastguard Worker)
35*61c4878aSAndroid Build Coastguard Worker
36*61c4878aSAndroid Build Coastguard Workercc_library(
37*61c4878aSAndroid Build Coastguard Worker    name = "config",
38*61c4878aSAndroid Build Coastguard Worker    hdrs = ["public/pw_unit_test/config.h"],
39*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
40*61c4878aSAndroid Build Coastguard Worker    deps = [
41*61c4878aSAndroid Build Coastguard Worker        ":config_override",
42*61c4878aSAndroid Build Coastguard Worker        "//pw_polyfill",
43*61c4878aSAndroid Build Coastguard Worker    ],
44*61c4878aSAndroid Build Coastguard Worker)
45*61c4878aSAndroid Build Coastguard Worker
46*61c4878aSAndroid Build Coastguard Workerlabel_flag(
47*61c4878aSAndroid Build Coastguard Worker    name = "config_override",
48*61c4878aSAndroid Build Coastguard Worker    build_setting_default = "//pw_build:default_module_config",
49*61c4878aSAndroid Build Coastguard Worker)
50*61c4878aSAndroid Build Coastguard Worker
51*61c4878aSAndroid Build Coastguard Workerpw_facade(
52*61c4878aSAndroid Build Coastguard Worker    name = "pw_unit_test",
53*61c4878aSAndroid Build Coastguard Worker    testonly = True,
54*61c4878aSAndroid Build Coastguard Worker    hdrs = ["public/pw_unit_test/framework.h"],
55*61c4878aSAndroid Build Coastguard Worker    backend = ":backend",
56*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
57*61c4878aSAndroid Build Coastguard Worker    deps = [":status_macros"],
58*61c4878aSAndroid Build Coastguard Worker)
59*61c4878aSAndroid Build Coastguard Worker
60*61c4878aSAndroid Build Coastguard Workerlabel_flag(
61*61c4878aSAndroid Build Coastguard Worker    name = "backend",
62*61c4878aSAndroid Build Coastguard Worker    build_setting_default = ":light",
63*61c4878aSAndroid Build Coastguard Worker)
64*61c4878aSAndroid Build Coastguard Worker
65*61c4878aSAndroid Build Coastguard Worker# TODO: b/352808542 - Remove this. DO NOT depend on this in downstream
66*61c4878aSAndroid Build Coastguard Worker# projects, it's a temporary API to mitigate a bug!
67*61c4878aSAndroid Build Coastguard Workerboolean_constraint_value(
68*61c4878aSAndroid Build Coastguard Worker    name = "googletest_only",
69*61c4878aSAndroid Build Coastguard Worker    visibility = ["//:__subpackages__"],
70*61c4878aSAndroid Build Coastguard Worker)
71*61c4878aSAndroid Build Coastguard Worker
72*61c4878aSAndroid Build Coastguard Worker# TODO: b/352808542 - Remove this. DO NOT depend on this in downstream
73*61c4878aSAndroid Build Coastguard Worker# projects, it's a temporary API to mitigate a bug!
74*61c4878aSAndroid Build Coastguard Workerplatform(
75*61c4878aSAndroid Build Coastguard Worker    name = "googletest_platform",
76*61c4878aSAndroid Build Coastguard Worker    constraint_values = [":googletest_only"] + HOST_CONSTRAINTS,
77*61c4878aSAndroid Build Coastguard Worker    visibility = ["//visibility:private"],
78*61c4878aSAndroid Build Coastguard Worker)
79*61c4878aSAndroid Build Coastguard Worker
80*61c4878aSAndroid Build Coastguard Workercc_library(
81*61c4878aSAndroid Build Coastguard Worker    name = "light",
82*61c4878aSAndroid Build Coastguard Worker    testonly = True,
83*61c4878aSAndroid Build Coastguard Worker    srcs = ["framework_light.cc"],
84*61c4878aSAndroid Build Coastguard Worker    hdrs = [
85*61c4878aSAndroid Build Coastguard Worker        "light_public_overrides/pw_unit_test/framework_backend.h",
86*61c4878aSAndroid Build Coastguard Worker        # The facade header is included here since
87*61c4878aSAndroid Build Coastguard Worker        # public_overrides/gtest/gtest.h includes it. This avoids a circular
88*61c4878aSAndroid Build Coastguard Worker        # dependency in the build system.
89*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/framework.h",
90*61c4878aSAndroid Build Coastguard Worker        "public_overrides/gtest/gtest.h",
91*61c4878aSAndroid Build Coastguard Worker    ],
92*61c4878aSAndroid Build Coastguard Worker    includes = [
93*61c4878aSAndroid Build Coastguard Worker        "light_public_overrides",
94*61c4878aSAndroid Build Coastguard Worker        "public",
95*61c4878aSAndroid Build Coastguard Worker        "public_overrides",
96*61c4878aSAndroid Build Coastguard Worker    ],
97*61c4878aSAndroid Build Coastguard Worker    deps = [
98*61c4878aSAndroid Build Coastguard Worker        ":config",
99*61c4878aSAndroid Build Coastguard Worker        ":event_handler",
100*61c4878aSAndroid Build Coastguard Worker        ":status_macros",
101*61c4878aSAndroid Build Coastguard Worker        "//pw_assert",
102*61c4878aSAndroid Build Coastguard Worker        "//pw_bytes:alignment",
103*61c4878aSAndroid Build Coastguard Worker        "//pw_polyfill",
104*61c4878aSAndroid Build Coastguard Worker        "//pw_preprocessor",
105*61c4878aSAndroid Build Coastguard Worker        "//pw_span",
106*61c4878aSAndroid Build Coastguard Worker        "//pw_status",
107*61c4878aSAndroid Build Coastguard Worker        "//pw_string",
108*61c4878aSAndroid Build Coastguard Worker    ],
109*61c4878aSAndroid Build Coastguard Worker)
110*61c4878aSAndroid Build Coastguard Worker
111*61c4878aSAndroid Build Coastguard Workercc_library(
112*61c4878aSAndroid Build Coastguard Worker    name = "googletest",
113*61c4878aSAndroid Build Coastguard Worker    testonly = True,
114*61c4878aSAndroid Build Coastguard Worker    hdrs = [
115*61c4878aSAndroid Build Coastguard Worker        "googletest_public_overrides/pw_unit_test/framework_backend.h",
116*61c4878aSAndroid Build Coastguard Worker    ],
117*61c4878aSAndroid Build Coastguard Worker    includes = ["googletest_public_overrides"],
118*61c4878aSAndroid Build Coastguard Worker    # TODO: b/310957361 - gtest not supported on device
119*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = incompatible_with_mcu(),
120*61c4878aSAndroid Build Coastguard Worker    deps = [
121*61c4878aSAndroid Build Coastguard Worker        ":googletest_handler_adapter",
122*61c4878aSAndroid Build Coastguard Worker        ":pw_unit_test.facade",
123*61c4878aSAndroid Build Coastguard Worker        "//pw_result",
124*61c4878aSAndroid Build Coastguard Worker        "//pw_status",
125*61c4878aSAndroid Build Coastguard Worker        "@com_google_googletest//:gtest",
126*61c4878aSAndroid Build Coastguard Worker    ],
127*61c4878aSAndroid Build Coastguard Worker)
128*61c4878aSAndroid Build Coastguard Worker
129*61c4878aSAndroid Build Coastguard Worker# Identifies when the light framework is being used.
130*61c4878aSAndroid Build Coastguard Workerconfig_setting(
131*61c4878aSAndroid Build Coastguard Worker    name = "light_setting",
132*61c4878aSAndroid Build Coastguard Worker    testonly = True,
133*61c4878aSAndroid Build Coastguard Worker    flag_values = {
134*61c4878aSAndroid Build Coastguard Worker        "//pw_unit_test:backend": "//pw_unit_test:light",
135*61c4878aSAndroid Build Coastguard Worker    },
136*61c4878aSAndroid Build Coastguard Worker    # Do not depend on this config_setting outside upstream Pigweed. Config
137*61c4878aSAndroid Build Coastguard Worker    # settings based on label flags are unreliable. See
138*61c4878aSAndroid Build Coastguard Worker    # https://github.com/bazelbuild/bazel/issues/21189.
139*61c4878aSAndroid Build Coastguard Worker    visibility = ["//:__subpackages__"],
140*61c4878aSAndroid Build Coastguard Worker)
141*61c4878aSAndroid Build Coastguard Worker
142*61c4878aSAndroid Build Coastguard Workerconfig_setting(
143*61c4878aSAndroid Build Coastguard Worker    name = "gtest_setting",
144*61c4878aSAndroid Build Coastguard Worker    testonly = True,
145*61c4878aSAndroid Build Coastguard Worker    flag_values = {
146*61c4878aSAndroid Build Coastguard Worker        "//pw_unit_test:backend": "//pw_unit_test:googletest",
147*61c4878aSAndroid Build Coastguard Worker    },
148*61c4878aSAndroid Build Coastguard Worker    # Do not depend on this config_setting outside upstream Pigweed. Config
149*61c4878aSAndroid Build Coastguard Worker    # settings based on label flags are unreliable. See
150*61c4878aSAndroid Build Coastguard Worker    # https://github.com/bazelbuild/bazel/issues/21189.
151*61c4878aSAndroid Build Coastguard Worker    visibility = ["//:__subpackages__"],
152*61c4878aSAndroid Build Coastguard Worker)
153*61c4878aSAndroid Build Coastguard Worker
154*61c4878aSAndroid Build Coastguard Workercc_library(
155*61c4878aSAndroid Build Coastguard Worker    name = "event_handler",
156*61c4878aSAndroid Build Coastguard Worker    hdrs = ["public/pw_unit_test/event_handler.h"],
157*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
158*61c4878aSAndroid Build Coastguard Worker)
159*61c4878aSAndroid Build Coastguard Worker
160*61c4878aSAndroid Build Coastguard Workercc_library(
161*61c4878aSAndroid Build Coastguard Worker    name = "status_macros",
162*61c4878aSAndroid Build Coastguard Worker    testonly = True,
163*61c4878aSAndroid Build Coastguard Worker    hdrs = ["public/pw_unit_test/status_macros.h"],
164*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
165*61c4878aSAndroid Build Coastguard Worker)
166*61c4878aSAndroid Build Coastguard Worker
167*61c4878aSAndroid Build Coastguard Workercc_library(
168*61c4878aSAndroid Build Coastguard Worker    name = "googletest_style_event_handler",
169*61c4878aSAndroid Build Coastguard Worker    srcs = ["googletest_style_event_handler.cc"],
170*61c4878aSAndroid Build Coastguard Worker    hdrs = ["public/pw_unit_test/googletest_style_event_handler.h"],
171*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
172*61c4878aSAndroid Build Coastguard Worker    deps = [
173*61c4878aSAndroid Build Coastguard Worker        ":event_handler",
174*61c4878aSAndroid Build Coastguard Worker        "//pw_preprocessor",
175*61c4878aSAndroid Build Coastguard Worker    ],
176*61c4878aSAndroid Build Coastguard Worker)
177*61c4878aSAndroid Build Coastguard Worker
178*61c4878aSAndroid Build Coastguard Workercc_library(
179*61c4878aSAndroid Build Coastguard Worker    name = "googletest_handler_adapter",
180*61c4878aSAndroid Build Coastguard Worker    testonly = True,
181*61c4878aSAndroid Build Coastguard Worker    srcs = ["googletest_handler_adapter.cc"],
182*61c4878aSAndroid Build Coastguard Worker    hdrs = ["public/pw_unit_test/googletest_handler_adapter.h"],
183*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
184*61c4878aSAndroid Build Coastguard Worker    # TODO: b/310957361 - gtest not supported on device
185*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = incompatible_with_mcu(),
186*61c4878aSAndroid Build Coastguard Worker    deps = [
187*61c4878aSAndroid Build Coastguard Worker        ":event_handler",
188*61c4878aSAndroid Build Coastguard Worker        "//pw_preprocessor",
189*61c4878aSAndroid Build Coastguard Worker        "@com_google_googletest//:gtest",
190*61c4878aSAndroid Build Coastguard Worker    ],
191*61c4878aSAndroid Build Coastguard Worker)
192*61c4878aSAndroid Build Coastguard Worker
193*61c4878aSAndroid Build Coastguard Workercc_library(
194*61c4878aSAndroid Build Coastguard Worker    name = "googletest_test_matchers",
195*61c4878aSAndroid Build Coastguard Worker    testonly = True,
196*61c4878aSAndroid Build Coastguard Worker    hdrs = ["public/pw_unit_test/googletest_test_matchers.h"],
197*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
198*61c4878aSAndroid Build Coastguard Worker    # TODO: b/310957361 - gtest not supported on device
199*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = incompatible_with_mcu(),
200*61c4878aSAndroid Build Coastguard Worker    deps = [
201*61c4878aSAndroid Build Coastguard Worker        "//pw_result",
202*61c4878aSAndroid Build Coastguard Worker        "//pw_status",
203*61c4878aSAndroid Build Coastguard Worker        "@com_google_googletest//:gtest",
204*61c4878aSAndroid Build Coastguard Worker    ],
205*61c4878aSAndroid Build Coastguard Worker)
206*61c4878aSAndroid Build Coastguard Worker
207*61c4878aSAndroid Build Coastguard Workerpw_cc_test(
208*61c4878aSAndroid Build Coastguard Worker    name = "googletest_test_matchers_test",
209*61c4878aSAndroid Build Coastguard Worker    srcs = ["googletest_test_matchers_test.cc"],
210*61c4878aSAndroid Build Coastguard Worker    deps = [
211*61c4878aSAndroid Build Coastguard Worker        ":googletest_test_matchers",
212*61c4878aSAndroid Build Coastguard Worker    ],
213*61c4878aSAndroid Build Coastguard Worker)
214*61c4878aSAndroid Build Coastguard Worker
215*61c4878aSAndroid Build Coastguard Workercc_library(
216*61c4878aSAndroid Build Coastguard Worker    name = "simple_printing_event_handler",
217*61c4878aSAndroid Build Coastguard Worker    testonly = True,
218*61c4878aSAndroid Build Coastguard Worker    srcs = ["simple_printing_event_handler.cc"],
219*61c4878aSAndroid Build Coastguard Worker    hdrs = [
220*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/simple_printing_event_handler.h",
221*61c4878aSAndroid Build Coastguard Worker    ],
222*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
223*61c4878aSAndroid Build Coastguard Worker    deps = [
224*61c4878aSAndroid Build Coastguard Worker        ":googletest_style_event_handler",
225*61c4878aSAndroid Build Coastguard Worker        "//pw_preprocessor",
226*61c4878aSAndroid Build Coastguard Worker    ],
227*61c4878aSAndroid Build Coastguard Worker)
228*61c4878aSAndroid Build Coastguard Worker
229*61c4878aSAndroid Build Coastguard Workercc_library(
230*61c4878aSAndroid Build Coastguard Worker    name = "simple_printing_main",
231*61c4878aSAndroid Build Coastguard Worker    testonly = True,
232*61c4878aSAndroid Build Coastguard Worker    srcs = [
233*61c4878aSAndroid Build Coastguard Worker        "simple_printing_main.cc",
234*61c4878aSAndroid Build Coastguard Worker    ],
235*61c4878aSAndroid Build Coastguard Worker    deps = [
236*61c4878aSAndroid Build Coastguard Worker        ":pw_unit_test",
237*61c4878aSAndroid Build Coastguard Worker        ":simple_printing_event_handler",
238*61c4878aSAndroid Build Coastguard Worker        "//pw_span",
239*61c4878aSAndroid Build Coastguard Worker        "//pw_sys_io",
240*61c4878aSAndroid Build Coastguard Worker    ],
241*61c4878aSAndroid Build Coastguard Worker)
242*61c4878aSAndroid Build Coastguard Worker
243*61c4878aSAndroid Build Coastguard Workercc_library(
244*61c4878aSAndroid Build Coastguard Worker    name = "printf_event_handler",
245*61c4878aSAndroid Build Coastguard Worker    testonly = True,
246*61c4878aSAndroid Build Coastguard Worker    hdrs = ["public/pw_unit_test/printf_event_handler.h"],
247*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
248*61c4878aSAndroid Build Coastguard Worker    deps = [
249*61c4878aSAndroid Build Coastguard Worker        ":googletest_style_event_handler",
250*61c4878aSAndroid Build Coastguard Worker        "//pw_preprocessor",
251*61c4878aSAndroid Build Coastguard Worker    ],
252*61c4878aSAndroid Build Coastguard Worker)
253*61c4878aSAndroid Build Coastguard Worker
254*61c4878aSAndroid Build Coastguard Workercc_library(
255*61c4878aSAndroid Build Coastguard Worker    name = "printf_main",
256*61c4878aSAndroid Build Coastguard Worker    testonly = True,
257*61c4878aSAndroid Build Coastguard Worker    srcs = ["printf_main.cc"],
258*61c4878aSAndroid Build Coastguard Worker    deps = [
259*61c4878aSAndroid Build Coastguard Worker        ":printf_event_handler",
260*61c4878aSAndroid Build Coastguard Worker        ":pw_unit_test",
261*61c4878aSAndroid Build Coastguard Worker    ],
262*61c4878aSAndroid Build Coastguard Worker)
263*61c4878aSAndroid Build Coastguard Worker
264*61c4878aSAndroid Build Coastguard Worker# TODO: b/324116813 - Remove this alias once no downstream project depends on
265*61c4878aSAndroid Build Coastguard Worker# it.
266*61c4878aSAndroid Build Coastguard Workeralias(
267*61c4878aSAndroid Build Coastguard Worker    name = "logging_event_handler",
268*61c4878aSAndroid Build Coastguard Worker    actual = "logging",
269*61c4878aSAndroid Build Coastguard Worker)
270*61c4878aSAndroid Build Coastguard Worker
271*61c4878aSAndroid Build Coastguard Workercc_library(
272*61c4878aSAndroid Build Coastguard Worker    name = "logging",
273*61c4878aSAndroid Build Coastguard Worker    testonly = True,
274*61c4878aSAndroid Build Coastguard Worker    srcs = [
275*61c4878aSAndroid Build Coastguard Worker        "logging_event_handler.cc",
276*61c4878aSAndroid Build Coastguard Worker    ],
277*61c4878aSAndroid Build Coastguard Worker    hdrs = [
278*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/logging_event_handler.h",
279*61c4878aSAndroid Build Coastguard Worker    ],
280*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
281*61c4878aSAndroid Build Coastguard Worker    deps = [
282*61c4878aSAndroid Build Coastguard Worker        ":googletest_style_event_handler",
283*61c4878aSAndroid Build Coastguard Worker        "//pw_log",
284*61c4878aSAndroid Build Coastguard Worker    ],
285*61c4878aSAndroid Build Coastguard Worker)
286*61c4878aSAndroid Build Coastguard Worker
287*61c4878aSAndroid Build Coastguard Workerpw_cc_binary(
288*61c4878aSAndroid Build Coastguard Worker    name = "logging_main",
289*61c4878aSAndroid Build Coastguard Worker    testonly = True,
290*61c4878aSAndroid Build Coastguard Worker    srcs = [
291*61c4878aSAndroid Build Coastguard Worker        "logging_main.cc",
292*61c4878aSAndroid Build Coastguard Worker    ],
293*61c4878aSAndroid Build Coastguard Worker    # TODO: b/353588407 - Won't build on RP2040 until //pw_libcxx is added to link_extra_lib.
294*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = select({
295*61c4878aSAndroid Build Coastguard Worker        "//pw_build/constraints/chipset:rp2040": ["@platforms//:incompatible"],
296*61c4878aSAndroid Build Coastguard Worker        "//conditions:default": [],
297*61c4878aSAndroid Build Coastguard Worker    }),
298*61c4878aSAndroid Build Coastguard Worker    deps = [
299*61c4878aSAndroid Build Coastguard Worker        ":logging",
300*61c4878aSAndroid Build Coastguard Worker        "//pw_unit_test",
301*61c4878aSAndroid Build Coastguard Worker    ],
302*61c4878aSAndroid Build Coastguard Worker)
303*61c4878aSAndroid Build Coastguard Worker
304*61c4878aSAndroid Build Coastguard Workercc_library(
305*61c4878aSAndroid Build Coastguard Worker    name = "multi_event_handler",
306*61c4878aSAndroid Build Coastguard Worker    testonly = True,
307*61c4878aSAndroid Build Coastguard Worker    hdrs = [
308*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/multi_event_handler.h",
309*61c4878aSAndroid Build Coastguard Worker    ],
310*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
311*61c4878aSAndroid Build Coastguard Worker    deps = [
312*61c4878aSAndroid Build Coastguard Worker        ":event_handler",
313*61c4878aSAndroid Build Coastguard Worker    ],
314*61c4878aSAndroid Build Coastguard Worker)
315*61c4878aSAndroid Build Coastguard Worker
316*61c4878aSAndroid Build Coastguard Workerpw_cc_test(
317*61c4878aSAndroid Build Coastguard Worker    name = "multi_event_handler_test",
318*61c4878aSAndroid Build Coastguard Worker    srcs = ["multi_event_handler_test.cc"],
319*61c4878aSAndroid Build Coastguard Worker    deps = [
320*61c4878aSAndroid Build Coastguard Worker        ":multi_event_handler",
321*61c4878aSAndroid Build Coastguard Worker        ":pw_unit_test",
322*61c4878aSAndroid Build Coastguard Worker    ],
323*61c4878aSAndroid Build Coastguard Worker)
324*61c4878aSAndroid Build Coastguard Worker
325*61c4878aSAndroid Build Coastguard Workercc_library(
326*61c4878aSAndroid Build Coastguard Worker    name = "test_record_event_handler",
327*61c4878aSAndroid Build Coastguard Worker    testonly = True,
328*61c4878aSAndroid Build Coastguard Worker    hdrs = [
329*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/internal/test_record_trie.h",
330*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/test_record_event_handler.h",
331*61c4878aSAndroid Build Coastguard Worker    ],
332*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
333*61c4878aSAndroid Build Coastguard Worker    deps = [
334*61c4878aSAndroid Build Coastguard Worker        ":event_handler",
335*61c4878aSAndroid Build Coastguard Worker        "//pw_assert",
336*61c4878aSAndroid Build Coastguard Worker        "//pw_json:builder",
337*61c4878aSAndroid Build Coastguard Worker    ],
338*61c4878aSAndroid Build Coastguard Worker)
339*61c4878aSAndroid Build Coastguard Worker
340*61c4878aSAndroid Build Coastguard Workerpw_cc_test(
341*61c4878aSAndroid Build Coastguard Worker    name = "test_record_event_handler_test",
342*61c4878aSAndroid Build Coastguard Worker    srcs = ["test_record_event_handler_test.cc"],
343*61c4878aSAndroid Build Coastguard Worker    deps = [
344*61c4878aSAndroid Build Coastguard Worker        ":pw_unit_test",
345*61c4878aSAndroid Build Coastguard Worker        ":test_record_event_handler",
346*61c4878aSAndroid Build Coastguard Worker    ],
347*61c4878aSAndroid Build Coastguard Worker)
348*61c4878aSAndroid Build Coastguard Worker
349*61c4878aSAndroid Build Coastguard Workerproto_library(
350*61c4878aSAndroid Build Coastguard Worker    name = "unit_test_proto",
351*61c4878aSAndroid Build Coastguard Worker    srcs = ["pw_unit_test_proto/unit_test.proto"],
352*61c4878aSAndroid Build Coastguard Worker    strip_import_prefix = "/pw_unit_test",
353*61c4878aSAndroid Build Coastguard Worker)
354*61c4878aSAndroid Build Coastguard Worker
355*61c4878aSAndroid Build Coastguard Workerpy_proto_library(
356*61c4878aSAndroid Build Coastguard Worker    name = "unit_test_py_pb2",
357*61c4878aSAndroid Build Coastguard Worker    deps = [":unit_test_proto"],
358*61c4878aSAndroid Build Coastguard Worker)
359*61c4878aSAndroid Build Coastguard Worker
360*61c4878aSAndroid Build Coastguard Workerpwpb_proto_library(
361*61c4878aSAndroid Build Coastguard Worker    name = "unit_test_pwpb",
362*61c4878aSAndroid Build Coastguard Worker    deps = [":unit_test_proto"],
363*61c4878aSAndroid Build Coastguard Worker)
364*61c4878aSAndroid Build Coastguard Worker
365*61c4878aSAndroid Build Coastguard Workerraw_rpc_proto_library(
366*61c4878aSAndroid Build Coastguard Worker    name = "unit_test_raw_rpc",
367*61c4878aSAndroid Build Coastguard Worker    deps = [":unit_test_proto"],
368*61c4878aSAndroid Build Coastguard Worker)
369*61c4878aSAndroid Build Coastguard Worker
370*61c4878aSAndroid Build Coastguard Workercc_library(
371*61c4878aSAndroid Build Coastguard Worker    name = "rpc_service",
372*61c4878aSAndroid Build Coastguard Worker    testonly = True,
373*61c4878aSAndroid Build Coastguard Worker    srcs = ["unit_test_service.cc"] + select({
374*61c4878aSAndroid Build Coastguard Worker        ":light_setting": ["rpc_light_event_handler.cc"],
375*61c4878aSAndroid Build Coastguard Worker        "//conditions:default": [":rpc_gtest_event_handler.cc"],
376*61c4878aSAndroid Build Coastguard Worker    }),
377*61c4878aSAndroid Build Coastguard Worker    hdrs = [
378*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/config.h",
379*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/unit_test_service.h",
380*61c4878aSAndroid Build Coastguard Worker    ] + select({
381*61c4878aSAndroid Build Coastguard Worker        ":light_setting": [
382*61c4878aSAndroid Build Coastguard Worker            "rpc_light_public/pw_unit_test/internal/rpc_event_handler.h",
383*61c4878aSAndroid Build Coastguard Worker        ],
384*61c4878aSAndroid Build Coastguard Worker        "//conditions:default": [
385*61c4878aSAndroid Build Coastguard Worker            "rpc_gtest_public/pw_unit_test/internal/rpc_event_handler.h",
386*61c4878aSAndroid Build Coastguard Worker        ],
387*61c4878aSAndroid Build Coastguard Worker    }),
388*61c4878aSAndroid Build Coastguard Worker    includes = ["public"] + select({
389*61c4878aSAndroid Build Coastguard Worker        ":light_setting": ["rpc_light_public"],
390*61c4878aSAndroid Build Coastguard Worker        "//conditions:default": ["rpc_gtest_public"],
391*61c4878aSAndroid Build Coastguard Worker    }),
392*61c4878aSAndroid Build Coastguard Worker    deps = [
393*61c4878aSAndroid Build Coastguard Worker        ":config",
394*61c4878aSAndroid Build Coastguard Worker        ":event_handler",
395*61c4878aSAndroid Build Coastguard Worker        ":pw_unit_test",
396*61c4878aSAndroid Build Coastguard Worker        ":unit_test_pwpb",
397*61c4878aSAndroid Build Coastguard Worker        ":unit_test_raw_rpc",
398*61c4878aSAndroid Build Coastguard Worker        "//pw_log",
399*61c4878aSAndroid Build Coastguard Worker    ],
400*61c4878aSAndroid Build Coastguard Worker)
401*61c4878aSAndroid Build Coastguard Worker
402*61c4878aSAndroid Build Coastguard Workercc_library(
403*61c4878aSAndroid Build Coastguard Worker    name = "rpc_main",
404*61c4878aSAndroid Build Coastguard Worker    testonly = True,
405*61c4878aSAndroid Build Coastguard Worker    srcs = [
406*61c4878aSAndroid Build Coastguard Worker        "rpc_main.cc",
407*61c4878aSAndroid Build Coastguard Worker    ],
408*61c4878aSAndroid Build Coastguard Worker    deps = [
409*61c4878aSAndroid Build Coastguard Worker        ":pw_unit_test",
410*61c4878aSAndroid Build Coastguard Worker        ":rpc_service",
411*61c4878aSAndroid Build Coastguard Worker        "//pw_assert",
412*61c4878aSAndroid Build Coastguard Worker        "//pw_hdlc:default_addresses",
413*61c4878aSAndroid Build Coastguard Worker        "//pw_log",
414*61c4878aSAndroid Build Coastguard Worker        "//pw_rpc",
415*61c4878aSAndroid Build Coastguard Worker        "//pw_rpc/system_server",
416*61c4878aSAndroid Build Coastguard Worker    ],
417*61c4878aSAndroid Build Coastguard Worker)
418*61c4878aSAndroid Build Coastguard Worker
419*61c4878aSAndroid Build Coastguard Workercc_library(
420*61c4878aSAndroid Build Coastguard Worker    name = "static_library_support",
421*61c4878aSAndroid Build Coastguard Worker    testonly = True,
422*61c4878aSAndroid Build Coastguard Worker    srcs = ["static_library_support.cc"],
423*61c4878aSAndroid Build Coastguard Worker    hdrs = ["public/pw_unit_test/static_library_support.h"],
424*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
425*61c4878aSAndroid Build Coastguard Worker    # This library only works with the light backend
426*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = select({
427*61c4878aSAndroid Build Coastguard Worker        ":light_setting": [],
428*61c4878aSAndroid Build Coastguard Worker        "//conditions:default": ["@platforms//:incompatible"],
429*61c4878aSAndroid Build Coastguard Worker    }),
430*61c4878aSAndroid Build Coastguard Worker    deps = [":pw_unit_test"],
431*61c4878aSAndroid Build Coastguard Worker)
432*61c4878aSAndroid Build Coastguard Worker
433*61c4878aSAndroid Build Coastguard Workercc_library(
434*61c4878aSAndroid Build Coastguard Worker    name = "tests_in_archive",
435*61c4878aSAndroid Build Coastguard Worker    testonly = True,
436*61c4878aSAndroid Build Coastguard Worker    srcs = [
437*61c4878aSAndroid Build Coastguard Worker        "static_library_archived_tests.cc",
438*61c4878aSAndroid Build Coastguard Worker        "static_library_missing_archived_tests.cc",
439*61c4878aSAndroid Build Coastguard Worker    ],
440*61c4878aSAndroid Build Coastguard Worker    linkstatic = True,
441*61c4878aSAndroid Build Coastguard Worker    visibility = ["//visibility:private"],
442*61c4878aSAndroid Build Coastguard Worker    deps = [":pw_unit_test"],
443*61c4878aSAndroid Build Coastguard Worker)
444*61c4878aSAndroid Build Coastguard Worker
445*61c4878aSAndroid Build Coastguard Workerpw_cc_test(
446*61c4878aSAndroid Build Coastguard Worker    name = "static_library_support_test",
447*61c4878aSAndroid Build Coastguard Worker    srcs = ["static_library_support_test.cc"],
448*61c4878aSAndroid Build Coastguard Worker    deps = [
449*61c4878aSAndroid Build Coastguard Worker        ":pw_unit_test",
450*61c4878aSAndroid Build Coastguard Worker        ":static_library_support",
451*61c4878aSAndroid Build Coastguard Worker        ":tests_in_archive",
452*61c4878aSAndroid Build Coastguard Worker        "//pw_assert",
453*61c4878aSAndroid Build Coastguard Worker    ],
454*61c4878aSAndroid Build Coastguard Worker)
455*61c4878aSAndroid Build Coastguard Worker
456*61c4878aSAndroid Build Coastguard Workerpw_cc_test(
457*61c4878aSAndroid Build Coastguard Worker    name = "framework_test",
458*61c4878aSAndroid Build Coastguard Worker    srcs = ["framework_test.cc"],
459*61c4878aSAndroid Build Coastguard Worker    # TODO: https://pwbug.dev/325509758 - Passes but hangs on cleanup.
460*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = select({
461*61c4878aSAndroid Build Coastguard Worker        "//pw_build/constraints/chipset:rp2040": ["@platforms//:incompatible"],
462*61c4878aSAndroid Build Coastguard Worker        "//conditions:default": [],
463*61c4878aSAndroid Build Coastguard Worker    }),
464*61c4878aSAndroid Build Coastguard Worker    deps = [
465*61c4878aSAndroid Build Coastguard Worker        ":pw_unit_test",
466*61c4878aSAndroid Build Coastguard Worker        "//pw_assert",
467*61c4878aSAndroid Build Coastguard Worker        "//pw_result",
468*61c4878aSAndroid Build Coastguard Worker        "//pw_status",
469*61c4878aSAndroid Build Coastguard Worker    ],
470*61c4878aSAndroid Build Coastguard Worker)
471*61c4878aSAndroid Build Coastguard Worker
472*61c4878aSAndroid Build Coastguard Workerpw_cc_test(
473*61c4878aSAndroid Build Coastguard Worker    name = "framework_light_test",
474*61c4878aSAndroid Build Coastguard Worker    srcs = ["framework_light_test.cc"],
475*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = select({
476*61c4878aSAndroid Build Coastguard Worker        ":light_setting": [],
477*61c4878aSAndroid Build Coastguard Worker        "//conditions:default": ["@platforms//:incompatible"],
478*61c4878aSAndroid Build Coastguard Worker    }),
479*61c4878aSAndroid Build Coastguard Worker    deps = [
480*61c4878aSAndroid Build Coastguard Worker        ":pw_unit_test",
481*61c4878aSAndroid Build Coastguard Worker        "//pw_status",
482*61c4878aSAndroid Build Coastguard Worker        "//pw_string",
483*61c4878aSAndroid Build Coastguard Worker    ],
484*61c4878aSAndroid Build Coastguard Worker)
485*61c4878aSAndroid Build Coastguard Worker
486*61c4878aSAndroid Build Coastguard Worker# TODO(hepler): Build this as a cc_binary and use it in integration tests.
487*61c4878aSAndroid Build Coastguard Workerfilegroup(
488*61c4878aSAndroid Build Coastguard Worker    name = "test_rpc_server",
489*61c4878aSAndroid Build Coastguard Worker    srcs = ["test_rpc_server.cc"],
490*61c4878aSAndroid Build Coastguard Worker    # deps = [
491*61c4878aSAndroid Build Coastguard Worker    #     ":pw_unit_test",
492*61c4878aSAndroid Build Coastguard Worker    #     ":rpc_service",
493*61c4878aSAndroid Build Coastguard Worker    #     "//pw_log",
494*61c4878aSAndroid Build Coastguard Worker    #     "//pw_rpc/system_server",
495*61c4878aSAndroid Build Coastguard Worker    # ],
496*61c4878aSAndroid Build Coastguard Worker)
497*61c4878aSAndroid Build Coastguard Worker
498*61c4878aSAndroid Build Coastguard Workerfilegroup(
499*61c4878aSAndroid Build Coastguard Worker    name = "doxygen",
500*61c4878aSAndroid Build Coastguard Worker    srcs = [
501*61c4878aSAndroid Build Coastguard Worker        "light_public_overrides/pw_unit_test/framework_backend.h",
502*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/config.h",
503*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/event_handler.h",
504*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/googletest_handler_adapter.h",
505*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/googletest_style_event_handler.h",
506*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/logging_event_handler.h",
507*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/multi_event_handler.h",
508*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/printf_event_handler.h",
509*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/simple_printing_event_handler.h",
510*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/static_library_support.h",
511*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/status_macros.h",
512*61c4878aSAndroid Build Coastguard Worker        "public/pw_unit_test/test_record_event_handler.h",
513*61c4878aSAndroid Build Coastguard Worker    ],
514*61c4878aSAndroid Build Coastguard Worker)
515