blob: 0693b4e46c74872998ac43b3bf37551642d80652 [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/config/fuchsia/zircon.gni")
import("//build/go/go_library.gni")
import("//build/go/go_test.gni")
import("//build/testing/host_test_data.gni")
group("tests") {
testonly = true
deps = []
if (host_os == "linux") {
deps = [ ":emulator_tests($host_toolchain)" ]
}
}
# Currently, we only support working with QEMU or FEMU on Linux.
if (is_linux) {
# The infrastructure does not provide a way for host tests to access
# qemu, so we need to archive our own copy of qemu from the source
# tree.
action("archive-qemu") {
testonly = true
visibility = [ ":*" ]
archive_path = "$root_out_dir/test_data/emulator/qemu.tar.gz"
outputs = [ archive_path ]
depfile = "${archive_path}.d"
script = "archive.py"
args = [
"--src",
rebase_path("//prebuilt/third_party/qemu/${host_platform}"),
"--dst",
rebase_path(archive_path, root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
]
}
action("archive-femu") {
testonly = true
visibility = [ ":*" ]
archive_path = "$root_out_dir/test_data/emulator/femu.tar.gz"
outputs = [ archive_path ]
depfile = "${archive_path}.d"
script = "archive.py"
args = [
"--src",
rebase_path("//prebuilt/third_party/aemu/${host_platform}"),
"--dst",
rebase_path(archive_path, root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
]
}
host_test_data("kernel") {
visibility = [ ":*" ]
if (target_cpu == "arm64") {
kernel_binary = "qemu-boot-shim.bin"
deps = [ "//zircon/kernel/target/arm64/boot-shim:qemu" ]
} else if (target_cpu == "x64") {
kernel_binary = "multiboot.bin"
deps = [ "//zircon/kernel/target/pc/multiboot" ]
} else {
assert(false, "CPU not supported")
}
sources = [ "$root_build_dir/$kernel_binary" ]
outputs = [ "$root_out_dir/test_data/emulator/$kernel_binary" ]
}
target_cpu_txt = "$root_out_dir/test_data/emulator/target_cpu.txt"
generated_file("target_cpu_txt") {
testonly = true
contents = target_cpu
outputs = [ target_cpu_txt ]
}
host_test_data("test_data") {
sources = [ target_cpu_txt ] + get_target_outputs(":archive-qemu") +
get_target_outputs(":archive-femu")
deps = [
":archive-femu",
":archive-qemu",
":kernel",
":target_cpu_txt",
]
}
go_library("emulator") {
testonly = true
non_go_deps = [
":archive-femu",
":archive-qemu",
":kernel",
":test_data",
]
sources = [
"emulator.go",
"emulator_test.go",
]
deps = [ "//tools/qemu" ]
}
go_test("emulator_tests") {
gopackages = [ "go.fuchsia.dev/fuchsia/src/testing/emulator" ]
deps = [ ":emulator" ]
}
}