| # Copyright 2019 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/components.gni") | |
| import("//build/dist/component_manifest_resources.gni") | |
| import("//build/test.gni") | |
| import("//src/storage/fshost/fshost.gni") | |
| import("//tools/cmc/build/cmc.gni") | |
| group("tests") { | |
| testonly = true | |
| deps = [ ":fshost-tests" ] | |
| } | |
| source_set("headers") { | |
| sources = [ "constants.h" ] | |
| } | |
| source_set("admin-client") { | |
| sources = [ | |
| "admin-client.cc", | |
| "admin-client.h", | |
| ] | |
| public_deps = [ | |
| "//sdk/fidl/fuchsia.fshost:fuchsia.fshost_cpp_wire", | |
| "//sdk/fidl/fuchsia.sys2:fuchsia.sys2_cpp_wire", | |
| "//sdk/lib/component/incoming/cpp", | |
| "//zircon/system/ulib/zx", | |
| ] | |
| } | |
| source_set("launcher") { | |
| visibility = [ ":*" ] | |
| sources = [ "fdio.cc" ] | |
| deps = [ | |
| "//sdk/lib/fdio", | |
| "//sdk/lib/fidl", | |
| "//sdk/lib/syslog/cpp", | |
| "//zircon/system/ulib/fbl", | |
| "//zircon/system/ulib/zx", | |
| ] | |
| } | |
| source_set("fshost-registry") { | |
| sources = [ | |
| "admin-server.cc", | |
| "fs-manager.cc", | |
| "fshost-boot-args.cc", | |
| "lifecycle.cc", | |
| ] | |
| public_deps = [ | |
| ":config", | |
| ":headers", | |
| ":inspect", | |
| ":launcher", | |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_cpp_wire", | |
| "//sdk/fidl/fuchsia.device:fuchsia.device_cpp_wire", | |
| "//sdk/fidl/fuchsia.feedback:fuchsia.feedback_cpp_wire", | |
| "//sdk/fidl/fuchsia.fshost:fuchsia.fshost_cpp_wire", | |
| "//sdk/fidl/fuchsia.hardware.block.partition:fuchsia.hardware.block.partition_cpp_wire", | |
| "//sdk/fidl/fuchsia.process.lifecycle:fuchsia.process.lifecycle_cpp_wire", | |
| "//sdk/lib/component/incoming/cpp", | |
| "//sdk/lib/fit", | |
| "//sdk/lib/vfs/cpp", | |
| "//src/lib/loader_service", | |
| "//src/lib/storage/fs_management", | |
| "//src/lib/storage/vfs/cpp", | |
| "//src/storage/fidl/fuchsia.fs.startup:fuchsia.fs.startup_cpp_wire", | |
| "//src/storage/fxfs:fuchsia.fxfs_cpp_wire", | |
| "//zircon/system/ulib/async-loop:async-loop-cpp", | |
| "//zircon/system/ulib/async-loop:async-loop-default", | |
| "//zircon/system/ulib/fdio-caller", | |
| "//zircon/system/ulib/zx", | |
| ] | |
| deps = [ | |
| "//sdk/lib/fdio", | |
| "//src/lib/files", | |
| "//src/sys/lib/stdout-to-debuglog/cpp", | |
| "//zircon/system/ulib/fbl", | |
| "//zircon/system/ulib/fidl-async:fidl-async-cpp", | |
| "//zircon/system/ulib/fzl", | |
| "//zircon/third_party/ulib/safemath", | |
| ] | |
| } | |
| source_set("inspect") { | |
| sources = [ | |
| "inspect-manager.cc", | |
| "inspect-manager.h", | |
| ] | |
| public_deps = [ | |
| "//sdk/lib/fdio", | |
| "//sdk/lib/sys/inspect/cpp", | |
| "//sdk/lib/syslog/cpp", | |
| "//src/lib/fsl", | |
| "//src/lib/storage/fs_management", | |
| "//src/lib/storage/vfs/cpp", | |
| "//zircon/system/ulib/fbl", | |
| ] | |
| } | |
| source_set("block-watcher") { | |
| configs += [ "//build/config:all_source" ] | |
| sources = [ | |
| "block-device-manager.cc", | |
| "block-device.cc", | |
| "block-watcher.cc", | |
| "copier.cc", | |
| "encrypted-volume.cc", | |
| "filesystem-mounter.cc", | |
| "fxfs.cc", | |
| "nand-device.cc", | |
| "storage-wiper.cc", | |
| "utils.cc", | |
| "watcher.cc", | |
| ] | |
| public_deps = [ | |
| ":config", | |
| ":fshost-registry", | |
| ":launcher", | |
| "//sdk/fidl/fuchsia.fshost:fuchsia.fshost_cpp_wire", | |
| "//sdk/fidl/fuchsia.hardware.block.partition:fuchsia.hardware.block.partition_cpp_wire", | |
| "//sdk/lib/fit", | |
| "//sdk/lib/fit-promise", | |
| "//src/lib/storage/vfs/cpp", | |
| "//src/storage/blobfs", | |
| "//src/storage/fidl/fuchsia.fs.startup:fuchsia.fs.startup_cpp_wire", | |
| "//src/storage/fxfs:fuchsia.fxfs_cpp_wire", | |
| "//zircon/system/ulib/async-loop:async-loop-cpp", | |
| "//zircon/system/ulib/async-loop:async-loop-default", | |
| "//zircon/system/ulib/fdio-caller", | |
| "//zircon/system/ulib/zx", | |
| ] | |
| deps = [ | |
| ":headers", | |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_cpp_wire", | |
| "//sdk/fidl/fuchsia.device:fuchsia.device_cpp_wire", | |
| "//sdk/fidl/fuchsia.hardware.block.encrypted:fuchsia.hardware.block.encrypted_cpp_wire", | |
| "//sdk/fidl/fuchsia.hardware.block.verified:fuchsia.hardware.block.verified_cpp_wire", | |
| "//sdk/fidl/fuchsia.hardware.block.volume:fuchsia.hardware.block.volume_cpp_wire", | |
| "//sdk/fidl/fuchsia.io:fuchsia.io_cpp_wire", | |
| "//sdk/lib/component/incoming/cpp", | |
| "//sdk/lib/fdio", | |
| "//sdk/lib/fidl", | |
| "//sdk/lib/fit", | |
| "//src/devices/block/drivers/block-verity:verified-volume-client", | |
| "//src/lib/digest", | |
| "//src/lib/files", | |
| "//src/lib/loader_service", | |
| "//src/lib/storage/fs_management", | |
| "//src/lib/storage/key-bag/c", | |
| "//src/lib/storage/ramdevice_client/cpp", | |
| "//src/lib/storage/vfs/cpp", | |
| "//src/lib/uuid:uuid", | |
| "//src/security/lib/fcrypto", | |
| "//src/security/lib/kms-stateless", | |
| "//src/security/lib/zxcrypt:zxcrypt-client", | |
| "//src/storage/f2fs", | |
| "//src/storage/gpt", | |
| "//src/storage/minfs", | |
| "//src/sys/pkg/fidl/fuchsia.update.verify:fuchsia.update.verify_cpp_wire", | |
| "//zircon/system/ulib/explicit-memory", | |
| "//zircon/system/ulib/fbl", | |
| "//zircon/system/ulib/fidl-async:fidl-async-cpp", | |
| "//zircon/system/ulib/trace", | |
| "//zircon/system/ulib/trace-engine", | |
| "//zircon/system/ulib/zx", | |
| ] | |
| } | |
| source_set("config") { | |
| sources = [ "config.cc" ] | |
| public_deps = [ | |
| ":fshost_config", | |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_cpp_wire", | |
| "//zircon/system/ulib/fbl", | |
| ] | |
| } | |
| executable("fshost") { | |
| if (is_fuchsia) { | |
| configs += [ "//build/config:all_source" ] | |
| } | |
| if (is_fuchsia) { | |
| fdio_config = [ "//build/config/fuchsia:fdio_config" ] | |
| if (configs + fdio_config - fdio_config != configs) { | |
| configs -= fdio_config | |
| } | |
| } | |
| sources = [ "main.cc" ] | |
| deps = [ | |
| ":block-watcher", | |
| ":config", | |
| ":fshost-registry", | |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_cpp_wire", | |
| "//sdk/fidl/fuchsia.fshost:fuchsia.fshost_cpp_wire", | |
| "//sdk/fidl/fuchsia.io:fuchsia.io_cpp_wire", | |
| "//src/lib/storage/fs_management", | |
| "//src/lib/storage/ramdevice_client/cpp", | |
| "//third_party/zstd", | |
| "//zircon/system/ulib/fidl-async:fidl-async-cpp", | |
| ] | |
| } | |
| test("fshost_test") { | |
| sources = [ | |
| "fshost-boot-args-test.cc", | |
| "fshost-test.cc", | |
| ] | |
| deps = [ | |
| ":block-watcher", | |
| ":config", | |
| ":fshost-registry", | |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_cpp_wire", | |
| "//sdk/fidl/fuchsia.io:fuchsia.io_cpp_wire", | |
| "//sdk/lib/fit-promise", | |
| "//src/lib/fxl/test:gtest_main", | |
| "//zircon/system/ulib/fidl-async", | |
| "//zircon/system/ulib/fidl-async:fidl-async-cpp", | |
| "//zircon/system/ulib/mock-boot-arguments", | |
| ] | |
| } | |
| # Include this target from a product config if you want to allow authoring | |
| # factory partition contents in mutable mode and prevent opening block-verity | |
| # volumes in verified read mode. | |
| generated_resource("allow-authoring-factory") { | |
| outputs = [ "config/allow-authoring-factory" ] | |
| contents = "yes" | |
| # We should never allow authoring factory from a production, user-facing build. | |
| deps = [ "//build/validate:non_production_tag" ] | |
| } | |
| fuchsia_unittest_component("fshost-test") { | |
| deps = [ ":fshost_test" ] | |
| } | |
| test("fshost_inspect_test") { | |
| sources = [ "inspect-manager-test.cc" ] | |
| deps = [ | |
| ":inspect", | |
| "//src/storage/memfs:cpp", | |
| "//zircon/system/ulib/async", | |
| "//zircon/system/ulib/async-loop:async-loop-cpp", | |
| "//zircon/system/ulib/async-loop:async-loop-default", | |
| "//zircon/system/ulib/inspect", | |
| "//zircon/system/ulib/zxtest", | |
| ] | |
| } | |
| fuchsia_unittest_component("fshost-inspect-test") { | |
| deps = [ ":fshost_inspect_test" ] | |
| } | |
| test("copier_test") { | |
| sources = [ | |
| "copier.cc", | |
| "copier_test.cc", | |
| ] | |
| deps = [ | |
| ":headers", | |
| "//sdk/lib/syslog/cpp:cpp-macros", | |
| "//src/lib/files", | |
| "//src/lib/fxl/test:gtest_main", | |
| "//src/lib/uuid:uuid", | |
| "//src/sys/test_runners:tmp_storage", | |
| "//zircon/system/ulib/fbl", | |
| "//zircon/system/ulib/zx", | |
| ] | |
| } | |
| fuchsia_unittest_component("copier-test") { | |
| deps = [ ":copier_test" ] | |
| } | |
| # Generates a test component for the fshost integration tests. | |
| # | |
| # test_component_name (required) | |
| # [string] The name of the test component, e.g. "test-fshost". deps should include the target | |
| # that builds the component. | |
| # | |
| # test_data_filesystem_format | |
| # [string] One of "fxfs", "minfs", or "f2fs". | |
| # | |
| # deps | |
| template("fshost_integration_test") { | |
| _test_bin = "${target_name}-bin" | |
| test(_test_bin) { | |
| sources = [ | |
| "admin-server-test.cc", | |
| "block-device-manager-test.cc", | |
| "block-device-test.cc", | |
| "block-watcher-test.cc", | |
| "filesystem-mounter-test.cc", | |
| "migration-test.cc", | |
| "recovery-test.cc", | |
| "testing/fshost_integration_test.cc", | |
| "testing/fshost_integration_test.h", | |
| "testing/mock-block-device.h", | |
| ] | |
| deps = [ | |
| ":block-watcher", | |
| ":config", | |
| ":headers", | |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_cpp_wire", | |
| "//sdk/fidl/fuchsia.component:fuchsia.component_cpp_wire", | |
| "//sdk/fidl/fuchsia.device:fuchsia.device_cpp_wire", | |
| "//sdk/fidl/fuchsia.hardware.block.volume:fuchsia.hardware.block.volume_cpp_wire", | |
| "//sdk/fidl/fuchsia.io:fuchsia.io_cpp_wire_testing", | |
| "//sdk/lib/component/incoming/cpp", | |
| "//src/developer/forensics/public/fakes:fuchsia.feedback.testing_cpp_wire", | |
| "//src/lib/files", | |
| "//src/lib/fxl/test:gtest_main", | |
| "//src/lib/storage/block_client/cpp", | |
| "//src/lib/storage/fs_management", | |
| "//src/lib/storage/ramdevice_client/cpp", | |
| "//src/lib/testing/predicates", | |
| "//src/storage/blobfs", | |
| "//src/storage/lib/utils:topological_path", | |
| "//src/storage/minfs", | |
| "//src/storage/testing:storage_driver_test_support", | |
| "//src/sys/pkg/fidl/fuchsia.update.verify:fuchsia.update.verify_cpp_wire", | |
| "//third_party/googletest:gmock", | |
| "//zircon/system/ulib/fidl-async", | |
| ] | |
| data_deps = [ | |
| "//src/storage/bin/mount", | |
| "//src/storage/bin/umount", | |
| ] | |
| defines = [ | |
| "DATA_FILESYSTEM_FORMAT=\"${invoker.test_data_filesystem_format}\"", | |
| "USE_DISK_BASED_MINFS_MIGRATION=false", | |
| "TEST_COMPONENT_NAME=\"${invoker.test_component_name}\"", | |
| ] | |
| } | |
| _shard_target = "${target_name}-shard" | |
| generated_file(_shard_target) { | |
| testonly = true | |
| contents = { | |
| program = { | |
| binary = "test/${_test_bin}" | |
| } | |
| } | |
| outputs = [ "${target_out_dir}/${_shard_target}.json" ] | |
| output_conversion = "json" | |
| visibility = [ ":*" ] | |
| } | |
| _shard = get_target_outputs(":$_shard_target") | |
| _shard = _shard[0] | |
| _manifest_target = "${target_name}-manifest.cml" | |
| cmc_merge("$_manifest_target") { | |
| testonly = true | |
| sources = [ | |
| "testing/meta/fshost_integration_test.cml", | |
| _shard, | |
| ] | |
| deps = [ ":$_shard_target" ] | |
| } | |
| _manifest = get_target_outputs(":$_manifest_target") | |
| _manifest = _manifest[0] | |
| fuchsia_component(target_name) { | |
| testonly = true | |
| manifest = _manifest | |
| deps = [ | |
| ":$_manifest_target", | |
| ":$_test_bin", | |
| "//src/storage/testing:storage_driver_test_realm", | |
| ] | |
| if (defined(invoker.deps)) { | |
| deps += invoker.deps | |
| } | |
| } | |
| } | |
| # Generates an integration test with a custom fshost | |
| # | |
| # options - specifies the options for the custom fshost. See fshost.gni | |
| template("fshost_integration_test_with_custom_fshost") { | |
| test_component_name = "$target_name.fshost" | |
| fshost_component_and_config(test_component_name) { | |
| testonly = true | |
| forward_variables_from(invoker, [ "options" ]) | |
| } | |
| fshost_integration_test(target_name) { | |
| _options = invoker.options | |
| test_data_filesystem_format = _options.data_filesystem_format | |
| deps = [ ":$test_component_name" ] | |
| } | |
| } | |
| fshost_integration_test("fshost-integration-test") { | |
| test_component_name = "test-fshost" | |
| test_data_filesystem_format = "minfs" | |
| deps = [ "//src/storage/fshost/testing:test-fshost" ] | |
| } | |
| fshost_integration_test("fshost-fxfs-integration-test") { | |
| test_component_name = "test-fshost-fxfs" | |
| test_data_filesystem_format = "fxfs" | |
| deps = [ "//src/storage/fshost/testing:test-fshost-fxfs" ] | |
| } | |
| fshost_integration_test_with_custom_fshost( | |
| "fshost-fxfs-legacy-crypto-integration-test") { | |
| options = default_integration_test_options | |
| options.data_filesystem_format = "fxfs" | |
| options.use_native_fxfs_crypto = false | |
| } | |
| fshost_integration_test_with_custom_fshost("fshost-f2fs-integration-test") { | |
| options = default_integration_test_options | |
| options.data_filesystem_format = "f2fs" | |
| } | |
| test("disk-migration-test") { | |
| # Note that these mirror the config variables set in | |
| # "//src/storage/fshost/testing:test-fshost-fxfs-disk-migration" but we don't | |
| # seem able to access those from the test, nor paramaterize this target | |
| # per component, so they're hard coded here. | |
| data_filesystem_format = "fxfs" | |
| use_disk_based_minfs_migration = true | |
| sources = [ | |
| "disk-migration-test.cc", | |
| "testing/fshost_integration_test.cc", | |
| "testing/fshost_integration_test.h", | |
| ] | |
| deps = [ | |
| ":block-watcher", | |
| ":config", | |
| ":fshost_config", | |
| ":headers", | |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_cpp_wire", | |
| "//sdk/fidl/fuchsia.component:fuchsia.component_cpp_wire", | |
| "//sdk/fidl/fuchsia.device:fuchsia.device_cpp_wire", | |
| "//sdk/fidl/fuchsia.hardware.block.volume:fuchsia.hardware.block.volume_cpp_wire", | |
| "//sdk/fidl/fuchsia.io:fuchsia.io_cpp_wire_testing", | |
| "//sdk/lib/component/incoming/cpp", | |
| "//src/lib/fxl/test:gtest_main", | |
| "//src/lib/storage/fs_management", | |
| "//src/lib/storage/ramdevice_client/cpp", | |
| "//src/storage/lib/utils:topological_path", | |
| "//src/storage/minfs", | |
| "//src/storage/testing:storage_driver_test_support", | |
| "//zircon/system/ulib/fidl-async", | |
| ] | |
| defines = [ | |
| "DATA_FILESYSTEM_FORMAT=\"$data_filesystem_format\"", | |
| "USE_DISK_BASED_MINFS_MIGRATION=$use_disk_based_minfs_migration", | |
| "TEST_COMPONENT_NAME=\"test-fshost-fxfs-disk-migration\"", | |
| ] | |
| } | |
| fuchsia_component("fshost-disk-migration-test") { | |
| testonly = true | |
| manifest = "meta/disk_migration_test.cml" | |
| deps = [ | |
| ":disk-migration-test", | |
| "//src/storage/fshost/testing:test-fshost-fxfs-disk-migration", | |
| "//src/storage/testing:storage_driver_test_realm", | |
| ] | |
| } | |
| fuchsia_test_package("fshost-tests") { | |
| test_specs = { | |
| log_settings = { | |
| max_severity = "ERROR" | |
| } | |
| } | |
| test_components = [ | |
| ":fshost-fxfs-integration-test", | |
| ":fshost-fxfs-legacy-crypto-integration-test", | |
| ":fshost-f2fs-integration-test", | |
| ":fshost-integration-test", | |
| ":fshost-test", | |
| ":fshost-inspect-test", | |
| ":copier-test", | |
| ":fshost-disk-migration-test", | |
| ] | |
| deps = [ | |
| "//sdk/fidl/fuchsia.io:fuchsia.io_cpp_wire_testing", | |
| "//src/developer/forensics/public/fakes:fake_crash_reporter", | |
| "//src/storage/bin/blobfs", | |
| "//src/storage/blobfs:decompressor-sandbox", | |
| ] | |
| } | |
| # This is only used for generating the structured configuration library, as the | |
| # main cml is produced by assembly. | |
| fshost_cml("fshost_for_config_lib.cml") { | |
| options = { | |
| bootfs_only = true | |
| } | |
| } | |
| fuchsia_component_manifest("fshost_manifest_for_config_lib") { | |
| component_name = "fshost" | |
| manifest = get_target_outputs(":fshost_for_config_lib.cml") | |
| manifest = manifest[0] | |
| deps = [ ":fshost_for_config_lib.cml" ] | |
| } | |
| fuchsia_structured_config_cpp_elf_lib("fshost_config") { | |
| cm_label = ":fshost_manifest_for_config_lib" | |
| } | |
| fuchsia_structured_config_rust_lib("fshost_config_rust") { | |
| name = "fshost_config" | |
| cm_label = ":fshost_manifest_for_config_lib" | |
| } |