blob: 75b66bb9af0eef4b48592358bfbc50f29f5d04e5 [file] [log] [blame]
# 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/config.gni")
import("//build/dist/resource.gni")
import("//build/rust/rustc_binary.gni")
import("//build/rust/rustc_test.gni")
import("//build/zbi/zbi.gni")
import("//src/sys/core/build/core_shard.gni")
rustc_binary("bin") {
name = "factory_store_providers"
edition = "2021"
with_unit_tests = true
deps = [
"//sdk/fidl/fuchsia.boot:fuchsia.boot_rust",
"//sdk/fidl/fuchsia.factory:fuchsia.factory_rust",
"//sdk/fidl/fuchsia.hardware.block:fuchsia.hardware.block_rust",
"//sdk/fidl/fuchsia.io:fuchsia.io_rust",
"//sdk/lib/device-watcher/rust",
"//src/lib/fdio/rust:fdio",
"//src/lib/fidl/rust/fidl",
"//src/lib/fuchsia",
"//src/lib/fuchsia-component",
"//src/lib/fuchsia-fs",
"//src/lib/zircon/rust:fuchsia-zircon",
"//src/storage/ext4/server/fidl:ext4_readonly_rust",
"//src/storage/lib/block_client/rust:remote-block-device",
"//src/storage/lib/vfs/rust:vfs",
"//src/sys/lib/fuchsia-bootfs",
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:futures",
"//third_party/rust_crates:serde",
"//third_party/rust_crates:serde_json",
"//third_party/rust_crates:thiserror",
"//third_party/rust_crates:tracing",
]
test_deps = [ "//src/lib/fuchsia-async" ]
sources = [
"src/config.rs",
"src/main.rs",
"src/validators/mod.rs",
"src/validators/pass.rs",
"src/validators/size.rs",
"src/validators/text.rs",
]
}
core_shard("factory_store_providers_shard") {
shard_file = "meta/factory_store_providers.core_shard.cml"
}
fuchsia_component("factory_store_providers_comp") {
component_name = "factory_store_providers"
manifest = "meta/factory_store_providers.cml"
deps = [ ":bin" ]
}
fuchsia_package("factory_store_providers") {
deps = [ ":factory_store_providers_comp" ]
}
rustc_test("factory_store_providers_test") {
edition = "2021"
source_root = "tests/factory_store_providers_test.rs"
deps = [
"//sdk/fidl/fuchsia.factory:fuchsia.factory_rust",
"//sdk/fidl/fuchsia.io:fuchsia.io_rust",
"//sdk/lib/device-watcher/rust",
"//src/devices/bus/drivers/platform",
"//src/lib/fidl/rust/fidl",
"//src/lib/fuchsia-async",
"//src/lib/fuchsia-component",
"//src/lib/fuchsia-fs",
"//src/storage/testing:storage_drivers",
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:tracing",
]
sources = [ "tests/factory_store_providers_test.rs" ]
}
test_files = [
"alpha_file",
"another_cast_file",
"failed_widevine_file",
"ignored_misc_file",
"multi_validated_file",
"other/misc",
"passed_misc_file",
"pr/file1",
"some_cast_file",
"weave_file",
"widevine_file",
]
zbi_deps = []
foreach(file, test_files) {
name = "zbi_$file"
zbi_deps += [ ":$name" ]
resource(name) {
testonly = true
sources = [ "testdata/input/$file" ]
outputs = [ file ]
}
}
test_file_resources = []
foreach(file, test_files) {
name = "test_resource_$file"
test_file_resources += [ ":$name" ]
resource(name) {
testonly = true
sources = [ "testdata/input/$file" ]
outputs = [ "data/{{source_file_part}}" ]
}
}
zbi("items") {
testonly = true
cpu = "" # Mark the zbi as incomplete.
compress = false
deps = zbi_deps
}
items_zbi_outputs = get_target_outputs(":items")
resource("factory_ext4_image") {
testonly = true
sources = [ "testdata/factory_ext4.img" ]
outputs = [ "data/factory_ext4.img" ]
}
fuchsia_test_component("factory_store_providers_ext4_test_comp") {
component_name = "factory_store_providers_ext4_test"
manifest = "meta/factory_store_providers_ext4_test.cml"
deps = [ ":factory_store_providers_test" ]
}
fuchsia_test_package("factory_store_providers_ext4_tests") {
test_components = [ ":factory_store_providers_ext4_test_comp" ]
deps = [
":factory_ext4_image",
":factory_store_providers_comp",
":factory_store_providers_ext4_tests_config",
"//src/factory/factory_store_providers/driver_test_realm",
"//src/storage/ext4/server:ext4_readonly_comp",
] + test_file_resources
test_specs = {
log_settings = {
max_severity = "ERROR"
}
}
}
resource("items_zbi") {
testonly = true
sources = [ items_zbi_outputs[0] ]
outputs = "data/items.zbi"
deps = [ ":items" ]
}
resource("fake_factory_items_json") {
testonly = true
sources = [ "testdata/fake_factory_items.json" ]
outputs = "data/fake_factory_items.json"
}
fuchsia_test_component("factory_store_providers_test_comp") {
component_name = "factory_store_providers_test"
manifest = "meta/factory_store_providers_test.cml"
deps = [ ":factory_store_providers_test" ]
}
fuchsia_unittest_component("factory_store_providers_bin_test_comp") {
component_name = "factory_store_providers_bin_test"
deps = [ ":bin_test" ]
}
fuchsia_test_package("factory_store_providers_tests_no_errors") {
test_components = [ ":factory_store_providers_bin_test_comp" ]
}
fuchsia_test_package("factory_store_providers_tests") {
test_components = [ ":factory_store_providers_test_comp" ]
deps = [
":factory_store_providers_comp",
":factory_store_providers_tests_config",
":fake_factory_items_json",
":items_zbi",
"../fake_factory_items:fake_factory_items_comp",
] + test_file_resources
test_specs = {
log_settings = {
max_severity = "ERROR"
}
}
}
resource("factory_store_providers_ext4_tests_config") {
sources = [
"testdata/factory.config",
"testdata/fuchsia.factory.AlphaFactoryStoreProvider.config",
"testdata/fuchsia.factory.CastCredentialsFactoryStoreProvider.config",
"testdata/fuchsia.factory.MiscFactoryStoreProvider.config",
"testdata/fuchsia.factory.PlayReadyFactoryStoreProvider.config",
"testdata/fuchsia.factory.WeaveFactoryStoreProvider.config",
"testdata/fuchsia.factory.WidevineFactoryStoreProvider.config",
]
outputs = [ "data/{{source_file_part}}" ]
}
resource("factory_store_providers_tests_config") {
sources = [
"testdata/fuchsia.factory.AlphaFactoryStoreProvider.config",
"testdata/fuchsia.factory.CastCredentialsFactoryStoreProvider.config",
"testdata/fuchsia.factory.MiscFactoryStoreProvider.config",
"testdata/fuchsia.factory.PlayReadyFactoryStoreProvider.config",
"testdata/fuchsia.factory.WeaveFactoryStoreProvider.config",
"testdata/fuchsia.factory.WidevineFactoryStoreProvider.config",
]
outputs = [ "data/{{source_file_part}}" ]
}
group("tests") {
testonly = true
deps = [
":factory_store_providers_ext4_tests",
":factory_store_providers_tests",
":factory_store_providers_tests_no_errors",
]
}