blob: 8b28cc1b8eed03b6b753f66e18d11047aeb1158d [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")
# Generates a gtest unit test package with a v2 test component from a source_set of GTest tests.
#
# Example:
#
# ```
# bt_gtest_package("example-tests") {
# deps = [":tests"]
# with_death_tests = true
# }
# ```
#
# Parameters
#
# with_death_tests (optional)
# Set true if the unit tests include gtest death tests so that the appropriate
# test component capabilities can be included.
# Type: bool
# Default: false
#
# deps (required)
template("bt_gtest_package") {
assert(
defined(invoker.deps),
"A `deps` argument was missing when calling bt_gtest_package($target_name)")
package_name = target_name
if (defined(invoker.package_name)) {
package_name = invoker.package_name
}
# Determines whether to include the manifest capabilities needed to run death tests
with_death_tests =
defined(invoker.with_death_tests) && invoker.with_death_tests
executable("tests_executable") {
testonly = true
output_name = package_name
deps = invoker.deps
deps += [ "//src/connectivity/bluetooth/core/bt-host/testing:gtest_main" ]
if (with_death_tests) {
metadata = {
# Used by the fuchsia_test_component_manifest() template in v2.
test_component_manifest_cml = [
{
use = [
{
# Enable gtest death tests to spawn processes.
protocol = [ "fuchsia.process.Launcher" ]
},
]
},
]
}
}
}
fuchsia_unittest_package(package_name) {
v2 = true
# Use the ELF test runner instead of the GTest test runner.
deprecated_legacy_test_execution = true
deps = [ ":tests_executable" ]
}
}