blob: 4630a7c0c836daca0de13c8b49e694ad0539c76a [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/go/go_library.gni")
import("//build/go/go_test.gni")
import("//build/testing/host_test_data.gni")
import("//zircon/kernel/phys/qemu.gni")
group("tests") {
testonly = true
deps = []
if (host_os == "linux") {
deps = [ ":emulator_tests($host_toolchain)" ]
}
}
if (is_fuchsia) {
# qemu_boot_shim must be interpreted in the default toolchain.
if (current_toolchain == default_toolchain) {
group("test_data_kernel") {
testonly = true
deps = qemu_boot_shim.deps
metadata = {
test_runtime_deps = [ qemu_boot_shim.path ]
}
}
}
}
# Currently, we only support working with QEMU or FEMU on Linux.
if (is_linux) {
if (current_toolchain == toolchain_variant.base) {
# 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}",
root_build_dir),
"--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/android/aemu/release/${host_platform}",
root_build_dir),
"--dst",
rebase_path(archive_path, root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
]
}
generated_file("buildinfo.ini") {
testonly = true
contents = [
# The path to images.json relative to the test data directory. This must be relative
# the test data directory specifically, rather than the build directory because the
# build directory is not guaranteed to exist at runtime, especially on CI.
"image_manifest_path=" +
rebase_path("$root_build_dir/images.json",
"$root_out_dir/test_data/emulator"),
"target_cpu=$target_cpu",
]
outputs = [ "$root_out_dir/test_data/emulator/buildinfo.ini" ]
}
host_test_data("test_data") {
sources =
get_target_outputs(":buildinfo.ini") +
get_target_outputs(":archive-qemu") +
get_target_outputs(":archive-femu") +
[
# Any files referenced by :buildinfo.ini should be listed here.
"$root_build_dir/images.json",
]
deps = [
":archive-femu",
":archive-qemu",
":buildinfo.ini",
]
}
}
go_library("emulator") {
testonly = true
sources = [
"emulator.go",
"emulator_test.go",
]
deps = [
"//tools/qemu",
"//tools/virtual_device",
"//tools/virtual_device:proto",
]
# The emulator itself should only be included via the base toolchain, not
# any toolchain variant (such as sanitizers)
data_deps = [
":test_data(${toolchain_variant.base})",
":test_data_kernel($default_toolchain)",
]
}
go_test("emulator_tests") {
library = ":emulator"
}
}