| # Copyright 2022 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/testing/host_test.gni") |
| |
| # Defines a host_test that can be used in the CTF. |
| # |
| # An equivalent to host_test, but ensures dependencies are allowed in the CTF. |
| # |
| # See host_test() for parameters. |
| template("ctf_host_test") { |
| main_target_name = target_name + "_host" |
| |
| # TODO(https://fxbug.dev/303077069): This template should not generate |
| # the host_test target. |
| host_test(main_target_name) { |
| forward_variables_from(invoker, "*") |
| } |
| |
| copy_target_name = target_name + "_copy" |
| copy(copy_target_name) { |
| testonly = true |
| sources = [ invoker.binary_path ] |
| outputs = [] |
| foreach(file, get_path_info(sources, "file")) { |
| outputs += [ "$root_build_dir/cts/host_${host_cpu}/$file" ] |
| } |
| deps = invoker.deps |
| |
| metadata = { |
| ctf_artifacts = rebase_path(outputs, root_build_dir) |
| } |
| } |
| |
| group(target_name) { |
| testonly = true |
| metadata = { |
| host_test_manifest = [ |
| { |
| test_name = target_name |
| binary_path = rebase_path(invoker.binary_path, root_build_dir) |
| args = invoker.args |
| }, |
| ] |
| } |
| deps = [ |
| ":$copy_target_name", |
| ":$main_target_name", |
| ] |
| } |
| } |