blob: 193d74009de4556f6aa579211fef2267cc6c6615 [file] [log] [blame]
# 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.
# Start with reading README.md for details.
import("//build/components.gni")
import("//build/fidl/fidl.gni")
import("//build/rust/rustc_library.gni")
import("//build/rust/rustc_test.gni")
import("//build/testing/environments.gni")
import("//sdk/ctf/build/ctf.gni")
# Canonical target.
group("example") {
testonly = true
deps = [
":pkg",
":tests",
]
}
# Canonical target.
group("tests") {
testonly = true
deps = [ ":root_pkg" ]
}
# This target name, as well as other target names, should be short.
rustc_test("test") {
# This name must be long to avoid name clashes. It is also what appears
# in the manifest under the key `program.binary`.
name = "src_sys_time_example"
edition = "2021"
sources = [ "src/lib.rs" ]
source_root = "src/lib.rs"
deps = [
"//sdk/fidl/fuchsia.testing.harness:fuchsia.testing.harness_rust",
"//sdk/fidl/fuchsia.time:fuchsia.time_rust",
"//sdk/fidl/fuchsia.time.external:fuchsia.time.external_rust",
"//src/lib/fidl/rust/fidl",
"//src/lib/fuchsia",
"//src/lib/fuchsia-async",
"//src/lib/fuchsia-component",
"//src/lib/zircon/rust:fuchsia-zircon",
"//src/sys/time/testing/fidl/test.time.realm:fidl_rust",
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:chrono",
"//third_party/rust_crates:lazy_static",
]
}
# See target `:pkg` below.
fuchsia_component("component") {
testonly = true
manifest = "meta/default.cml"
deps = [ ":test" ]
}
# Declaring this package as `cft_fuchsia_package` allows it to become an
# interchangeable module in Fuchsia's testing framework CTF.
ctf_fuchsia_package("pkg") {
package_name = "src_sys_time_testing_example"
testonly = true
deps = [
":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",
]
}
# The test realm based integration tests must have a mostly empty "root"
# component, which only needs to start the test realm factory and the
# test driver components.
fuchsia_test_component("root") {
component_name = "test_root"
testonly = true
manifest = "meta/test-root.cml"
}
# This target together with `:root` above will lead to the component URL:
# `fuchsia-pkg://fuchsia.com/src_sys_time_testing_example_root#meta/root.cm`
#
# The package naming gets complicated fast, because all packages are served
# from a flat namespace. It would have perhaps been nicer to serve as:
#
# `fuchsia-pkg://fuchsia.com/src/sys/time/testing/example/root#meta/root.cm`
# or some such. But it's not ideal.
fuchsia_test_package("root_pkg") {
package_name = "src_sys_time_testing_example_root"
test_components = [
# The top-level component.
":root",
]
subpackages = [
# The test driver package
":pkg",
# The Timekeeper test realm factory (TTRF) package.
"//src/sys/time/testing/realm-proxy:pkg",
]
test_specs = {
log_settings = {
# Some tests produce "error" level logs as part of the test execution.
max_severity = "ERROR"
}
}
}