blob: ea1d49e63ec9f82ac140ae0bd0edd60a33979cdc [file] [log] [blame]
# 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/testing/cc_test_executable.gni")
import("//sdk/ctf/build/ctf.gni")
shebang = "#!resolve fuchsia-pkg://fuchsia.com/fdio-spawn-tests"
if (defined(cts_version) && cts_version != "") {
shebang += "_${cts_version}"
}
cc_test_executable("fdio-spawn-tests-bin") {
output_name = "fdio-spawn-tests-bin"
testonly = true
visibility = [ ":*" ]
sources = [
"resolve_test.cc",
"shebang_test.cc",
"spawn_test.cc",
"util.cc",
"util.h",
]
deps = [
":fake-launcher-util-bin",
"//sdk/fidl/fuchsia.io:fuchsia.io_hlcpp",
"//sdk/lib/fdio",
"//zircon/system/ulib/zxtest",
]
}
# TODO(b/295025303): Runs ResolveTest.* cases at ToT, but is not run in CTF.
# For some reason, helper test binaries cannot be resolved with '#!resolve' when
# this test is run as a CTF prebuilt. Debug and merge these back into a single
# :fdio-spawn-test component.
fuchsia_component("fdio-spawn-resolve-test") {
testonly = true
manifest = "meta/fdio-spawn-resolve-test.cml"
deps = [ ":fdio-spawn-tests-bin" ]
}
fuchsia_test_component("resolve-test-root") {
manifest = "meta/fdio-spawn-resolve-tests-root.cml"
test_type = "ctf"
}
# A test utility used to test various features of fdio_spawn, extensively in spawn_test.cc.
executable("spawn-child-util-bin") {
testonly = true
visibility = [ ":*" ]
output_name = "spawn_child_util"
sources = [ "spawn_child_util.cc" ]
deps = [
"//sdk/lib/fdio",
"//zircon/system/ulib/zx",
]
}
fuchsia_component("spawn-child-util-component") {
testonly = true
manifest = "meta/spawn-child-util-component.cml"
deps = [ ":spawn-child-util-bin" ]
}
# A test utility that attempts to use zx_process_create (mimicking a launcher implementation).
executable("fake-launcher-util-bin") {
testonly = true
visibility = [ ":*" ]
output_name = "fake_launcher_util"
sources = [
"fake_launcher_util.cc",
"fake_launcher_util.h",
]
deps = [
"//sdk/lib/fdio",
"//zircon/system/ulib/zx",
]
}
fuchsia_component("fake-launcher-util-component") {
testonly = true
manifest = "meta/fake-launcher-util-component.cml"
deps = [ ":fake-launcher-util-bin" ]
}
# A simple test utility that returns the integer value provided to it in its first argument.
cc_test_executable("return-arg-test-util-bin") {
testonly = true
output_name = "return_arg_test_util"
sources = [ "return_arg_util.cc" ]
}
fuchsia_component("return-arg-test-util-component") {
testonly = true
manifest = "meta/return-arg-test-util-component.cml"
deps = [ ":return-arg-test-util-bin" ]
}
# A simple program that prints the arguments with newline delimiter.
executable("echo-arguments-bin") {
output_name = "echo_arguments_bin"
sources = [ "echo_arguments.cc" ]
}
fuchsia_component("echo-arguments-bin-component") {
testonly = true
manifest = "meta/echo-arguments-bin-component.cml"
deps = [ ":echo-arguments-bin" ]
}
generated_file("resolve-once-file") {
outputs = [ "${target_gen_dir}/test_bins/resolve_once" ]
contents = "${shebang}#bin/return_arg_test_util"
}
# The 'binaries' in the components below are really just text files with either
# a "#!resolve" or "#!" directive.
resource("resolve-once-bin") {
sources = get_target_outputs(":resolve-once-file")
outputs = [ "bin/resolve_once" ]
deps = [ ":resolve-once-file" ]
allow_binary_output_dir = true
}
fuchsia_component("resolve-once-component") {
testonly = true
manifest = "meta/resolve-once-component.cml"
deps = [ ":resolve-once-bin" ]
}
generated_file("resolve-twice-file") {
outputs = [ "${target_gen_dir}/test_bins/resolve_twice" ]
contents = "${shebang}#bin/resolve_once"
}
resource("resolve-twice-bin") {
sources = get_target_outputs(":resolve-twice-file")
outputs = [ "bin/resolve_twice" ]
deps = [ ":resolve-twice-file" ]
allow_binary_output_dir = true
}
fuchsia_component("resolve-twice-component") {
testonly = true
manifest = "meta/resolve-twice-component.cml"
deps = [ ":resolve-twice-bin" ]
}
generated_file("resolve-infinite-loop-file") {
outputs = [ "${target_gen_dir}/test_bins/resolve_infinite_loop" ]
contents = "${shebang}#bin/resolve_infinite_loop"
}
resource("resolve-infinite-loop-bin") {
sources = get_target_outputs(":resolve-infinite-loop-file")
outputs = [ "bin/resolve_infinite_loop" ]
deps = [ ":resolve-infinite-loop-file" ]
allow_binary_output_dir = true
}
fuchsia_component("resolve-infinite-loop-component") {
testonly = true
manifest = "meta/resolve-infinite-loop-component.cml"
deps = [ ":resolve-infinite-loop-bin" ]
}
resource("resolve-to-not-found-bin") {
sources = [ "test_bins/resolve_to_not_found" ]
outputs = [ "bin/resolve_to_not_found" ]
allow_binary_output_dir = true
}
fuchsia_component("resolve-to-not-found-component") {
testonly = true
manifest = "meta/resolve-to-not-found-component.cml"
deps = [ ":resolve-to-not-found-bin" ]
}
resource("shebang-echo-arguments-bin") {
sources = [ "test_bins/shebang_echo_arguments" ]
outputs = [ "bin/shebang_echo_arguments" ]
allow_binary_output_dir = true
}
fuchsia_component("shebang-echo-arguments-component") {
testonly = true
manifest = "meta/shebang-echo-arguments-component.cml"
deps = [ ":shebang-echo-arguments-bin" ]
}
resource("use-script-as-interpreter-bin") {
sources = [ "test_bins/use_script_as_interpreter" ]
outputs = [ "bin/use_script_as_interpreter" ]
allow_binary_output_dir = true
}
fuchsia_component("use-script-as-interpreter-component") {
testonly = true
manifest = "meta/use-script-as-interpreter-component.cml"
deps = [ ":use-script-as-interpreter-bin" ]
}
resource("shebang-infinite-loop-bin") {
sources = [ "test_bins/shebang_infinite_loop" ]
outputs = [ "bin/shebang_infinite_loop" ]
allow_binary_output_dir = true
}
fuchsia_component("shebang-infinite-loop-component") {
testonly = true
manifest = "meta/shebang-infinite-loop-component.cml"
deps = [ ":shebang-infinite-loop-bin" ]
}
resource("attempt-use-shell-outside-package-script") {
sources = [ "test_bins/attempt_use_shell_outside_package.sh" ]
outputs = [ "bin/attempt_use_shell_outside_package.sh" ]
allow_binary_output_dir = true
}
fuchsia_component("attempt-use-shell-outside-package-component") {
testonly = true
manifest = "meta/attempt-use-shell-outside-package-component.cml"
deps = [ ":attempt-use-shell-outside-package-script" ]
}
resource("too-long-shebang-bin") {
sources = [ "test_bins/too_long_shebang" ]
outputs = [ "bin/too_long_shebang" ]
allow_binary_output_dir = true
}
fuchsia_component("too-long-shebang-component") {
testonly = true
manifest = "meta/too-long-shebang-component.cml"
deps = [ ":too-long-shebang-bin" ]
}
resource("use-resolve-from-shebang-bin") {
sources = [ "test_bins/use_resolve_from_shebang" ]
outputs = [ "bin/use_resolve_from_shebang" ]
allow_binary_output_dir = true
}
fuchsia_component("use-resolve-from-shebang-component") {
testonly = true
manifest = "meta/use-resolve-from-shebang-component.cml"
deps = [ ":use-resolve-from-shebang-bin" ]
}
generated_file("use-shebang-from-resolve-file") {
outputs = [ "${target_gen_dir}/test_bins/use-shebang-from-resolve" ]
contents = "${shebang}#bin/shebang_echo_arguments"
}
resource("use-shebang-from-resolve-bin") {
sources = get_target_outputs(":use-shebang-from-resolve-file")
outputs = [ "bin/use_shebang_from_resolve" ]
deps = [ ":use-shebang-from-resolve-file" ]
allow_binary_output_dir = true
}
fuchsia_component("use-shebang-from-resolve-component") {
testonly = true
manifest = "meta/use-shebang-from-resolve-component.cml"
deps = [ ":use-shebang-from-resolve-bin" ]
}
fuchsia_component("fdio-spawn-test") {
testonly = true
manifest = "meta/fdio-spawn-test.cml"
deps = [ ":fdio-spawn-tests-bin" ]
}
ctf_fuchsia_package("fdio-spawn-tests") {
testonly = true
package_name = "fdio-spawn-tests"
deps = [
# test components
":fdio-spawn-resolve-test",
":fdio-spawn-test",
# helper components
":attempt-use-shell-outside-package-component",
":echo-arguments-bin-component",
":fake-launcher-util-component",
":resolve-infinite-loop-component",
":resolve-once-component",
":resolve-to-not-found-component",
":resolve-twice-component",
":return-arg-test-util-component",
":shebang-echo-arguments-component",
":shebang-infinite-loop-component",
":spawn-child-util-component",
":too-long-shebang-component",
":use-resolve-from-shebang-component",
":use-script-as-interpreter-component",
":use-shebang-from-resolve-component",
]
}
fuchsia_test_component("test-root") {
manifest = "meta/fdio-spawn-tests-root.cml"
test_type = "ctf"
}
fuchsia_test_package("fdio-spawn-tests-package") {
test_components = [
":test-root",
# TODO(b/295025303): Delete when Resolve tests are fixed.
":resolve-test-root",
]
subpackages = [ ":fdio-spawn-tests" ]
}
group("tests") {
testonly = true
deps = [
":fdio-spawn-tests-package",
":fdio-spawn-tests_archive",
]
}