1# Copyright 2019 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://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, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") 16load( 17 "//pw_build:pigweed.bzl", 18 "pw_cc_binary", 19 "pw_cc_library", 20 "pw_cc_test", 21) 22load("//pw_protobuf_compiler:proto.bzl", "pw_proto_library") 23 24package(default_visibility = ["//visibility:public"]) 25 26licenses(["notice"]) 27 28pw_cc_library( 29 name = "config", 30 hdrs = ["public/pw_unit_test/config.h"], 31 includes = ["public"], 32 deps = [ 33 "//pw_polyfill", 34 ], 35) 36 37pw_cc_library( 38 name = "pw_unit_test", 39 deps = ["@pigweed_config//:pw_unit_test_googletest_backend"], 40) 41 42pw_cc_library( 43 name = "light", 44 srcs = [ 45 "framework.cc", 46 "public/pw_unit_test/internal/framework.h", 47 ], 48 hdrs = ["public_overrides/gtest/gtest.h"], 49 includes = [ 50 "public", 51 "public_overrides", 52 ], 53 deps = [ 54 ":config", 55 ":event_handler", 56 "//pw_assert", 57 "//pw_polyfill", 58 "//pw_preprocessor", 59 "//pw_span", 60 "//pw_string", 61 ], 62) 63 64pw_cc_library( 65 name = "event_handler", 66 hdrs = ["public/pw_unit_test/event_handler.h"], 67 includes = ["public"], 68) 69 70pw_cc_library( 71 name = "googletest_style_event_handler", 72 srcs = ["googletest_style_event_handler.cc"], 73 hdrs = ["public/pw_unit_test/googletest_style_event_handler.h"], 74 deps = [ 75 ":event_handler", 76 "//pw_preprocessor", 77 ], 78) 79 80pw_cc_library( 81 name = "simple_printing_event_handler", 82 srcs = ["simple_printing_event_handler.cc"], 83 hdrs = [ 84 "public/pw_unit_test/simple_printing_event_handler.h", 85 ], 86 includes = [ 87 "public", 88 ], 89 deps = [ 90 ":googletest_style_event_handler", 91 "//pw_preprocessor", 92 ], 93) 94 95pw_cc_library( 96 name = "simple_printing_main", 97 srcs = [ 98 "simple_printing_main.cc", 99 ], 100 deps = [ 101 ":pw_unit_test", 102 ":simple_printing_event_handler", 103 "//pw_span", 104 "//pw_sys_io", 105 ], 106) 107 108pw_cc_library( 109 name = "printf_event_handler", 110 hdrs = ["public/pw_unit_test/printf_event_handler.h"], 111 deps = [ 112 ":googletest_style_event_handler", 113 "//pw_preprocessor", 114 ], 115) 116 117pw_cc_library( 118 name = "printf_main", 119 srcs = ["printf_main.cc"], 120 deps = [ 121 ":printf_event_handler", 122 ":pw_unit_test", 123 ], 124) 125 126pw_cc_library( 127 name = "logging_event_handler", 128 srcs = [ 129 "logging_event_handler.cc", 130 ], 131 hdrs = [ 132 "public/pw_unit_test/logging_event_handler.h", 133 ], 134 includes = [ 135 "public", 136 ], 137 deps = [ 138 ":googletest_style_event_handler", 139 "//pw_log", 140 ], 141) 142 143pw_cc_binary( 144 name = "logging_main", 145 srcs = [ 146 "logging_main.cc", 147 ], 148 deps = [ 149 ":logging_event_handler", 150 "//pw_unit_test", 151 ], 152) 153 154proto_library( 155 name = "unit_test_proto", 156 srcs = ["pw_unit_test_proto/unit_test.proto"], 157 strip_import_prefix = "/pw_unit_test", 158) 159 160py_proto_library( 161 name = "unit_test_py_pb2", 162 srcs = ["pw_unit_test_proto/unit_test.proto"], 163) 164 165pw_proto_library( 166 name = "unit_test_cc", 167 deps = [":unit_test_proto"], 168) 169 170pw_cc_library( 171 name = "rpc_service", 172 srcs = [ 173 "rpc_light_event_handler.cc", 174 "unit_test_service.cc", 175 ], 176 hdrs = [ 177 "public/pw_unit_test/unit_test_service.h", 178 "rpc_light_public/pw_unit_test/internal/rpc_event_handler.h", 179 ], 180 includes = ["rpc_light_public"], 181 deps = [ 182 ":pw_unit_test", 183 ":unit_test_cc.pwpb", 184 ":unit_test_cc.raw_rpc", 185 "//pw_log", 186 ], 187) 188 189pw_cc_library( 190 name = "rpc_main", 191 srcs = [ 192 "rpc_main.cc", 193 ], 194 deps = [ 195 ":pw_unit_test", 196 ":rpc_service", 197 "//pw_hdlc:pw_rpc", 198 "//pw_log", 199 "//pw_rpc", 200 "//pw_rpc/system_server", 201 ], 202) 203 204pw_cc_library( 205 name = "static_library_support", 206 srcs = ["static_library_support.cc"], 207 hdrs = ["public/pw_unit_test/static_library_support.h"], 208 includes = ["public"], 209 deps = [":light"], # This library only works with the light backend 210) 211 212pw_cc_library( 213 name = "tests_in_archive", 214 srcs = [ 215 "static_library_archived_tests.cc", 216 "static_library_missing_archived_tests.cc", 217 ], 218 linkstatic = True, 219 visibility = ["//visibility:private"], 220 deps = [":pw_unit_test"], 221) 222 223pw_cc_test( 224 name = "static_library_support_test", 225 srcs = ["static_library_support_test.cc"], 226 deps = [ 227 ":static_library_support", 228 ":tests_in_archive", 229 "//pw_assert", 230 ], 231) 232 233pw_cc_test( 234 name = "framework_test", 235 srcs = ["framework_test.cc"], 236 deps = [ 237 ":pw_unit_test", 238 "//pw_assert", 239 ], 240) 241 242# TODO(hepler): Build this as a cc_binary and use it in integration tests. 243filegroup( 244 name = "test_rpc_server", 245 srcs = ["test_rpc_server.cc"], 246 # deps = [ 247 # ":pw_unit_test", 248 # ":rpc_service", 249 # "//pw_log", 250 # "//pw_rpc/system_server", 251 # ], 252) 253 254# GTest is not yet supported in the Bazel build. This filegroup silences 255# warnings about these files not being included in the Bazel build. 256filegroup( 257 name = "gtest_support", 258 srcs = [ 259 "googletest_handler_adapter.cc", 260 "public/pw_unit_test/googletest_handler_adapter.h", 261 "rpc_gtest_event_handler.cc", 262 "rpc_gtest_public/pw_unit_test/internal/rpc_event_handler.h", 263 ], 264) 265