blob: 035b159306e3d066e4b6865540c287b72f7bf97f [file] [edit]
# Copyright 2026 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.
# Start with reading README.md for details.
load(
"//build/bazel/rules/components:fx_component.bzl",
"fx_component",
"fx_component_manifest",
)
load(
"//build/bazel/rules/packages:fx_packaged_binary.bzl",
"fx_packaged_binary",
)
load("//build/bazel/rules/rust:rustc_test.bzl", "rustc_test")
load("//sdk/ctf/build:ctf_fx_package.bzl", "ctf_fx_package")
package(default_applicable_licenses = ["//:license"])
# This target name, as well as other target names, should be short.
rustc_test(
name = "test",
srcs = ["src/lib.rs"],
# This name must be long to avoid name clashes. It is also what appears
# in the manifest under the key `program.binary`.
crate_name = "src_sys_time_example",
edition = "2024",
deps = [
"//sdk/fidl/fuchsia.testing.harness:fuchsia.testing.harness_rust",
"//sdk/fidl/fuchsia.time.external:fuchsia.time.external_rust",
"//sdk/fidl/fuchsia.time:fuchsia.time_rust",
"//sdk/rust/zx",
"//src/lib/fidl/rust/fidl",
"//src/lib/fuchsia",
"//src/lib/fuchsia-async",
"//src/lib/fuchsia-component",
"//src/sys/time/testing/fidl/test.time.realm:fidl_rust",
"//third_party/rust_crates/vendor:anyhow",
"//third_party/rust_crates/vendor:chrono",
],
)
fx_packaged_binary(
name = "test_packaged_bin",
testonly = True,
binary = ":test",
binary_name = "src_sys_time_example",
)
fx_component_manifest(
name = "component_manifest",
testonly = True,
component_name = "component",
includes = [
"//sdk/lib/inspect:client.shard",
"//sdk/lib/sys/component:realm_builder.shard",
"//sdk/lib/syslog:client.shard",
"//src/lib/fake-clock/lib:client.shard",
"//src/sys/test_runners/rust:default.shard.cml",
],
manifest = "meta/default.cml",
)
# See target `:pkg` below.
fx_component(
name = "component",
testonly = True,
compiled_manifest = ":component_manifest",
deps = [":test_packaged_bin"],
)
# Declaring this package as `ctf_fx_package` allows it to become an
# interchangeable module in Fuchsia's testing framework CTF.
#
# The test root package that subpackages it is in BUILD.gn, because it also
# subpackages `//src/sys/time/testing/realm-proxy:pkg`, which has no Bazel
# target yet.
ctf_fx_package(
name = "pkg",
package_name = "src_sys_time_testing_example",
components = [
":component",
"//src/lib/fake-clock/svc",
# Also package the realm builder server as a subcomponent in this same
# package. Required transitively.
"//src/lib/fuchsia-component-test/realm_builder_server:realm_builder_server_component",
],
)