blob: 440bd605d181f6982b3a56f57af4f9a7a245654b [file] [log] [blame]
# Copyright 2019 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/assembly/assembled_system.gni")
import("//build/assembly/product_assembly_configuration.gni")
import("//build/assembly/product_bundle.gni")
import("//build/board.gni")
import("//build/images/args.gni")
import("//build/product.gni")
import("//build/testing/boot_tests/zbi_test.gni")
import("//src/storage/fshost/generated_fshost_config.gni")
declare_args() {
# Defines the default value of `kernel_zbi_test()` template `generate_cuckoo` parameters.
# When true, all instances of `kernel_zbi_tests()` will default to generating a `cuckoo_zbi_test()`
# which is a full system image generated for exfiltrating instrumentation data from a target system.
generate_cuckoo_tests = false
# Default value for `disabled` parameter for generated `cuckoo_test()`.
# TODO(https://fxbug.dev/320511796): Cleanup when no longer necessary.
disable_cuckoo_tests = false
}
template("_cuckoo_product_bundle") {
assert(current_toolchain == default_toolchain)
assert(defined(invoker.kernel_zbi))
main_target = target_name
assembled_system_target = "${target_name}.assembled_system"
stub_test_target = "${target_name}.test"
assembled_system_namespace = assembled_system_target
# This creates the target test to run against the cuckoo images, the purpose of
# this test is to trigger coverage collection.
fuchsia_unittest_package(stub_test_target) {
deps = [
"//src/sys/early_boot_instrumentation/test:early-boot-collector-stub",
]
test_specs = {
if ((defined(invoker.disabled) && invoker.disabled) ||
disable_cuckoo_tests) {
# A disabled test is marked by an empty environments list.
environments = []
} else {
forward_variables_from(invoker, [ "environments" ])
}
isolated = true
product_bundle = main_target
is_boot_test = true
bootup_timeout_secs = default_boot_test_timeout_secs
if (defined(invoker.timeout)) {
bootup_timeout_secs = invoker.timeout
}
}
}
product_assembly_configuration("${main_target}.product_config") {
testonly = true
platform = {
build_type = "eng"
intl = {
# A fake intl_services will be injected
config_type = "none"
}
development_support = {
enable_userboot_next_component_manager = true
}
}
product = {
}
base_packages = [
{
package_target = "//src/testing/fidl/intl_property_manager:fake_intl_services_package"
},
{
package_target = ":$stub_test_target"
},
]
}
# Generate the assembled system with the provided kernel_zbi.
assembly_kernel_zbi = invoker.kernel_zbi
assembled_system(assembled_system_target) {
testonly = true
namespace = assembled_system_namespace
image_name = "fuchsia"
kernel_zbi = assembly_kernel_zbi
board_config_label = board_configuration_label
product_assembly_config_label = ":${main_target}.product_config"
generate_fxfs = true
generate_vbmeta = use_vbmeta
}
product_bundle(main_target) {
testonly = true
name = main_target
system_a = "${target_out_dir}/${assembled_system_namespace}"
deps = [
":$assembled_system_target",
# While it is already a transitive dependency of the assembled system,
# that dependency is subject to package metadata barrier. Accordingly, we
# also depend directly the stub test package so it ends up in main
# repository.
":$stub_test_target",
]
}
}
# Composes a bootable kernel zbi test. That is, a zircon kernel that will launch
# a custom user space process instead of component manager.
#
# Subtargets
#
# * `${target_name}.cuckoo.assembled_system`
# Specifies a "cuckoo assembled system": an `assembled_system()` that
# contains a test package with a stub test component, and which boots the
# associated ZBI to a full Fuchsia system. This subtarget is only emitted
# if `generate_cuckoo = true`.
#
# Parameters
#
# * generate_cuckoo
# - Optional: Whether to generate a cuckoo assembled system and emit the
# `.cuckoo.assembled_system` subtarget (see above).
# - Type: boolean
# - Default: `kernel_zbi_test_generates_cuckoo`
#
# See zbi_test() for additional parameters.
template("kernel_zbi_test") {
generate_cuckoo = generate_cuckoo_tests
if (defined(invoker.generate_cuckoo)) {
generate_cuckoo = invoker.generate_cuckoo
}
main_target = target_name
cuckoo_deps = []
if (generate_cuckoo) {
cuckoo_target_name = "${target_name}.cuckoo"
if (default_toolchain == current_toolchain) {
_cuckoo_product_bundle(cuckoo_target_name) {
forward_variables_from(invoker,
[
"disabled",
"environments",
"timeout",
])
kernel_zbi = ":$main_target.zbi"
}
} else {
group(cuckoo_target_name) {
testonly = true
deps = [ ":$cuckoo_target_name($default_toolchain)" ]
}
}
cuckoo_deps = [ ":$cuckoo_target_name($default_toolchain)" ]
}
zbi_test(main_target) {
assert(current_cpu != "")
deps = []
data_deps = []
forward_variables_from(invoker, "*", [ "generate_cuckoo" ])
data_deps += cuckoo_deps
deps += [ "//zircon/kernel" ]
}
}