blob: f73e598e1bdd8961559cd08e1898f611fe3514c9 [file]
# 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")
import("//build/zircon/tools.gni")
rustc_test("resolve_bootfs_package") {
name = "resolve-bootfs-package"
edition = "2018"
source_root = "src/resolve_bootfs_package.rs"
deps = [
"//sdk/fidl/fuchsia.component.resolution:fuchsia.component.resolution_rust",
"//sdk/fidl/fuchsia.io:fuchsia.io_rust",
"//src/lib/fuchsia-async",
"//src/lib/fuchsia-fs",
"//src/lib/storage/vfs/rust:vfs",
"//src/sys/component_manager:lib",
]
sources = [ "src/resolve_bootfs_package.rs" ]
}
if (current_toolchain == default_toolchain) {
# `assembled_system` requires a package with the name "pkgfs".
fuchsia_package("empty_pkgfs") {
testonly = true
package_name = "pkgfs"
}
# `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.
assembled_system("test_zbi") {
testonly = true
bootfs_labels = []
bootfs_package_labels = [ "//src/security/tests/pkg_test/assemblies/hello_world_v1:hello_world-package" ]
base_packages = [
":empty-pkg",
":empty_config",
]
}
output_file = "$target_out_dir/uncompressed_bootfs"
action("test_assembly") {
testonly = true
script = "//src/sys/component_manager/tests/fuchsia_boot_resolver/scripts/extract_bootfs_from_zbi.py"
deps = [
":test_zbi",
zbi_tool_target,
]
inputs = [
target_out_dir + "/test_zbi/test_zbi.zbi",
zbi_tool_path,
]
outputs = [ output_file ]
args = [
"--zbi",
rebase_path(zbi_tool_path, root_build_dir),
"--zbi-image",
rebase_path(target_out_dir + "/test_zbi/test_zbi.zbi", root_build_dir),
"--output",
rebase_path(outputs[0], root_build_dir),
]
}
resource("bootfs_resource") {
testonly = true
sources = [ output_file ]
outputs = [ "data/tests/uncompressed_bootfs" ]
deps = [ ":test_assembly" ]
}
fuchsia_test_component("resolve_bootfs_package-component") {
component_name = "resolve_bootfs_package"
manifest = "meta/resolve_bootfs_package.cml"
deps = [
":bootfs_resource",
":resolve_bootfs_package",
]
}
# This module tests the property that the FuchsiaBootResolver successfully
# resolves components that are encoded in a meta.far. This test is fully
# hermetic, despite using assembled_system, as it only uses that template
# to generate a wellformed hermetic bootfs.
fuchsia_test_package("fuchsia-boot-resolver-integration-tests") {
test_components = [ ":resolve_bootfs_package-component" ]
deps = [ ":bootfs_resource" ]
}
group("tests") {
testonly = true
deps = [ ":fuchsia-boot-resolver-integration-tests" ]
}
}