| # Copyright 2024 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/assembly/board_configuration.gni") |
| import("//build/assembly/bootfs_files_for_assembly.gni") |
| import("//build/assembly/generated_partitions_config.gni") |
| import("//build/assembly/product_assembly_configuration.gni") |
| import("//build/assembly/product_bundle.gni") |
| import("//build/host.gni") |
| import("//build/images/args.gni") |
| import("//build/rust/rustc_library.gni") |
| import("//build/testing/host_test_data.gni") |
| import("//zircon/kernel/phys/qemu.gni") |
| |
| if (is_host) { |
| files = { |
| outdir = |
| get_label_info(":product_bundle($target_toolchain)", "target_out_dir") |
| product_bundle = "$outdir/product_bundle" |
| } |
| |
| if (has_board) { |
| host_test_data("testdata") { |
| deps = [ ":product_bundle($target_toolchain)" ] |
| sources = [ files.product_bundle ] |
| } |
| } |
| |
| config("test_config") { |
| rustenv = [ "PRODUCT_BUNDLE_PATH=" + |
| rebase_path(files.product_bundle, root_build_dir) ] |
| } |
| |
| rustc_library("collector") { |
| name = "scrutiny_collector" |
| with_unit_tests = true |
| edition = "2021" |
| deps = [ |
| "//sdk/fidl/fuchsia.component.decl:fuchsia.component.decl_rust", |
| "//sdk/fidl/fuchsia.component.internal:fuchsia.component.internal_rust", |
| "//src/lib/directed_graph", |
| "//src/lib/fidl/rust/fidl", |
| "//src/lib/fuchsia-url", |
| "//src/security/lib/scrutiny/collection", |
| "//src/security/lib/scrutiny/utils", |
| "//src/sys/lib/cm_config", |
| "//src/sys/lib/cm_fidl_validator", |
| "//src/sys/lib/cm_rust", |
| "//src/sys/lib/cm_types", |
| "//src/sys/lib/component_id_index", |
| "//src/sys/lib/config_encoder", |
| "//src/sys/lib/moniker", |
| "//src/sys/lib/routing", |
| "//src/sys/pkg/lib/far/rust:fuchsia-archive", |
| "//src/sys/pkg/lib/fuchsia-hash", |
| "//src/sys/pkg/lib/fuchsia-merkle", |
| "//src/sys/pkg/lib/update-package", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:base64", |
| "//third_party/rust_crates:log", |
| "//third_party/rust_crates:maplit", |
| "//third_party/rust_crates:serde", |
| "//third_party/rust_crates:serde_json5", |
| "//third_party/rust_crates:url", |
| "//tools/lib/cm_fidl_analyzer", |
| ] |
| test_deps = [ |
| ":testdata", |
| "//src/lib/fuchsia", |
| "//src/security/lib/scrutiny/testing", |
| "//third_party/rust_crates:tempfile", |
| ] |
| configs += [ ":test_config" ] |
| |
| non_rust_deps = [ "//src/lib/chunked-compression" ] |
| |
| sources = [ |
| "src/additional_boot_args.rs", |
| "src/component_model.rs", |
| "src/lib.rs", |
| "src/package.rs", |
| "src/package_reader.rs", |
| "src/package_test_utils.rs", |
| "src/package_types.rs", |
| "src/package_utils.rs", |
| "src/static_packages.rs", |
| "src/unified_collector.rs", |
| "src/zbi.rs", |
| ] |
| } |
| } |
| |
| # Build the fake product bundle for testing. |
| if (is_fuchsia) { |
| files = { |
| assembly_outdir = "$target_out_dir/assembly" |
| version = "$target_out_dir/version" |
| } |
| |
| generated_partitions_config("partitions") { |
| testonly = true |
| hw_revision = "test" |
| } |
| |
| generated_file("version") { |
| testonly = true |
| contents = "0.0.0.1" |
| outputs = [ files.version ] |
| } |
| |
| board_configuration("board_config") { |
| name = "test" |
| testonly = true |
| version = "fake_version" |
| partitions_config = ":partitions" |
| } |
| |
| product_assembly_configuration("assembly_config") { |
| testonly = true |
| platform = { |
| feature_set_level = "utility" |
| build_type = "eng" |
| storage = { |
| filesystems = { |
| image_name = "assembly" |
| } |
| } |
| } |
| version = build_info_version |
| } |
| |
| assembled_system("assembly") { |
| testonly = true |
| product_assembly_config_label = ":assembly_config" |
| board_config_label = ":board_config" |
| generate_fxfs = true |
| } |
| |
| product_bundle("product_bundle") { |
| testonly = true |
| name = "scrutiny" |
| deps = [ |
| ":assembly", |
| ":version", |
| ] |
| system_a = files.assembly_outdir |
| update = { |
| version_file = files.version |
| epoch = "1" |
| } |
| } |
| } |
| |
| group("tests") { |
| testonly = true |
| public_deps = [ ":collector_test($host_toolchain)" ] |
| } |