blob: 21be00cf87833caa565468a3b475fb88a36f2cce [file] [log] [blame]
# Copyright 2023 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/zbi_test.gni")
import("//build/zbi/kernel_cmdline.gni")
import("//zircon/kernel/kernel_package.gni")
import("//zircon/kernel/phys/kernel_elf_binary.gni")
import("//zircon/kernel/phys/phys_executable.gni")
# Defines a physload module and a ZBI test that loads it. This provides a
# streamlined way of running boot test logic in the phys environment, allowing
# for physload to take care of the basic set-up and execution. See
# //zircon/kernel/phys/physload.h for more information on the physload
# machinery. As a test variation, sources specified in instances of this
# template are expected to implement PhysLoadTestMain() rather than
# PhysLoadModuleMain(): see
# //zircon/kernel/phys/test/physload-test-main.h for more information.
#
# Subtargets
#
# * $target_name.binary
# The underlying kernel_elf_binary() target defining the physload module.
#
# Parameters
#
# * deps
# - Optional: The usual meaning, though this list need not include
# //zircon/kernel/phys:physload.module nor
# //zircon/kernel/phys/test:physload-test-main, as these
# dependencies are added automatically.
# - Type: list of labels
#
# * data_deps
# - Optional: data dependencies of the underlying binary target. Any
# resources() specified here are ultimately aggregated in the associated
# kernel package.
# - Type: list of labels
#
# For all other parameters see kernel_elf_binary().
template("physload_binary_test") {
binary_target = "$target_name.binary"
package_target = "_physload_binary_test.$target_name.kernel_package"
cmdline_target = "_physload_binary_test.$target_name.cmdline"
main_target = target_name
if (toolchain_environment == "kernel.phys") {
kernel_elf_binary(binary_target) {
output_name = main_target
visibility = [ ":*" ]
testonly = true
# Data deps are aggregated separately by the kernel package.
forward_variables_from(invoker,
"*",
[
"data_deps",
"testonly",
"visibility",
])
deps += [ "//zircon/kernel/phys/test:physload-test-main" ]
}
kernel_package(package_target) {
visibility = [ ":*" ]
testonly = true
prefix = ""
deps = [ ":$binary_target" ]
if (defined(invoker.data_deps)) {
deps += invoker.data_deps
}
}
} else {
group(binary_target) {
testonly = true
forward_variables_from(invoker, [ "visibility" ])
if (!defined(visibility)) {
visibility = []
}
visibility += [ ":*" ]
deps = [ ":$binary_target($phys_toolchain)" ]
}
not_needed(invoker, "*")
}
kernel_cmdline(cmdline_target) {
visibility = [ ":*" ]
testonly = true
args = [ "kernel.phys.next=$main_target" ]
}
zbi_test(main_target) {
forward_variables_from(invoker, [ "visibility" ])
if (!defined(visibility)) {
visibility = []
}
visibility += [ ":*" ]
deps = [
":$cmdline_target",
":$package_target($phys_toolchain)",
]
}
}