| # Copyright 2024 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("//sdk/ctf/build/ctf.gni") |
| |
| # This generates a fuchsia_test_package that conforms to the architecture required for |
| # Test Realm Factory tests. |
| # See https://fuchsia.dev/fuchsia-src/development/testing/components/test_realm_factory for details. |
| # |
| # This template will generate: |
| # |
| # - fuchsia_package containing the test_suite_package_deps which should include |
| # the test component target. |
| # - test-root component |
| # - fuchsia_test_package with the generated test-root component as the test |
| # component, and realm-factory and the generated test_suite_package as subpackages |
| # |
| # Parameters |
| # |
| # test_suite_package_deps (required) |
| # The dependencies of the test suite package that will be generated by this template. |
| # This should include the test component, and any other components that must be packaged with |
| # the test component. |
| # |
| # test_suite_component_name (required) |
| # The name of the test suite component. The generated test-root component needs to know the |
| # name of the test suite component so that it can add it as a child. |
| # |
| # test_suite_package_name (optional) |
| # The name of the test suite package. |
| # |
| # package_name (optional) |
| # The package name of the integration test package. |
| template("wlan_integration_test_package") { |
| assert(defined(invoker.test_suite_package_deps)) |
| assert(defined(invoker.test_suite_component_name)) |
| |
| test_suite_package_name = "${target_name}-wlan-integration-tests" |
| if (defined(invoker.test_suite_package_name)) { |
| test_suite_package_name = invoker.test_suite_package_name |
| } |
| |
| # Test suite package. Will be subpackaged by the integration test package. |
| if (defined(invoker.ctf) && invoker.ctf) { |
| ctf_fuchsia_package(test_suite_package_name) { |
| testonly = true |
| package_name = "${test_suite_package_name}" |
| deps = invoker.test_suite_package_deps |
| } |
| } else { |
| fuchsia_package(test_suite_package_name) { |
| testonly = true |
| package_name = "${test_suite_package_name}" |
| deps = invoker.test_suite_package_deps |
| visibility = [ ":*" ] |
| } |
| } |
| |
| # Generates component manifest for the test root component. |
| test_root_name = "${target_name}-test-root" |
| test_root_manifest_target = "${test_root_name}-manifest" |
| test_root_manifest = "${target_gen_dir}/${test_root_name}.cml" |
| |
| # TODO(https://fxbug.dev/286435361) test realm factory should autogenerate test-root components |
| generated_file(test_root_manifest_target) { |
| testonly = true |
| contents = { |
| include = [ |
| "//src/connectivity/wlan/tests/helpers/build/meta/test-root.shard.cml", |
| ] |
| children = [ |
| { |
| name = "test_suite" # NOTE: this name needs to match the name used in |
| # test-root.shard.cml |
| url = "${test_suite_package_name}#meta/${invoker.test_suite_component_name}.cm" |
| }, |
| ] |
| } |
| outputs = [ test_root_manifest ] |
| output_conversion = "json" |
| visibility = [ ":*" ] |
| } |
| |
| # Create test-root using generated component manifest. |
| test_root_component = "${test_root_name}-component" |
| fuchsia_test_component(test_root_component) { |
| testonly = true |
| manifest = test_root_manifest |
| component_name = "test-root" |
| deps = [ |
| ":${test_root_manifest_target}", |
| "//src/storage/memfs:memfs_component", |
| ] |
| } |
| |
| # Package containing full integration test. |
| fuchsia_test_package(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "test_specs", |
| "package_name", |
| ]) |
| test_components = [ ":${test_root_component}" ] |
| subpackages = [ |
| "//src/connectivity/wlan/tests/helpers/realm-factory", |
| "//src/lib/fuchsia-component-test/realm_builder_server:pkg", |
| ":${test_suite_package_name}", |
| ] |
| } |
| } |