| # 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/fuchsia_structured_config.gni") |
| import("//build/config.gni") |
| import("//build/rust/rustc_binary.gni") |
| import("//build/rust/rustc_test.gni") |
| import("//build/testing/environments.gni") |
| import("//src/hwinfo/hwinfo_config.gni") |
| |
| rustc_binary("hwinfo_bin") { |
| name = "hwinfo" |
| edition = "2021" |
| |
| deps = [ |
| ":hwinfo_structured_config", |
| "//sdk/fidl/fuchsia.boot:fuchsia.boot_rust", |
| "//sdk/fidl/fuchsia.factory:fuchsia.factory_rust", |
| "//sdk/fidl/fuchsia.hwinfo:fuchsia.hwinfo_rust", |
| "//sdk/fidl/fuchsia.intl:fuchsia.intl_rust", |
| "//sdk/fidl/fuchsia.io:fuchsia.io_rust", |
| "//src/lib/fidl/rust/fidl", |
| "//src/lib/fuchsia", |
| "//src/lib/fuchsia-async", |
| "//src/lib/fuchsia-component", |
| "//src/lib/fuchsia-fs", |
| "//src/sys/lib/fuchsia-zbi", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:chrono", |
| "//third_party/rust_crates:futures", |
| "//third_party/rust_crates:log", |
| "//third_party/rust_crates:serde", |
| "//third_party/rust_crates:serde_json", |
| ] |
| |
| sources = [ |
| "src/config.rs", |
| "src/hwinfo_server.rs", |
| "src/main.rs", |
| ] |
| } |
| |
| hwinfo_config("default_board_config") { |
| type = "board" |
| config = rebase_path("default_board_config.json") |
| } |
| |
| fuchsia_component_manifest("manifest") { |
| component_name = "hwinfo" |
| manifest = "meta/hwinfo.cml" |
| } |
| |
| fuchsia_component("hwinfo_component") { |
| cm_label = ":manifest" |
| deps = [ ":hwinfo_bin" ] |
| } |
| |
| fuchsia_structured_config_rust_lib("hwinfo_structured_config") { |
| cm_label = ":manifest" |
| } |
| |
| fuchsia_package("hwinfo") { |
| validate_structured_config = false |
| deps = [ ":hwinfo_component" ] |
| } |
| |
| template("hwinfo_integration_test") { |
| assert(defined(invoker.manifest), "A manifest must be specified.") |
| assert(defined(invoker.deps), "Test dependencies must be specified.") |
| test_name = target_name |
| |
| fuchsia_component("${test_name}_hwinfo") { |
| testonly = true |
| component_name = "hwinfo" |
| manifest = "meta/hwinfo.cml" |
| deps = [ ":hwinfo_bin" ] |
| } |
| |
| fuchsia_component("${test_name}_test_driver") { |
| testonly = true |
| manifest = "meta/${test_name}_test_driver.cml" |
| deps = invoker.deps |
| } |
| |
| fuchsia_component("${test_name}_misc_cm") { |
| testonly = true |
| component_name = "fake_factory_store_providers" |
| manifest = "//src/factory/fake_factory_store_providers/meta/fake_misc.cml" |
| if (test_name == "hwinfo_retail_tests") { |
| manifest = |
| "//src/factory/fake_factory_store_providers/meta/misc_retail.cml" |
| } |
| deps = [ "//src/factory/fake_factory_store_providers:bin" ] |
| } |
| |
| fuchsia_test_component("${test_name}_component") { |
| component_name = test_name |
| manifest = invoker.manifest |
| deps = invoker.deps |
| } |
| |
| fuchsia_test_package("${test_name}_package") { |
| package_name = test_name |
| test_components = [ ":${test_name}_component" ] |
| deps = [ |
| ":${test_name}_hwinfo", |
| ":${test_name}_misc_cm", |
| ":${test_name}_test_driver", |
| ] |
| if (defined(invoker.test_specs)) { |
| test_specs = invoker.test_specs |
| } |
| } |
| |
| group(target_name) { |
| testonly = true |
| deps = [ ":${test_name}_package" ] |
| } |
| } |
| |
| rustc_test("hwinfo_positive_test") { |
| edition = "2021" |
| source_root = "tests/hwinfo_positive_test.rs" |
| |
| deps = [ |
| "//sdk/fidl/fuchsia.hwinfo:fuchsia.hwinfo_rust", |
| "//src/lib/fuchsia-async", |
| "//src/lib/fuchsia-component", |
| "//third_party/rust_crates:anyhow", |
| ] |
| |
| sources = [ "tests/hwinfo_positive_test.rs" ] |
| } |
| |
| rustc_test("hwinfo_negative_test") { |
| edition = "2021" |
| source_root = "tests/hwinfo_negative_test.rs" |
| |
| deps = [ |
| "//sdk/fidl/fuchsia.hwinfo:fuchsia.hwinfo_rust", |
| "//src/lib/fuchsia-async", |
| "//src/lib/fuchsia-component", |
| "//third_party/rust_crates:anyhow", |
| ] |
| |
| sources = [ "tests/hwinfo_negative_test.rs" ] |
| } |
| |
| rustc_test("hwinfo_retail_test") { |
| edition = "2021" |
| source_root = "tests/hwinfo_retail_test.rs" |
| |
| deps = [ |
| "//sdk/fidl/fuchsia.hwinfo:fuchsia.hwinfo_rust", |
| "//src/lib/fuchsia-async", |
| "//src/lib/fuchsia-component", |
| "//third_party/rust_crates:anyhow", |
| ] |
| |
| sources = [ "tests/hwinfo_retail_test.rs" ] |
| } |
| |
| hwinfo_integration_test("hwinfo_positive_tests") { |
| manifest = "meta/hwinfo_positive_tests.cml" |
| deps = [ |
| ":hwinfo_positive_test", |
| ":hwinfo_tests_config", |
| ":hwinfo_tests_factory_config", |
| ":hwinfo_tests_product_config", |
| ] |
| } |
| |
| hwinfo_integration_test("hwinfo_negative_tests") { |
| manifest = "meta/hwinfo_negative_tests.cml" |
| deps = [ |
| ":hwinfo_negative_test", |
| |
| # The component cannot be compiled without the correct structured config |
| # values, therefore we cannot have a missing name, model, or manufacturer. |
| ":hwinfo_tests_product_config", |
| ] |
| test_specs = { |
| log_settings = { |
| max_severity = "ERROR" |
| } |
| } |
| } |
| |
| hwinfo_integration_test("hwinfo_retail_tests") { |
| manifest = "meta/hwinfo_retail_tests.cml" |
| deps = [ |
| ":hwinfo_retail_test", |
| ":hwinfo_retail_tests_config", |
| ":hwinfo_retail_tests_factory_config", |
| ":hwinfo_tests_product_config", |
| ] |
| } |
| |
| resource("hwinfo_tests_factory_config") { |
| sources = [ "testdata/test_misc.config" ] |
| outputs = [ "data/{{source_file_part}}" ] |
| } |
| |
| resource("hwinfo_tests_config") { |
| sources = [ "testdata/board_config.json" ] |
| outputs = [ "hwinfo_positive_tests/{{source_file_part}}" ] |
| } |
| |
| resource("hwinfo_retail_tests_factory_config") { |
| sources = |
| [ "testdata/fuchsia.factory.MiscFactoryStoreProvider_retail.config" ] |
| outputs = [ "fake_factory_store_providers/{{source_file_part}}" ] |
| } |
| |
| resource("hwinfo_retail_tests_config") { |
| sources = [ "testdata/board_config.json" ] |
| outputs = [ "hwinfo_retail_tests/{{source_file_part}}" ] |
| } |
| |
| fuchsia_structured_config_values("hwinfo_tests_product_config") { |
| cm_label = ":manifest" |
| values = { |
| product_name = "test_product_name" |
| product_model = "test_product_model" |
| product_manufacturer = "test_manufacturer" |
| } |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":hwinfo_negative_tests", |
| ":hwinfo_positive_tests", |
| ":hwinfo_retail_tests", |
| "mock:tests", |
| ] |
| } |