blob: c21eaed8f4311f2add3d9f9160e73a452cfdf52b [file] [log] [blame]
# 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/rust/rustc_test.gni")
import("./wlan_integration_test_component.gni")
import("./wlan_integration_test_package.gni")
# Creates a WLAN integration test package where the test suite is defined in a Rust binary.
#
# Ideally, this should look as close as the `rustc_test` template as possible. As such,
# this forwards all parameters except:
#
# binary_deps (optional)
# Dependencies for the test suite binary, forwarded to rustc_test.
#
# package_deps (optional)
# Dependencies for the test suite package, forwarded to wlan_integration_test_package.
# This should include anything that needs to be packaged with the test suite binary (e.g.,
# the test driver target).
#
# test_suite_package_name (optional)
# Name of the test suite package. By default this is
# ${target_name}-wlan-integration-tests.
#
# package_name (optional)
# Name of the output integration test package.
#
# ctf (optional)
# Set to true if this defines a CTF test. False by default.
#
# test_specs (optional)
#
# All other parameters will be forwarded to the internal call to rustc_test.
# See //build/rust/rustc_test.gni for more information about its parameters.
template("rust_wlan_integration_test") {
assert(!defined(invoker.deps))
binary_deps = []
if (defined(invoker.binary_deps)) {
binary_deps = invoker.binary_deps
}
# NOTE: If $target_name is in kebab case, rustc_test will format it to be snake_case
# even if we manually set output_name = $target_name. So we convert $test_binary_name
# to snake_case here.
test_binary_name = string_replace("${target_name}_test_suite", "-", "_")
rustc_test(test_binary_name) {
forward_variables_from(invoker,
"*",
[
"test_specs",
"test_driver",
"package_name",
"package_deps",
"test_suite_package_name",
"ctf",
"deps",
])
deps = binary_deps
}
component_name = "test-suite"
component = "${target_name}-component"
wlan_integration_test_component(component) {
test_suite_binary = "${test_binary_name}"
component_name = component_name
visibility = [ ":*" ]
deps = [ ":${test_binary_name}" ]
}
package_deps = [ ":${component}" ]
if (defined(invoker.package_deps)) {
package_deps += invoker.package_deps
}
wlan_integration_test_package(target_name) {
forward_variables_from(invoker,
[
"test_specs",
"test_driver",
"package_name",
"test_suite_package_name",
"ctf",
])
test_suite_component_name = component_name
test_suite_package_deps = package_deps
}
}