blob: 36c3086028a84d6af1893e203a1c629bf83fc2e7 [file] [log] [blame]
# Copyright 2020 The Fuchsia Authors
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT
import("//build/testing/boot_tests/boot_test.gni")
import("qemu.gni")
# Defines a boot test that runs a QEMU kernel directly, for each supported
# QEMU boot format. In particular, the expanded `boot_test()` instances are
# named "$target_name.$format" for each $format in $qemu_boot_formats. The
# The overall $target_name is a group of all those tests.
#
# Parameters
#
# * initrd
# - Optional: A ramdisk (e.g., ZBI) with which to boot.
# - Type: label
#
# Apart from output_dir and output_extension, other parameters are propagated
# to phys_executable(), which see.
#
template("qemu_kernel_test") {
group_target = target_name
group(group_target) {
forward_variables_from(invoker, [ "visibility" ])
testonly = true
deps = []
foreach(qemu, qemu_boot_formats) {
deps += [ ":$target_name.${qemu.name}" ]
}
}
foreach(qemu, qemu_boot_formats) {
test_target = "$group_target.${qemu.name}"
# Make this sub-target as public as the overall group target is.
# But make sure it also allows the group's deps to list it, and
# to itself for the environment redirect.
public_visibility = []
if (defined(invoker.visibility)) {
public_visibility = invoker.visibility + [
":$group_target",
":$test_target",
]
} else {
public_visibility = [ "*" ]
}
if (toolchain_variant.base == qemu.environment) {
executable_target = "_qemu_phys_test.$test_target.executable"
phys_executable(executable_target) {
testonly = true
visibility = [ ":*" ]
output_name = test_target
deps = []
forward_variables_from(invoker,
"*",
[
"initrd",
"output_dir",
"output_extension",
"output_name",
"tags",
"target_name",
"testonly",
"timeout",
"visibility",
])
deps += qemu.deps + [ "//zircon/kernel/phys/test:qemu-test-main" ]
}
boot_test(test_target) {
visibility = public_visibility
# The special kernel is all that really matters for this test.
device_types = [ "QEMU" ]
qemu_kernel = ":$executable_target"
if (defined(invoker.initrd)) {
zbi = invoker.initrd
}
}
} else {
group(test_target) {
visibility = public_visibility
testonly = true
public_deps = [ ":$test_target(${qemu.environment})" ]
}
not_needed(invoker, "*")
}
}
}