| # 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/components.gni") |
| import("//build/fuzz.gni") |
| import("//build/rust/rustc_binary.gni") |
| import("//build/rust/rustc_fuzzer.gni") |
| import("//build/rust/rustc_library.gni") |
| import("//src/storage/fs_test/suite.gni") |
| |
| fatfs_deps = [ |
| "//sdk/fidl/fuchsia.fs:fuchsia.fs_rust", |
| "//sdk/fidl/fuchsia.io:fuchsia.io_rust", |
| "//src/lib/fidl/rust/fidl", |
| "//src/lib/fuchsia-async", |
| "//src/lib/zircon/rust:fuchsia-zircon", |
| "//src/storage/lib/block_client/rust:remote-block-device", |
| "//src/storage/lib/vfs/rust:vfs", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:chrono", |
| "//third_party/rust_crates:fatfs", |
| "//third_party/rust_crates:futures", |
| "//third_party/rust_crates:libc", |
| "//third_party/rust_crates:scopeguard", |
| ] |
| |
| fatfs_sources = [ |
| "src/directory.rs", |
| "src/file.rs", |
| "src/filesystem.rs", |
| "src/lib.rs", |
| "src/node.rs", |
| "src/refs.rs", |
| "src/types.rs", |
| "src/util.rs", |
| ] |
| |
| rustc_library("lib") { |
| edition = "2021" |
| with_unit_tests = true |
| name = "fuchsia_fatfs" |
| |
| deps = fatfs_deps |
| test_deps = [ |
| "//src/lib/fuchsia", |
| "//third_party/rust_crates:assert_matches", |
| "//third_party/rust_crates:futures", |
| ] |
| sources = fatfs_sources |
| } |
| |
| fuchsia_component("fuchsia-fatfs-test") { |
| testonly = true |
| deps = [ ":lib_test" ] |
| manifest = "meta/fuchsia_fatfs_lib_test.cml" |
| } |
| |
| fuchsia_test_package("fuchsia-fatfs-tests") { |
| test_components = [ ":fuchsia-fatfs-test" ] |
| } |
| |
| rustc_fuzzer("fat-fuzzer") { |
| edition = "2021" |
| rustfunction = "fuzz_fatfs" |
| |
| sources = [ "src/fuzzer.rs" ] + fatfs_sources |
| deps = fatfs_deps + [ |
| "//src/lib/fuzzing/rust:fuzz", |
| "//third_party/rust_crates:futures", |
| ] |
| } |
| |
| fuchsia_fuzzer_component("fat-fuzzer-component") { |
| manifest = "meta/fat-fuzzer.cml" |
| deps = [ |
| ":fat-fuzzer", |
| "corpus", |
| ] |
| } |
| |
| fuchsia_fuzzer_package("fuchsia-fatfs-fuzzer") { |
| rust_fuzzer_components = [ ":fat-fuzzer-component" ] |
| } |
| |
| rustc_binary("fatfs") { |
| edition = "2021" |
| |
| deps = [ |
| ":lib", |
| "//sdk/fidl/fuchsia.fs:fuchsia.fs_rust", |
| "//sdk/fidl/fuchsia.hardware.block:fuchsia.hardware.block_rust", |
| "//sdk/fidl/fuchsia.io:fuchsia.io_rust", |
| "//sdk/fidl/fuchsia.process.lifecycle:fuchsia.process.lifecycle_rust", |
| "//src/lib/fidl/rust/fidl", |
| "//src/lib/fuchsia", |
| "//src/lib/fuchsia-async", |
| "//src/lib/fuchsia-component", |
| "//src/lib/fuchsia-runtime", |
| "//src/lib/zircon/rust:fuchsia-zircon", |
| "//src/storage/block_adapter:block_adapter_lib", |
| "//src/storage/fidl/fuchsia.fs.startup:fuchsia.fs.startup_rust", |
| "//src/storage/lib/block_client/rust:remote-block-device", |
| "//src/storage/lib/vfs/rust:vfs", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:futures", |
| "//third_party/rust_crates:tracing", |
| ] |
| |
| sources = [ |
| "src/component.rs", |
| "src/main.rs", |
| ] |
| } |
| |
| fuchsia_package("fuchsia-fatfs") { |
| deps = [ "//src/storage/fuchsia-fatfs/mounter:fatfs-mounter" ] |
| } |
| |
| fuchsia_shell_package("fatfs-bin") { |
| deps = [ ":fatfs" ] |
| } |
| |
| fuchsia_component("fatfs-component") { |
| component_name = "fatfs" |
| manifest = "meta/fatfs.cml" |
| deps = [ |
| ":fatfs", |
| "//zircon/third_party/uapp/fsck-msdosfs", |
| "//zircon/third_party/uapp/mkfs-msdosfs", |
| ] |
| } |
| |
| # FAT has different filename rules compared to other filesystems, so we substitute the |
| # filename tests in the test suite with a different set. |
| test("fat_filename_tests") { |
| sources = [ "filename_tests.cc" ] |
| deps = [ |
| "//src/lib/fxl/test:gtest_main", |
| "//src/storage/fs_test", |
| ] |
| } |
| |
| storage_driver_test_realm_v2_component("fatfs-fat-filename-tests") { |
| deps = [ |
| ":fat_filename_tests", |
| ":test_fatfs_component_manifest_shard", |
| ] |
| } |
| |
| expect_includes("test_fatfs_component_manifest_shard") { |
| testonly = true |
| includes = [ "meta/test_fatfs.shard.cml" ] |
| } |
| |
| fs_test_suite("fatfs") { |
| deps = [ ":fatfs-component" ] |
| component_deps = [ ":test_fatfs_component_manifest_shard" ] |
| config = { |
| disk_format = 4 |
| is_case_sensitive = false |
| is_journaled = false |
| timestamp_granularity = 2000000000 |
| supports_hard_links = false |
| supports_resize = false |
| supports_sparse_files = false |
| max_file_size = 4294967295 |
| is_slow = true |
| sectors_per_cluster = 2 |
| } |
| |
| omit_components = [ |
| ":fatfs-filename-tests", |
| ":fatfs-query-filesystem-tests", |
| ] |
| extra_components = [ ":fatfs-fat-filename-tests" ] |
| |
| # TODO(https://fxbug.dev/297201368): Remove when these tests pass on RISC-V. |
| if (current_cpu == "riscv64") { |
| omit_components += [ |
| ":fatfs-full-tests", |
| ":fatfs-attr-tests", |
| ] |
| } |
| } |
| |
| slow_fs_test_suite("fatfs") { |
| deps = [ |
| ":fatfs-component", |
| ":fatfs_fs_test_config", |
| "//src/storage/fuchsia-fatfs:fatfs", |
| ] |
| component_deps = [ ":test_fatfs_component_manifest_shard" ] |
| |
| # TODO(b/297201368): These tests are disabled in the regular test suite above due to timeouts. |
| if (current_cpu == "riscv64") { |
| extra_components = [ |
| ":fatfs-full-tests", |
| ":fatfs-attr-tests", |
| ] |
| } |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":fatfs-fs-tests", |
| ":fatfs-slow-fs-tests", |
| ":fuchsia-fatfs-fuzzer", |
| ":fuchsia-fatfs-tests", |
| "//src/storage/fuchsia-fatfs/mounter:tests", |
| ] |
| } |
| |
| # This group includes mkfs and fsck and the block_adapter tool that is required to run them. |
| # fs-management requires all of these to be able to run mkfs and fsck for fatfs. |
| group("tools") { |
| deps = [ |
| "//src/storage/block_adapter", |
| "//zircon/third_party/uapp/fsck-msdosfs", |
| "//zircon/third_party/uapp/mkfs-msdosfs", |
| ] |
| } |