blob: ee2162aca418e7dd05e5fd3a8388592a97e47cfe [file] [log] [blame]
# Copyright 2022 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/assembly/assembled_system.gni")
import("//build/components/fuchsia_package.gni")
import("//build/config.gni")
import("//build/testing/host_test_data.gni")
# `assembled_system` needs at least one package in base_packages.
fuchsia_package("empty-pkg") {
testonly = true
package_name = "empty-pkg"
}
config_data("empty_config") {
for_pkg = "empty-pkg"
sources = [ "empty_config" ]
outputs = [ "empty/{{source_file_part}}" ]
}
# `assembled_system` builds a zbi and blob.blk for consumption by the test.
_assemble_system_target_name = "assembly"
assembled_system(_assemble_system_target_name) {
testonly = true
bootfs_labels = []
base_packages = [
":empty-pkg",
":empty_config",
]
}
# `assembled_system` builds a zbi, specifying `ramdisk_fvm_in_zbi = true`
# tests the path where the blobfs exists in the zbi and is automatically
# extracted as part of the zbi, such as in recovery images.
_assemble_system_recovery_target_name = "assembly_recovery"
assembled_system(_assemble_system_recovery_target_name) {
testonly = true
bootfs_labels = []
ramdisk_fvm_in_zbi = true
base_packages = [
":empty-pkg",
":empty_config",
]
}
if (is_host) {
host_test_data("testdata") {
deps = [
":${_assemble_system_recovery_target_name}.image_assembler($target_toolchain)",
":${_assemble_system_target_name}.image_assembler($target_toolchain)",
]
sources = [
get_label_info(
":${_assemble_system_target_name}.image_assembler($target_toolchain)",
"target_out_dir") + "/${_assemble_system_target_name}/blob.blk",
get_label_info(
":${_assemble_system_target_name}.image_assembler($target_toolchain)",
"target_out_dir") + "/${_assemble_system_target_name}/${_assemble_system_target_name}.zbi",
get_label_info(
":${_assemble_system_recovery_target_name}.image_assembler($target_toolchain)",
"target_out_dir") + "/${_assemble_system_recovery_target_name}/${_assemble_system_recovery_target_name}.zbi",
]
outputs = [ "$target_out_dir/testdata/{{source_file_part}}" ]
metadata = {
package_barrier = []
}
}
# Required for the test to be able to call ffx.
host_test_data("copy_host_tools") {
sources = [ "${host_tools_dir}/ffx" ]
deps = [ "//src/developer/ffx:host($host_toolchain)" ]
outputs = [ "$target_out_dir/host_tools/{{source_file_part}}" ]
}
config("config") {
testdata_out_dir =
get_label_info(":testdata($host_toolchain)", "target_out_dir")
host_tools_out_dir =
get_label_info(":copy_host_tools($host_toolchain)", "target_out_dir")
ffx_path = "$host_tools_out_dir/host_tools/ffx"
blobfs_path = "$testdata_out_dir/testdata/blob.blk"
zbi_path = "$testdata_out_dir/testdata/${_assemble_system_target_name}.zbi"
recovery_zbi_path = "$testdata_out_dir/testdata/${_assemble_system_recovery_target_name}.zbi"
rustenv = [
"FFX_TOOL_PATH=" + rebase_path(ffx_path, root_build_dir),
"BLOBFS_PATH=" + rebase_path(blobfs_path, root_build_dir),
"ZBI_PATH=" + rebase_path(zbi_path, root_build_dir),
"RECOVERY_ZBI_PATH=" + rebase_path(recovery_zbi_path, root_build_dir),
]
}
rustc_test("test") {
source_root = "src/lib.rs"
edition = "2018"
deps = [
":copy_host_tools($host_toolchain)",
":testdata($host_toolchain)",
"//third_party/rust_crates:tempfile",
]
sources = [ "src/lib.rs" ]
configs += [ ":config" ]
# TODO(fxbug.dev/97055): LSAN says that Scrutiny has a leak, disable this test in ASAN
if (is_asan) {
test_environments = []
}
}
}
group("tests") {
testonly = true
deps = [ ":test($host_toolchain)" ]
}