blob: ca211b43f194c8ab68752480f0e7b88708f5d719 [file] [log] [blame]
# Copyright 2021 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/components/fuchsia_unittest_component.gni")
import("//build/fuzz.gni")
import("//build/rust/rustc_binary.gni")
import("//build/rust/rustc_fuzzer.gni")
import("//build/rust/rustc_library.gni")
import("//build/rust/rustc_macro.gni")
import("//src/storage/fs_test/suite.gni")
import("//src/storage/testing/driver_test_realm.gni")
import("//tools/cmc/build/expect_includes.gni")
fxfs_deps = [
":fxfs_macros",
"//sdk/fidl/fuchsia.io:fuchsia.io_rust",
"//src/lib/diagnostics/inspect/rust",
"//src/lib/fuchsia-async",
"//src/lib/mundane",
"//src/storage/fxfs/crypto",
"//src/storage/fxfs/trace",
"//src/storage/fxfs/unicode",
"//src/storage/lib/fsverity-merkle",
"//src/storage/lib/storage_device",
"//src/storage/type-fprint:fprint",
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:assert_matches",
"//third_party/rust_crates:async-trait",
"//third_party/rust_crates:bincode",
"//third_party/rust_crates:bit-vec",
"//third_party/rust_crates:byteorder",
"//third_party/rust_crates:either",
"//third_party/rust_crates:event-listener",
"//third_party/rust_crates:futures",
"//third_party/rust_crates:linked-hash-map",
"//third_party/rust_crates:num-traits",
"//third_party/rust_crates:once_cell",
"//third_party/rust_crates:rand",
"//third_party/rust_crates:rustc-hash",
"//third_party/rust_crates:scopeguard",
"//third_party/rust_crates:serde",
"//third_party/rust_crates:static_assertions",
"//third_party/rust_crates:thiserror",
"//third_party/rust_crates:tracing",
"//third_party/rust_crates:uuid",
"//third_party/rust_crates:zerocopy_0_0_0_alpha_0",
]
fxfs_test_deps = [
"//src/lib/fuchsia",
"//src/storage/fxfs/crypto/insecure",
]
fxfs_sources = [
"src/checksum.rs",
"src/debug_assert_not_too_long.rs",
"src/drop_event.rs",
"src/errors.rs",
"src/filesystem.rs",
"src/fsck.rs",
"src/fsck/errors.rs",
"src/fsck/store_scanner.rs",
"src/fsck/tests.rs",
"src/lib.rs",
"src/log.rs",
"src/lsm_tree.rs",
"src/lsm_tree/bloom_filter.rs",
"src/lsm_tree/cache.rs",
"src/lsm_tree/merge.rs",
"src/lsm_tree/persistent_layer.rs",
"src/lsm_tree/skip_list_layer.rs",
"src/lsm_tree/types.rs",
"src/metrics.rs",
"src/object_handle.rs",
"src/object_store.rs",
"src/object_store/allocator.rs",
"src/object_store/allocator/merge.rs",
"src/object_store/allocator/strategy.rs",
"src/object_store/caching_object_handle.rs",
"src/object_store/data_object_handle.rs",
"src/object_store/directory.rs",
"src/object_store/extent_record.rs",
"src/object_store/flush.rs",
"src/object_store/graveyard.rs",
"src/object_store/journal.rs",
"src/object_store/journal/bootstrap_handle.rs",
"src/object_store/journal/checksum_list.rs",
"src/object_store/journal/reader.rs",
"src/object_store/journal/super_block.rs",
"src/object_store/journal/writer.rs",
"src/object_store/key_manager.rs",
"src/object_store/merge.rs",
"src/object_store/object_manager.rs",
"src/object_store/object_record.rs",
"src/object_store/project_id.rs",
"src/object_store/store_object_handle.rs",
"src/object_store/transaction.rs",
"src/object_store/tree.rs",
"src/object_store/tree_cache.rs",
"src/object_store/volume.rs",
"src/range.rs",
"src/round.rs",
"src/serialized_types.rs",
"src/serialized_types/test_traits.rs",
"src/serialized_types/tests.rs",
"src/serialized_types/traits.rs",
"src/serialized_types/types.rs",
"src/testing.rs",
"src/testing/fake_object.rs",
"src/testing/writer.rs",
]
if (is_fuchsia) {
fxfs_deps += [
"//src/lib/zircon/rust:fuchsia-zircon",
"//third_party/rust_crates:scopeguard",
]
if (is_debug) {
fxfs_deps += [ "//src/lib/debug/rust" ]
}
fxfs_test_deps += [
"//src/storage/blobfs/bin:blobfs-component",
"//third_party/zstd",
]
}
rustc_macro("fxfs_macros") {
edition = "2021"
name = "fxfs_macros"
deps = [
"//third_party/rust_crates:proc-macro2",
"//third_party/rust_crates:quote",
# FIXME(https://fxbug.dev/332277415): Please update to syn 2.x.
# "//third_party/rust_crates:syn",
"//third_party/rust_crates:syn-v1_0_98",
]
source_root = "macros/macros.rs"
sources = [ "macros/macros.rs" ]
}
rustc_library("lib") {
edition = "2021"
with_unit_tests = true
name = "fxfs"
deps = fxfs_deps
sources = fxfs_sources
test_deps = fxfs_test_deps
}
fuchsia_unittest_component("fxfs-test") {
deps = [ ":lib_test" ]
}
fuchsia_unittest_component("fxfs-crypto-test") {
deps = [ "crypto:crypto_test" ]
}
fuchsia_unittest_component("fxfs-make-blob-image-test") {
deps = [
"make-blob-image:make-blob-image_test",
"//src/sys/test_runners:tmp_storage",
]
}
storage_driver_test_realm_v2_component("fxfs-platform-test") {
deps = [ "platform:platform_test" ]
manifest = "platform/meta/fxfs-platform-test.cml"
}
fuchsia_test_package("fxfs-tests") {
test_components = [
":fxfs-test",
":fxfs-crypto-test",
":fxfs-make-blob-image-test",
":fxfs-platform-test",
]
test_specs = {
log_settings = {
# We expect some tests to produce ERROR logs
max_severity = "ERROR"
}
}
}
rustc_binary("fxfs") {
edition = "2021"
deps = [
":lib",
"//src/lib/diagnostics/inspect/runtime/rust",
"//src/lib/diagnostics/inspect/rust",
"//src/lib/diagnostics/log/rust",
"//src/lib/fuchsia-async",
"//src/lib/fuchsia-component",
"//src/lib/fuchsia-runtime",
"//src/lib/trace/rust:trace-provider",
"//src/storage/fxfs/platform",
"//third_party/rust_crates:anyhow",
]
sources = [ "src/main.rs" ]
configs += [
# Optimize for size
"//build/config/rust:bootfs",
]
# Add thinlto config if lto variants are not used.
if (!is_lto_variant) {
# Optimize for speed (Fxfs is split into several crates; apply optimizations across them).
configs += [ "//build/config/lto:thinlto" ]
}
}
fuchsia_component("fxfs_component") {
component_name = "fxfs"
deps = [ ":fxfs" ]
manifest = "meta/fxfs.cml"
}
fuchsia_package("package") {
package_name = "fxfs"
deps = [ ":fxfs_component" ]
}
fuchsia_shell_package("fxfs-bin") {
deps = [ ":fxfs" ]
}
fs_test_config("fxfs") {
is_multi_volume = true
# See MAX_FILE_SIZE in filesystem.rs.
max_file_size = 9223372036854771712
supports_fsck_after_every_transaction = true
# TODO(https://fxbug.dev/42063349) Add support for block sizes greater than the page size.
max_block_size = 4096
supports_hard_links = true
supports_inspect = true
supports_resize = true
supports_mmap = true
supports_mmap_shared_write = true
supports_shutdown_on_no_connections = true
timestamp_granularity = 1
disk_format = 12 # See //src/storage/lib/fs_management/cpp/format.h
uses_crypt = true
options = [
{
description = "Fxfs"
use_fvm = false
has_min_volume_size = true
device_block_count = 24576
device_block_size = 512
},
]
}
test("fxfs-interop-fs") {
sources = [ "test/fs_test.cc" ]
deps = [
"//sdk/fidl/fuchsia.io:fuchsia.io_cpp",
"//sdk/lib/component/incoming/cpp",
"//src/lib/fxl/test:gtest_main",
"//src/storage/fs_test",
"//src/storage/fs_test:test_crypt_service",
"//src/storage/fxfs",
"//src/storage/lib/block_client/cpp",
"//zircon/system/ulib/fbl",
"//zircon/system/ulib/fdio-caller",
]
# TODO(https://fxbug.dev/42085293): delete the below and fix compiler warnings
configs += [ "//build/config:Wno-vla-cxx-extension" ]
}
storage_driver_test_realm_v2_component("fxfs-interop-fs-tests") {
deps = [
":fxfs-interop-fs",
":test_fxfs_component_manifest_shard",
]
}
expect_includes("test_fxfs_component_manifest_shard") {
testonly = true
includes = [ "meta/test_fxfs.shard.cml" ]
}
fs_test_suite("fxfs") {
deps = [
":fxfs_component",
":fxfs_fs_test_config",
"//src/storage/fxfs",
"//src/storage/fxfs-crypt",
]
extra_components = [ ":fxfs-interop-fs-tests" ]
component_deps = [
":test_fxfs_component_manifest_shard",
"//src/storage/fs_test:test_crypt_service",
]
}
slow_fs_test_suite("fxfs") {
deps = [
":fxfs_component",
":fxfs_fs_test_config",
"//src/storage/fxfs",
"//src/storage/fxfs-crypt",
]
component_deps = [
":test_fxfs_component_manifest_shard",
"//src/storage/fs_test:test_crypt_service",
]
}
group("tests") {
testonly = true
deps = [
":fxfs-fs-tests",
":fxfs-fuzzers",
":fxfs-slow-fs-tests",
":fxfs-tests",
":fxfs_component",
":lib_test($host_toolchain)",
"//src/storage/fxfs/tools:tests",
"//src/storage/fxfs/trace:tests",
"//src/storage/fxfs/unicode:tests",
]
}
#################
## Fuzzers
#################
_fuzzers = [
"fuzz_lsm_tree_actions",
"fuzz_journal",
"fuzz_journal_bytes",
]
foreach(fuzzer, _fuzzers) {
rustc_fuzzer(fuzzer) {
edition = "2021"
deps = fxfs_deps + [
"//src/lib/fuzzing/rust:fuzz",
"//third_party/rust_crates:arbitrary",
"//third_party/rust_crates:futures",
]
sources = fxfs_sources
}
fuchsia_fuzzer_component("${fuzzer}_component") {
manifest = "meta/${fuzzer}.cml"
deps = [ ":$fuzzer" ]
}
}
fuchsia_fuzzer_package("fxfs-fuzzers") {
rust_fuzzer_components = []
foreach(fuzzer, _fuzzers) {
rust_fuzzer_components += [ ":${fuzzer}_component" ]
}
}
group("fuzzers") {
testonly = true
deps = [ ":fxfs-fuzzers" ]
}