| # Copyright 2024 The Fuchsia Authors. All rights reserved. | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| load("//build/bazel/rules/cc:fx_cc_library.bzl", "fx_cc_library") | |
| load("//build/bazel/rules/cc:fx_cc_test_binary.bzl", "fx_cc_test_binary") | |
| load("//build/bazel/rules/packages:fx_package.bzl", "fx_package") | |
| load("//build/bazel/rules/testing:fx_test.bzl", "fx_test") | |
| load("//build/bazel/rules/testing:fx_unittest_component.bzl", "fx_unittest_component") | |
| package(default_applicable_licenses = ["//:license"]) | |
| test_suite( | |
| name = "tests", | |
| tests = [":predicates-lib-test"], | |
| visibility = ["//src/lib:__pkg__"], | |
| ) | |
| # In GN, //third_party/googletest:gtest is testonly, whereas in Bazel @com_google_googletest//:gtest | |
| # is not testonly and non-testonly targets depend on :predicates. | |
| # @bazel2gn:raw_attribute:testonly = true | |
| fx_cc_library( | |
| name = "predicates", | |
| srcs = [ | |
| "status.cc", | |
| ], | |
| hdrs = [ | |
| "status.h", | |
| ], | |
| visibility = ["//:__subpackages__"], | |
| deps = [ | |
| # "status.h" has #include <lib/fit/result.h> | |
| "//sdk/lib/fit", | |
| # "status.h" has #include <zircon/status.h>. | |
| "//src/zircon/lib/zircon:headers", | |
| # "status.h" has #include <gtest/gtest.h>. | |
| "@com_google_googletest//:gtest", | |
| ], | |
| alwayslink = True, | |
| ) | |
| fx_cc_test_binary( | |
| name = "predicates-lib-unittests", | |
| srcs = ["predicates_test.cc"], | |
| # Links zx_status_get_string from the Zircon vDSO. | |
| target_compatible_with = ["@platforms//os:fuchsia"], | |
| deps = [ | |
| ":predicates", | |
| "//src/lib/fxl/test:gtest_main", | |
| "//zircon/system/ulib/zx", | |
| ], | |
| ) | |
| fx_unittest_component( | |
| name = "predicates-lib-test-component", | |
| binary = ":predicates-lib-unittests", | |
| component_name = "predicates-lib-test", | |
| ) | |
| fx_package( | |
| name = "predicates-lib-test-package", | |
| package_name = "predicates-lib-test", | |
| test_components = [":predicates-lib-test-component"], | |
| ) | |
| fx_test( | |
| name = "predicates-lib-test", | |
| environments = ["//build/testing/environments:emu_env"], | |
| package = ":predicates-lib-test-package", | |
| ) |