| # 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/assembly/board_configuration.gni") |
| import("//build/assembly/generated_partitions_config.gni") |
| import("//build/assembly/product_assembly_configuration.gni") |
| import("//build/assembly/update_package.gni") |
| import("//build/components.gni") |
| import("//build/images/args.gni") |
| import("//build/product.gni") |
| import("//build/python/python_binary.gni") |
| import("//build/sdk/product_bundle.gni") |
| import("//build/testing/host_test.gni") |
| import("//build/testing/host_test_data.gni") |
| import("//src/developer/ffx/config.gni") |
| import("//src/storage/fshost/generated_fshost_config.gni") |
| import("//src/sys/core/build/core.gni") |
| import("//src/sys/core/build/core_shard.gni") |
| import("//zircon/kernel/phys/qemu.gni") |
| |
| if (is_fuchsia) { |
| fuchsia_component("component_with_broken_use") { |
| testonly = true |
| manifest = "meta/component_with_broken_use.cml" |
| |
| # We don't intend to run this component, just make its manifest visible to scrutiny. |
| check_references = false |
| } |
| |
| fuchsia_component("component_with_collection") { |
| testonly = true |
| manifest = "meta/component_with_collection.cml" |
| |
| # We don't intend to run this component, just make its manifest visible to scrutiny. |
| check_references = false |
| } |
| |
| fuchsia_package("package") { |
| testonly = true |
| package_name = "package_for_scrutiny_testing" |
| deps = [ |
| ":component_with_broken_use", |
| ":component_with_collection", |
| ] |
| } |
| |
| core_shard("core_shard") { |
| shard_file = "meta/core_shard.cml" |
| } |
| |
| core_realm_definition("core_realm") { |
| deps = [ ":core_shard" ] |
| } |
| |
| files = { |
| partitions_config = "$target_out_dir/partitions_config.json" |
| |
| outdir = target_out_dir + "/assembly" |
| packages_json = "${outdir}/packages.json" |
| images_json = "${outdir}/images.json" |
| |
| blobfs = "${outdir}/blob.blk" |
| zbi = "${outdir}/assembly.zbi" |
| fvm = "${outdir}/fvm.blk" |
| fvm_sparse = "${outdir}/fvm.sparse.blk" |
| |
| qemu_kernel = qemu_boot_shim.path |
| |
| product_bundle = target_out_dir + "/product_bundle" |
| } |
| |
| board_configuration("board_config") { |
| name = "test" |
| filesystems = { |
| fvm = { |
| sparse_output = { |
| } |
| } |
| } |
| } |
| |
| product_assembly_configuration("product_assembly_config") { |
| platform = { |
| build_type = "user" |
| feature_set_level = "utility" |
| storage = { |
| configure_fshost = true |
| filesystems = { |
| image_name = "assembly" |
| volume = { |
| fvm = { |
| data = { |
| } |
| blob = { |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| assembled_system("assembly") { |
| testonly = true |
| generate_fvm = true |
| generate_fvm_fastboot = false |
| generate_vbmeta = false |
| product_assembly_config_label = ":product_assembly_config" |
| board_config_label = ":board_config" |
| |
| # Needed for scrutiny to find root.cm and other component config. |
| bootfs_labels = [ "//build/input:bootfs" ] |
| base_packages = [ ":package" ] |
| |
| generate_image_metadata = false |
| |
| # Needed for scrutiny to find things for the component model. |
| core_realm_definition = ":core_realm" |
| } |
| |
| generated_partitions_config("partitions_config") { |
| testonly = true |
| output_path = files.partitions_config |
| hw_revision = board_name |
| } |
| |
| update_package("update") { |
| testonly = true |
| deps = [ |
| ":assembly", |
| ":partitions_config", |
| "//build/info:build_info_files", |
| ] |
| partitions = files.partitions_config |
| system_a = files.images_json |
| version_file = build_info_files.version |
| board_name = "fake_board" |
| epoch = "1" |
| } |
| |
| product_bundle("product_bundle") { |
| testonly = true |
| name = "scrutiny-failed-route-verify-test" |
| deps = [ |
| ":assembly", |
| ":partitions_config", |
| "//build/info:build_info_files", |
| ] |
| |
| update = { |
| version_file = build_info_files.version |
| epoch = "1" |
| } |
| |
| partitions = files.partitions_config |
| system_a = files.images_json |
| |
| # Create lists of the files that are referenced by the assembly manifests. |
| system_a_contents = [ |
| files.blobfs, |
| files.fvm, |
| files.fvm_sparse, |
| files.qemu_kernel, |
| files.zbi, |
| ] |
| } |
| } |
| |
| if (is_host) { |
| group("host_tests") { |
| testonly = true |
| |
| # TODO(https://fxbug.dev/42076896): Support Fxblob in scrutiny |
| if (fxfs_blob) { |
| deps = [] |
| } else { |
| deps = [ ":test_route_verification" ] |
| } |
| } |
| |
| labels = { |
| image_assembler = ":assembly.image_assembler($target_toolchain)" |
| product_bundle = ":product_bundle($target_toolchain)" |
| update_package = ":update($target_toolchain)" |
| } |
| |
| files = { |
| ffx = "$ffx_test_host_tools_out_dir/ffx-scrutiny" |
| |
| component_tree_config = "//src/security/lib/scrutiny/tests/route_verification/component_tree_config.json5" |
| |
| product_bundle_target_out_dir = |
| get_label_info(labels.product_bundle, "target_out_dir") |
| product_bundle_target_name = get_label_info(labels.product_bundle, "name") |
| |
| product_bundle_dir = |
| "$product_bundle_target_out_dir/$product_bundle_target_name" |
| } |
| |
| python_binary("test_route_verification_bin") { |
| enable_mypy = true |
| main_source = "test_route_verification.py" |
| } |
| |
| host_test_data("failed_route_verify_test_data") { |
| sources = get_target_outputs(":test_route_verification_bin") |
| sources += [ |
| files.product_bundle_dir, |
| files.component_tree_config, |
| ] |
| deps = [ |
| ":test_route_verification_bin", |
| labels.product_bundle, |
| ] |
| } |
| |
| test_route_verification_binary = |
| get_target_outputs(":test_route_verification_bin") |
| test_route_verification_binary = test_route_verification_binary[0] |
| |
| host_test("test_route_verification") { |
| binary_path = python_exe_src |
| |
| depfile = "$target_out_dir/test_route_verification.d" |
| args = [ |
| rebase_path(test_route_verification_binary, root_build_dir), |
| "--ffx-bin", |
| rebase_path(files.ffx, root_build_dir), |
| "--fail-protocol", |
| "fuchsia.foo.bar", |
| "--fail-moniker", |
| "core/component_with_broken_use", |
| "--fail-dynamic-moniker", |
| "core/component_with_collection/coll:component_with_broken_use", |
| "--success-protocol", |
| "fuchsia.logger.LogSink", |
| "--depfile", |
| rebase_path(depfile, root_build_dir), |
| "--product-bundle", |
| rebase_path(files.product_bundle_dir, root_build_dir), |
| "--component-tree-config", |
| rebase_path(files.component_tree_config, root_build_dir), |
| ] |
| depfile = [ depfile ] |
| |
| deps = [ |
| ":failed_route_verify_test_data", |
| "//build/python:interpreter", |
| "//src/developer/ffx/plugins/scrutiny:ffx_scrutiny_tool_test_data", |
| ] |
| } |
| } |