| # Copyright 2026 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/cpp/library_headers.gni") | |
| import("//build/testing/boot_tests/boot_test.gni") | |
| import("//build/toolchain/toolchain_environment.gni") | |
| import("//zircon/kernel/phys/linuxboot-embed/linuxboot_embed.gni") | |
| import("//zircon/kernel/phys/phys_executable.gni") | |
| import("//zircon/kernel/phys/qemu.gni") | |
| library_headers("headers") { | |
| headers = [ "phys/linuxboot-embed/linuxboot-embed.h" ] | |
| public_deps = [ "//zircon/kernel/lib/ktl:headers" ] | |
| } | |
| source_set("linuxboot-embed") { | |
| public_deps = [ ":headers" ] | |
| sources = [ "linuxboot-embed.cc" ] | |
| deps = [ | |
| "//zircon/kernel/lib/arch", | |
| "//zircon/kernel/lib/ktl", | |
| "//zircon/kernel/lib/libc", | |
| ] | |
| } | |
| qemu_linuxboot_embed = [] | |
| foreach(qemu, qemu_boot_formats) { | |
| if (qemu.name == "linuxboot" && qemu.has_embed) { | |
| qemu_linuxboot_embed += [ qemu ] | |
| } | |
| } | |
| if (qemu_linuxboot_embed != []) { | |
| boot_test("linuxboot-embed-test") { | |
| qemu_kernel = ":linuxboot-embed-hello-world-test-packed($phys_toolchain)" | |
| foreach(qemu, qemu_linuxboot_embed) { | |
| timeout = qemu.timeout | |
| environments = qemu.supported_environments | |
| forward_variables_from(qemu, [ "disabled" ]) | |
| } | |
| } | |
| if (toolchain_environment == "kernel.phys") { | |
| phys_executable("linuxboot-embed-hello-world-test") { | |
| testonly = true | |
| sources = [ "linuxboot-embed-hello-world-test.cc" ] | |
| deps = [ | |
| ":linuxboot-embed", | |
| "//zircon/kernel/lib/ktl", | |
| "//zircon/kernel/lib/libc", | |
| "//zircon/kernel/phys/test:qemu-test-main", | |
| "//zircon/system/ulib/pretty", | |
| ] | |
| foreach(qemu, qemu_linuxboot_embed) { | |
| deps += qemu.deps | |
| } | |
| } | |
| generated_file("linuxboot-embed-hello-world-test-data1.txt") { | |
| visibility = [ ":*" ] | |
| testonly = true | |
| outputs = [ "$target_gen_dir/$target_name" ] | |
| output_conversion = "list lines" | |
| contents = [ "Hello, world!" ] | |
| } | |
| generated_file("linuxboot-embed-hello-world-test-data2.txt") { | |
| visibility = [ ":*" ] | |
| testonly = true | |
| outputs = [ "$target_gen_dir/$target_name" ] | |
| output_conversion = "list lines" | |
| contents = [ "Lorem ipsum" ] | |
| } | |
| linuxboot_embed("linuxboot-embed-hello-world-test-packed") { | |
| visibility = [ ":*" ] | |
| testonly = true | |
| shim_label = ":linuxboot-embed-hello-world-test" | |
| deps = [ | |
| ":linuxboot-embed-hello-world-test-data1.txt", | |
| ":linuxboot-embed-hello-world-test-data2.txt", | |
| ] | |
| inputs = [] | |
| foreach(label, deps) { | |
| inputs += get_target_outputs(label) | |
| } | |
| emulator_support_aib = true | |
| } | |
| } | |
| } | |
| group("boot_tests") { | |
| testonly = true | |
| if (qemu_linuxboot_embed != []) { | |
| deps = [ ":linuxboot-embed-test" ] | |
| } | |
| } |