| # 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/generated_fshost_config.gni") |
| import("//tools/cmc/build/cmc.gni") |
| |
| group("tests") { |
| testonly = true |
| deps = [ ":fshost-tests" ] |
| } |
| |
| source_set("headers") { |
| sources = [ "constants.h" ] |
| } |
| |
| source_set("launcher") { |
| visibility = [ ":*" ] |
| sources = [ "fdio.cc" ] |
| deps = [ |
| "//sdk/lib/fdio", |
| "//sdk/lib/syslog/cpp", |
| "//zircon/system/ulib/fbl", |
| "//zircon/system/ulib/fidl", |
| "//zircon/system/ulib/zx", |
| ] |
| } |
| |
| source_set("fshost-registry") { |
| sources = [ |
| "admin-server.cc", |
| "fs-manager.cc", |
| "fshost-boot-args.cc", |
| "lifecycle.cc", |
| ] |
| public_deps = [ |
| ":config", |
| ":inspect", |
| ":launcher", |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_llcpp", |
| "//sdk/fidl/fuchsia.device:fuchsia.device_llcpp", |
| "//sdk/fidl/fuchsia.feedback:fuchsia.feedback_llcpp", |
| "//sdk/fidl/fuchsia.fshost:fuchsia.fshost_llcpp", |
| "//sdk/fidl/fuchsia.hardware.block.partition:fuchsia.hardware.block.partition_llcpp", |
| "//sdk/fidl/fuchsia.process.lifecycle:fuchsia.process.lifecycle_llcpp", |
| "//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_llcpp", |
| "//src/storage/fxfs:fuchsia.fxfs_llcpp", |
| "//src/storage/memfs:lib", |
| "//zircon/system/ulib/async-loop:async-loop-cpp", |
| "//zircon/system/ulib/async-loop:async-loop-default", |
| "//zircon/system/ulib/fdio-caller", |
| "//zircon/system/ulib/service:service-llcpp", |
| "//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", |
| ] |
| |
| # TODO(fxbug.dev/95833): This target uses the deprecated C bindings. |
| # Consider switching to the C++ bindings. See linked bug for details. |
| configs += [ "//build/c:fidl-deprecated-c-bindings" ] |
| } |
| |
| 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", |
| "nand-device.cc", |
| "watcher.cc", |
| ] |
| public_deps = [ |
| ":config", |
| ":fshost-registry", |
| ":launcher", |
| "//sdk/fidl/fuchsia.fshost:fuchsia.fshost_llcpp", |
| "//sdk/fidl/fuchsia.hardware.block.partition:fuchsia.hardware.block.partition_llcpp", |
| "//sdk/lib/fit", |
| "//sdk/lib/fit-promise", |
| "//src/lib/storage/vfs/cpp", |
| "//src/storage/blobfs", |
| "//src/storage/fidl/fuchsia.fs.startup:fuchsia.fs.startup_llcpp", |
| "//src/storage/fxfs:fuchsia.fxfs_llcpp", |
| "//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_c", |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_llcpp", |
| "//sdk/fidl/fuchsia.device:fuchsia.device_c", |
| "//sdk/fidl/fuchsia.device:fuchsia.device_llcpp", |
| "//sdk/fidl/fuchsia.hardware.block:fuchsia.hardware.block_c", |
| "//sdk/fidl/fuchsia.hardware.block.encrypted:fuchsia.hardware.block.encrypted_c", |
| "//sdk/fidl/fuchsia.hardware.block.encrypted:fuchsia.hardware.block.encrypted_llcpp", |
| "//sdk/fidl/fuchsia.hardware.block.partition:fuchsia.hardware.block.partition_c", |
| "//sdk/fidl/fuchsia.hardware.block.verified:fuchsia.hardware.block.verified_llcpp", |
| "//sdk/fidl/fuchsia.hardware.block.volume:fuchsia.hardware.block.volume_llcpp", |
| "//sdk/fidl/fuchsia.io:fuchsia.io_llcpp", |
| "//sdk/lib/fdio", |
| "//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/ramdevice_client/cpp", |
| "//src/lib/storage/vfs/cpp", |
| "//src/lib/uuid:uuid", |
| "//src/security/zxcrypt:zxcrypt-client", |
| "//src/storage/bin/minfs:minfs-component", |
| "//src/storage/gpt", |
| "//src/storage/minfs", |
| "//src/sys/pkg/fidl/fuchsia.update.verify:fuchsia.update.verify_llcpp", |
| "//zircon/system/ulib/fbl", |
| "//zircon/system/ulib/fidl", |
| "//zircon/system/ulib/fidl-async:fidl-async-cpp", |
| "//zircon/system/ulib/service:service-llcpp", |
| "//zircon/system/ulib/trace", |
| "//zircon/system/ulib/trace-engine", |
| "//zircon/system/ulib/zx", |
| ] |
| |
| if (extract_minfs_metadata_on_corruption) { |
| sources += [ "extract-metadata.cc" ] |
| public_deps += [ "//src/storage/extractor/cpp:disk_extractor" ] |
| } else { |
| sources += [ "extract-metadata-noop.cc" ] |
| } |
| |
| if (data_filesystem_format == "fxfs") { |
| deps += [ "//src/storage/fxfs:fxfs_component" ] |
| } else if (data_filesystem_format == "f2fs") { |
| deps += [ "//src/storage/bin/f2fs" ] |
| } |
| |
| # TODO(fxbug.dev/95833): This target uses the deprecated C bindings. |
| # Consider switching to the C++ bindings. See linked bug for details. |
| configs += [ "//build/c:fidl-deprecated-c-bindings" ] |
| } |
| |
| source_set("config") { |
| sources = [ "config.cc" ] |
| public_deps = [ |
| ":fshost_config", |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_llcpp", |
| "//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_c", |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_llcpp", |
| "//sdk/fidl/fuchsia.fshost:fuchsia.fshost_c", |
| "//sdk/fidl/fuchsia.fshost:fuchsia.fshost_llcpp", |
| "//sdk/fidl/fuchsia.io:fuchsia.io_llcpp", |
| "//sdk/fidl/fuchsia.ldsvc:fuchsia.ldsvc_c", |
| "//src/lib/storage/fs_management", |
| "//src/lib/storage/ramdevice_client/cpp", |
| "//third_party/zstd", |
| "//zircon/system/ulib/fidl-async:fidl-async-cpp", |
| ] |
| |
| if (data_filesystem_format == "fxfs") { |
| deps += [ "//src/storage/fxfs-crypt" ] |
| } |
| |
| # TODO(fxbug.dev/95833): This target uses the deprecated C bindings. |
| # Consider switching to the C++ bindings. See linked bug for details. |
| configs += [ "//build/c:fidl-deprecated-c-bindings" ] |
| } |
| |
| test("fshost_test") { |
| sources = [ |
| "fshost-boot-args-test.cc", |
| "fshost-test.cc", |
| ] |
| deps = [ |
| ":block-watcher", |
| ":config", |
| ":fshost-registry", |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_llcpp", |
| "//sdk/fidl/fuchsia.io:fuchsia.io_llcpp", |
| "//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", |
| ] |
| |
| # TODO(fxbug.dev/95833): This target uses the deprecated C bindings. |
| # Consider switching to the C++ bindings. See linked bug for details. |
| configs += [ "//build/c:fidl-deprecated-c-bindings" ] |
| } |
| |
| # 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 = [ |
| "//sdk/lib/syslog/cpp:cpp-macros", |
| "//src/lib/files", |
| "//src/lib/fxl/test:gtest_main", |
| "//src/sys/test_runners:tmp_storage", |
| "//zircon/system/ulib/fbl", |
| "//zircon/system/ulib/zxc", |
| ] |
| } |
| |
| 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". |
| # |
| # test_component_target (required) |
| # [string] The build target for the test component, e.g. "//src/storage/fshost/testing:test-fshost". |
| # |
| # data_filesystem_format |
| # [string] One of "fxfs", "minfs", or "f2fs". |
| template("fshost_integration_test") { |
| assert(defined(invoker.test_component_name) && |
| defined(invoker.test_component_target), |
| "Test component not specified") |
| _test_bin = "${target_name}-bin" |
| test(_test_bin) { |
| data_filesystem_format = invoker.data_filesystem_format |
| forward_variables_from(invoker, [ "test_component_name" ]) |
| 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_llcpp", |
| "//sdk/fidl/fuchsia.component:fuchsia.component_llcpp", |
| "//sdk/fidl/fuchsia.device:fuchsia.device_llcpp", |
| "//sdk/fidl/fuchsia.hardware.block.volume:fuchsia.hardware.block.volume_llcpp", |
| "//sdk/fidl/fuchsia.io:fuchsia.io_llcpp_testing", |
| "//src/developer/forensics/public/fakes:fuchsia.feedback.testing_llcpp", |
| "//src/lib/files", |
| "//src/lib/fxl/test:gtest_main", |
| "//src/lib/storage/fs_management", |
| "//src/lib/storage/ramdevice_client/cpp", |
| "//src/lib/testing/predicates", |
| "//src/storage/bin/minfs:minfs-component", |
| "//src/storage/blobfs", |
| "//src/storage/fxfs:fxfs_component", |
| "//src/storage/fxfs-crypt", |
| "//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_llcpp", |
| "//third_party/googletest:gmock", |
| "//zircon/system/ulib/fidl-async", |
| "//zircon/system/ulib/service:service-llcpp", |
| ] |
| data_deps = [ |
| "//src/storage/bin/mount", |
| "//src/storage/bin/umount", |
| ] |
| |
| # TODO(fxbug.dev/95833): This target uses the deprecated C bindings. |
| # Consider switching to the C++ bindings. See linked bug for details. |
| configs += [ "//build/c:fidl-deprecated-c-bindings" ] |
| defines = [ |
| "DATA_FILESYSTEM_FORMAT=\"$data_filesystem_format\"", |
| "TEST_COMPONENT_NAME=\"$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 |
| forward_variables_from(invoker, [ "test_component_target" ]) |
| manifest = _manifest |
| deps = [ |
| ":$_manifest_target", |
| ":$_test_bin", |
| "//src/storage/testing:storage_driver_test_realm", |
| test_component_target, |
| ] |
| } |
| } |
| |
| fshost_integration_test("fshost-integration-test") { |
| test_component_name = "test-fshost" |
| test_component_target = "//src/storage/fshost/testing:test-fshost" |
| |
| # Ideally these would come from the configuration of "test_component_target". |
| data_filesystem_format = "minfs" |
| } |
| |
| fshost_integration_test("fshost-fxfs-integration-test") { |
| test_component_name = "test-fshost-fxfs" |
| test_component_target = "//src/storage/fshost/testing:test-fshost-fxfs" |
| |
| # Ideally these would come from the configuration of "test_component_target". |
| data_filesystem_format = "fxfs" |
| } |
| |
| fuchsia_test_package("fshost-tests") { |
| test_specs = { |
| log_settings = { |
| max_severity = "ERROR" |
| } |
| } |
| test_components = [ |
| ":fshost-fxfs-integration-test", |
| ":fshost-integration-test", |
| ":fshost-test", |
| ":fshost-inspect-test", |
| ":copier-test", |
| ] |
| deps = [ |
| "//sdk/fidl/fuchsia.io:fuchsia.io_llcpp_testing", |
| "//src/developer/forensics/public/fakes:fake_crash_reporter", |
| "//src/storage/bin/blobfs", |
| "//src/storage/bin/minfs", |
| "//src/storage/blobfs:decompressor-sandbox", |
| ] |
| } |
| |
| cmc_merge("fshost.cml") { |
| sources = [ |
| "meta/base_fshost.cml", |
| "meta/config.cml", |
| "meta/cpp_fshost.cml", |
| "meta/real_fshost.cml", |
| ] |
| if (!bootfs_only) { |
| if (data_filesystem_format == "fxfs") { |
| sources += [ "meta/fxfs_fshost.cml" ] |
| } else if (data_filesystem_format == "f2fs") { |
| sources += [ "meta/f2fs_fshost.cml" ] |
| } else { |
| sources += [ "meta/minfs_fshost.cml" ] |
| } |
| sources += [ "meta/core_fshost.cml" ] |
| } |
| } |
| |
| fuchsia_component_manifest("fshost_manifest") { |
| component_name = "fshost" |
| manifest = get_target_outputs(":fshost.cml") |
| manifest = manifest[0] |
| deps = [ ":fshost.cml" ] |
| } |
| |
| fuchsia_structured_config_cpp_elf_lib("fshost_config") { |
| cm_label = ":fshost_manifest" |
| } |
| |
| group("bootfs") { |
| deps = [ |
| ":fshost", |
| ":fshost_manifest", |
| ] |
| } |