blob: a2d3ce1f7efb5193e15ccbfd28816b301889957d [file] [log] [blame]
# Copyright 2020 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/components.gni")
# Produces a component with an isolated driver manager which can be used to launch drivers.
#
# Example Usage:
#
# ```
# isolated_devmgr_unittest_component("my-component") {
# args = [ "--svc_name=fuchsia.example.IsolatedDevmgr" ]
# }
#
# fuchsia_test_package("my-package") {
# test_components = [ ":my-component" ]
# }
# ```
# The component above will have the following launch URL:
# `fuchsia-pkg://fuchsia.com/my-package#meta/my-component.cmx`
#
# `isolated_devmgr_unittest_component` may depend on any number of `driver_module()` targets to
# ensure that any `fuchsia_package()` that includes them will include the same drivers.
#
# ```
# driver_module("my_driver") {
# ...
# }
#
# isolated_devmgr_unittest_component("my-component") {
# deps = [ ":my_driver" ]
# ...
# }
# ```
#
# The component defined above will be able to read my_driver under the path
# "/pkg/driver/my_driver.so" in its sandbox.
#
# Parameters
#
# executable_path (required)
# Specify the packaged path of the test executable.
# Example: "test/my_executable"
# This executable must be generated by one of the `deps`.
# This is used in generating the manifest.
# Type: string
#
# services (optional)
# Provide test with a list of additional services necessary to run.
#
# deps
# visibility
template("isolated_devmgr_unittest_component") {
assert(
defined(invoker.executable_path),
"`executable_path` must be specified when calling isolated_devmgr_unittest_package($target_name)")
additional_services = []
if (defined(invoker.services)) {
additional_services = invoker.services
}
additional_features = []
if (defined(invoker.features)) {
additional_features = invoker.features
}
generated_target = "${target_name}_generated_manifest"
manifest = "$target_out_dir/${generated_target}.cmx"
action(generated_target) {
script = "//zircon/system/ulib/devmgr-integration-test/generate-component-manifest.py"
outputs = [ manifest ]
args = [
"--executable-path",
invoker.executable_path,
"--output",
rebase_path(manifest, root_build_dir),
]
foreach(service, additional_services) {
args += [
"--additional-services",
service,
]
}
foreach(feature, additional_features) {
args += [
"--additional-features",
feature,
]
}
visibility = [ ":*" ]
}
fuchsia_component(target_name) {
forward_variables_from(invoker,
[
"deps",
"manifest",
"visibility",
])
component_name = target_name
if (defined(invoker.component_name)) {
component_name = invoker.component_name
}
testonly = true
if (!defined(deps)) {
deps = []
}
deps += [
":${generated_target}",
"//src/bringup/bin/device-name-provider",
"//src/devices/bin/driver_host",
"//src/devices/bin/driver_manager",
"//src/lib/isolated_devmgr:isolated_devmgr",
"//src/storage/fshost",
]
}
}
# Produces a component and package with an isolated driver manager which can be used to launch
# drivers.
#
# Example Usage:
#
# ```
# isolated_devmgr_unittest_package("my-driver-test") {
# args = [ "--svc_name=fuchsia.example.IsolatedDevmgr" ]
# }
# ```
# The component above will have the following launch URL:
# `fuchsia-pkg://fuchsia.com/my-driver-test#meta/my-driver-test.cmx`
#
# `isolated_devmgr_unittest_package` may depend on any number of `driver_module()` targets to
# include them in the package.
#
# ```
# driver_module("my_driver") {
# ...
# }
#
# isolated_devmgr_unittest_package("my-driver-test") {
# deps = [ ":my_driver" ]
# ...
# }
# ```
#
# The component defined above will be able to read my_driver under the path
# "/pkg/driver/my_driver.so" in its sandbox.
#
# Parameters
#
# executable_path (required)
# Specify the packaged path of the test executable.
# Example: "test/my_executable"
# This executable must be generated by one of the `deps`.
# This is used in generating the manifest.
# Type: string
#
# services (optional)
# Provide test with a list of additional services necessary to run.
#
# package_name (optional)
# The name of the package.
# Type: string
# Default: target_name
#
# test_specs (optional)
# Additional test specifications to apply to the test defined above.
# See `test_spec.gni`.
# Type: scope
#
# deps
# visibility
template("isolated_devmgr_unittest_package") {
component_target = "${target_name}_component"
isolated_devmgr_unittest_component(component_target) {
forward_variables_from(invoker,
[
"deps",
"executable_path",
"services",
"features",
])
component_name = invoker.target_name
visibility = [ ":*" ]
}
fuchsia_test_package(target_name) {
forward_variables_from(invoker,
[
"package_name",
"test_specs",
"visibility",
])
test_components = [ ":$component_target" ]
}
}