blob: aed6ef0d17ae558634911ee9864839c5f6f8e541 [file] [log] [blame]
# Copyright 2021 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.
import("//build/bazel/export_fuchsia_package_to_bazel.gni")
import("//build/components.gni")
import("//build/drivers.gni")
import("//tools/cmc/build/expect_includes.gni")
# WARNING: Prefer to use the realm-builder variants, unless you have a very basic use case and
# don't need hermeticity in your test.
#
# This is the static driver_test_realm. It is a layer on top of the driver_test_realm, that
# adds it as a static component in the test. This is done by bringing in the client_includes
# which is an expect_includes target with a client shard that the test must include in its cml.
# This client shard contains a child entry for the driver-test-realm component. This is provided
# with some default capabilities that simple tests can utilize (eg. the devfs directory), but it
# can't be customized any further to add more capabilities (like a test specific driver service).
#
# See the realm-builder libraries if any customization outside of what currently exists in the
# client shard is needed.
group("static") {
testonly = true
deps = [
":client_includes",
":driver_test_realm",
]
}
# This is the main driver_test_realm group. It contains the driver-test-realm component that
# configures the realm, as well as the inner components that are part of the inner realm.
# Generally this should not be depended on directly, instead either the static target or the
# realm_builder libraries should be depended on and they bring in this dependency.
group("driver_test_realm") {
deps = [
":driver_manager_test",
":driver_test_realm_component",
":dtr_support_component",
":fake_resolver",
":test_realm_manifest",
"//src/devices/bin/devfs:component-for-test",
"//src/devices/bin/driver-host:component",
"//src/devices/bin/driver-index:component",
"//src/devices/bin/driver_manager:driver_shared_libraries",
"//src/devices/bin/driver_manager/devfs:component",
]
}
group("tests") {
testonly = true
deps = [
":static_package",
"platform:tests",
"simple:tests",
"tests",
]
}
source_set("internal_server_cpp") {
sources = [
"src/internal_server.cc",
"src/internal_server.h",
]
deps = [ "//sdk/lib/component/incoming/cpp" ]
public_deps = [
"//sdk/fidl/fuchsia.component.resolution:fuchsia.component.resolution_cpp",
"//sdk/fidl/fuchsia.driver.test:fuchsia.driver.test_cpp",
]
}
executable("bin") {
output_name = "driver_test_realm"
sources = [
"driver_test_realm.cc",
"src/boot_items.cc",
"src/boot_items.h",
"src/root_job.cc",
"src/root_job.h",
"src/system_state.h",
]
deps = [
":driver_test_realm_config",
":internal_server_cpp",
"//sdk/fidl/fuchsia.boot:fuchsia.boot_cpp",
"//sdk/fidl/fuchsia.driver.development:fuchsia.driver.development_cpp",
"//sdk/fidl/fuchsia.io:fuchsia.io_cpp",
"//sdk/fidl/fuchsia.kernel:fuchsia.kernel_cpp",
"//sdk/fidl/fuchsia.system.state:fuchsia.system.state_cpp",
"//sdk/lib/async-loop:async-loop-cpp",
"//sdk/lib/component/incoming/cpp",
"//sdk/lib/component/outgoing/cpp",
"//sdk/lib/sys/component/cpp/testing:cpp",
"//sdk/lib/syslog/cpp",
"//sdk/lib/zbi-format",
"//src/lib/ddk",
"//src/lib/ddk:ddk-metadata-headers",
]
}
executable("dtr_support_bin") {
output_name = "dtr_support"
sources = [
"src/boot_items.cc",
"src/boot_items.h",
"src/dtr_support_main.cc",
"src/root_job.cc",
"src/root_job.h",
"src/system_state.h",
]
deps = [
":dtr_support_config",
"//sdk/fidl/fuchsia.boot:fuchsia.boot_cpp",
"//sdk/fidl/fuchsia.component.decl:fuchsia.component.decl_cpp",
"//sdk/fidl/fuchsia.component.resolution:fuchsia.component.resolution_cpp",
"//sdk/fidl/fuchsia.driver.development:fuchsia.driver.development_cpp",
"//sdk/fidl/fuchsia.driver.framework:fuchsia.driver.framework_cpp",
"//sdk/fidl/fuchsia.driver.test:fuchsia.driver.test_cpp",
"//sdk/fidl/fuchsia.io:fuchsia.io_cpp",
"//sdk/fidl/fuchsia.kernel:fuchsia.kernel_cpp",
"//sdk/fidl/fuchsia.pkg:fuchsia.pkg_cpp",
"//sdk/fidl/fuchsia.system.state:fuchsia.system.state_cpp",
"//sdk/lib/async-loop:async-loop-cpp",
"//sdk/lib/component/incoming/cpp",
"//sdk/lib/component/outgoing/cpp",
"//sdk/lib/syslog/cpp",
"//sdk/lib/zbi-format",
"//src/lib/ddk",
"//src/lib/ddk:ddk-metadata-headers",
"//src/lib/files",
"//third_party/rapidjson",
]
}
fuchsia_component_manifest("manifest") {
component_name = "driver_test_realm"
manifest = "meta/driver_test_realm.cml"
}
fuchsia_component_manifest("dtr_support_manifest") {
component_name = "dtr_support"
manifest = "meta/dtr_support.cml"
}
fuchsia_structured_config_cpp_elf_lib("driver_test_realm_config") {
cm_label = ":manifest"
}
fuchsia_structured_config_cpp_elf_lib("dtr_support_config") {
cm_label = ":dtr_support_manifest"
}
fuchsia_structured_config_values("driver_test_realm_config_default") {
cm_label = ":manifest"
values = {
tunnel_boot_items = false
}
}
fuchsia_component("driver_test_realm_component") {
cm_label = ":manifest"
deps = [
":bin",
":driver_test_realm_config_default",
]
}
fuchsia_component("dtr_support_component") {
cm_label = ":dtr_support_manifest"
deps = [ ":dtr_support_bin" ]
}
executable("fake_resolver_bin") {
output_name = "fake_resolver"
sources = [ "fake_resolver.cc" ]
data_deps = [ "//sdk/lib/driver_test_realm/fake_driver:component" ]
deps = [
"//sdk/fidl/fuchsia.component.decl:fuchsia.component.decl_cpp",
"//sdk/fidl/fuchsia.component.resolution:fuchsia.component.resolution_cpp",
"//sdk/fidl/fuchsia.driver.test:fuchsia.driver.test_cpp",
"//sdk/fidl/fuchsia.io:fuchsia.io_cpp",
"//sdk/fidl/fuchsia.pkg:fuchsia.pkg_cpp",
"//sdk/lib/async-loop:async-loop-cpp",
"//sdk/lib/async-loop:async-loop-default",
"//sdk/lib/component/incoming/cpp",
"//sdk/lib/component/outgoing/cpp",
"//sdk/lib/syslog/cpp",
"//src/lib/files",
"//third_party/rapidjson",
]
}
fuchsia_component("fake_resolver") {
manifest = "meta/fake_resolver.cml"
deps = [ ":fake_resolver_bin" ]
}
fuchsia_component_manifest("driver_manager_manifest") {
component_name = "driver_manager_test"
manifest = "meta/driver_manager_test.cml"
}
fuchsia_structured_config_values("test_config") {
cm_label = ":driver_manager_manifest"
values = {
set_root_driver_host_critical = false
delay_fallback_until_base_drivers_indexed = true
suspend_timeout_fallback = true
verbose = false
root_driver = "fuchsia-boot:///dtr#meta/test-parent-sys.cm"
enable_test_shutdown_delays = false
power_inject_offer = false
power_suspend_enabled = false
}
}
fuchsia_component("driver_manager_test") {
cm_label = ":driver_manager_manifest"
deps = [
":test_config",
"//src/devices/bin/driver_manager",
]
}
fuchsia_component_manifest("test_realm_manifest") {
component_name = "test_realm"
manifest = "meta/test_realm.cml"
restricted_features = [ "allow_long_names" ]
}
expect_includes("client_includes") {
includes = [ "meta/client.shard.cml" ]
}
fuchsia_package("static_package") {
testonly = true
package_name = "static_driver_test_realm"
deps = [
":static",
"//src/devices/misc/drivers/test-parent",
]
}
fuchsia_package("package") {
package_name = "driver_test_realm"
deps = [
":driver_test_realm",
"//src/devices/misc/drivers/test-parent",
]
}
exported_fuchsia_package_archive("package-archive") {
package = ":package"
}
# Define Bazel input resource so it can be used
export_fuchsia_package_to_bazel("package-bazel") {
package = ":package"
package_name = "driver_test_realm"
}