blob: a22196a4de568efdf17888a780f7e18c85622b60 [file] [log] [blame]
# Copyright 2020 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/host.gni")
import("//build/rust/rustc_library.gni")
import("//build/rust/rustc_test.gni")
import("//build/testing/host_test_data.gni")
import("//build/zircon/tools.gni")
if (is_host) {
template("scrutiny_utils_blobfs_testdata") {
assert(defined(invoker.blobs),
"scrutiny_utils_blobfs_testdata() requires blobs")
assert(defined(invoker.blobfs_manifest),
"scrutiny_utils_blobfs_testdata() requires blobfs_manifest")
action(target_name) {
script = blobfs_tool_path
output = "$target_out_dir/$target_name/$target_name.blk"
args = [
"--compress",
rebase_path(output, root_build_dir),
"create",
"--manifest",
rebase_path(invoker.blobfs_manifest, root_build_dir),
]
deps = [ blobfs_tool_target ]
inputs = [ invoker.blobfs_manifest ] + invoker.blobs
outputs = [ output ]
}
}
scrutiny_utils_blobfs_testdata("alpha_beta_blobfs") {
blobs = [
"testdata/alpha",
"testdata/beta",
]
blobfs_manifest = "testdata/blob.alpha_beta.manifest"
}
scrutiny_utils_blobfs_testdata("beta_gamma_blobfs") {
blobs = [
"testdata/beta",
"testdata/gamma",
]
blobfs_manifest = "testdata/blob.beta_gamma.manifest"
}
host_test_data("testdata") {
alpha_beta_blobfs = get_label_info(":alpha_beta_blobfs", "target_out_dir") +
"/alpha_beta_blobfs/alpha_beta_blobfs.blk"
beta_gamma_blobfs = get_label_info(":beta_gamma_blobfs", "target_out_dir") +
"/beta_gamma_blobfs/beta_gamma_blobfs.blk"
deps = [
":alpha_beta_blobfs",
":beta_gamma_blobfs",
]
sources = [
"testdata/alpha",
"testdata/beta",
"testdata/delta",
"testdata/gamma",
alpha_beta_blobfs,
beta_gamma_blobfs,
]
outputs = [ "$target_out_dir/testdata/{{source_file_part}}" ]
}
rustc_library("utils") {
name = "scrutiny_utils"
with_unit_tests = true
edition = "2021"
visibility = [
"//src/developer/ffx/plugins/scrutiny/*",
"//src/security/scrutiny/*",
]
deps = [
"//src/lib/fuchsia-url",
"//src/sys/pkg/lib/far/rust:fuchsia-archive",
"//src/sys/pkg/lib/fuchsia-hash",
"//src/sys/pkg/lib/fuchsia-merkle",
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:bincode",
"//third_party/rust_crates:byteorder",
"//third_party/rust_crates:hex",
"//third_party/rust_crates:libc",
"//third_party/rust_crates:log",
"//third_party/rust_crates:pathdiff",
"//third_party/rust_crates:serde",
"//third_party/rust_crates:thiserror",
]
test_deps = [
"//third_party/rust_crates:maplit",
"//third_party/rust_crates:tempfile",
]
non_rust_deps = [
"//src/lib/chunked-compression",
"//src/lib/fuchsia",
"//src/security/scrutiny/utils/ffi",
"//third_party/zstd",
]
sources = [
"src/artifact.rs",
"src/blobfs.rs",
"src/blobfs_export.rs",
"src/bootfs.rs",
"src/fvm.rs",
"src/golden.rs",
"src/key_value.rs",
"src/lib.rs",
"src/package.rs",
"src/url.rs",
"src/usage.rs",
"src/zbi.rs",
"src/zstd.rs",
]
# TODO(fxbug.dev/92670): Needed by test. Remove when fixed.
configs += [ "//build/config/rust:output_dir_sensitive" ]
}
config("test_config") {
testdata_dir = get_label_info(":testdata($host_toolchain)",
"target_out_dir") + "/testdata"
rustenv = [ "TESTDATA_DIR=" + rebase_path(testdata_dir, root_build_dir) ]
}
rustc_test("integration_tests") {
source_root = "test/lib.rs"
sources = [ "test/lib.rs" ]
edition = "2018"
inputs = [
"testdata/alpha",
"testdata/beta",
"testdata/gamma",
"testdata/delta",
]
configs += [ ":test_config" ]
disable_clippy = true # TODO(fxbug.dev/86506): clippy needs env vars
# TODO(fxbug.dev/92670): Needed by test. Remove when fixed.
configs += [ "//build/config/rust:output_dir_sensitive" ]
deps = [
":testdata($host_toolchain)",
":utils($host_toolchain)",
"//src/sys/pkg/lib/fuchsia-merkle",
"//third_party/rust_crates:once_cell",
]
non_rust_deps = [
"//src/lib/chunked-compression",
"//src/security/scrutiny/utils/ffi",
"//third_party/zstd",
]
}
}
group("tests") {
testonly = true
public_deps = [
":integration_tests($host_toolchain)",
":utils_test($host_toolchain)",
]
}