blob: ddd4ee74bdf0153c632e3dd44804c6fe0245ac9f [file] [log] [blame]
# Copyright 2022 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/dist/generated_resource.gni")
import("//build/testing/boot_tests/boot_test.gni")
import("efi_test.gni")
import("fat_filesystem.gni")
# Defines a UEFI filesystem image with a startup.nsh test script.
#
# The provided startup.nsh contents will be executed by the UEFI shell on boot.
#
# Subtargets
#
# * $target_name.fatfs
# - The associated fat_filesystem() target.
#
# Parameters
#
# * contents
# - Required: The desired contents of startup.nsh, by line.
# - Type: list(string)
#
# * data_deps
# - Optional: `resource()`s that should present in the script's local
# filesystem at runtime.
# - Type: list(label)
#
# * disabled
# - Optional: See boot_test().
# - Type: bool
# - Default: false
#
# * environments
# - Optional: See boot_test().
# - Type: list(scope)
# - Default: all_uefi_envs
#
template("efi_shell_test") {
assert(defined(invoker.contents),
"efi_shell_test(\"$target_name\") must define `contents`")
script_target = "$target_name.startup.nsh"
fs_target = "$target_name.fatfs"
main_target = target_name
generated_resource(script_target) {
forward_variables_from(invoker, [ "visibility" ])
testonly = true
if (defined(visibility)) {
visibility += [ ":$fs_target" ]
}
contents = invoker.contents
outputs = [ "startup.nsh" ]
}
fat_filesystem(fs_target) {
forward_variables_from(invoker,
[
"data_deps",
"visibility",
])
testonly = true
if (defined(visibility)) {
visibility += [ ":$main_target" ]
}
deps = [ ":$script_target" ]
outputs = [ "$target_out_dir/$main_target.fat" ]
}
boot_test(main_target) {
forward_variables_from(invoker,
[
"disabled",
"environments",
"visibility",
])
if (!defined(environments)) {
environments = all_uefi_envs
}
efi_disk = ":$fs_target"
}
}