| # 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/config/fuchsia/zircon_images.gni") |
| import("//build/test/test_package.gni") |
| import("//build/testing/environments.gni") |
| |
| executable("bin") { |
| testonly = true |
| output_name = "fdio_spawn_tests" |
| visibility = [ ":*" ] |
| |
| sources = [ |
| "fake_launcher_util.h", |
| "resolve_test.cc", |
| "shebang_test.cc", |
| "spawn_test.cc", |
| "util.cc", |
| "util.h", |
| ] |
| |
| deps = [ |
| "//src/lib/fxl/test:gtest_main", |
| "//third_party/googletest:gtest", |
| "//zircon/public/lib/fdio", |
| "//zircon/public/lib/zx", |
| "//zircon/system/fidl/fuchsia-io:fuchsia-io_llcpp", |
| ] |
| } |
| |
| # A test utility used to test various features of fdio_spawn, extensively in spawn_test.cc. |
| executable("spawn_child_util") { |
| testonly = true |
| visibility = [ ":*" ] |
| |
| sources = [ "spawn_child_util.cc" ] |
| deps = [ |
| "//zircon/public/lib/fdio", |
| "//zircon/public/lib/zx", |
| ] |
| } |
| |
| # A test utility that attempts to use zx_process_create (mimicking a launcher implementation). |
| executable("fake_launcher_util") { |
| testonly = true |
| visibility = [ ":*" ] |
| |
| sources = [ |
| "fake_launcher_util.cc", |
| "fake_launcher_util.h", |
| ] |
| deps = [ |
| "//zircon/public/lib/fdio", |
| "//zircon/public/lib/zx", |
| ] |
| } |
| |
| # A simple test utility that returns the integer value provided to it in its first argument. |
| executable("return_arg_test_util") { |
| testonly = true |
| |
| sources = [ "return_arg_util.cc" ] |
| |
| deps = [ "//src/lib/fxl" ] |
| } |
| |
| # TODO(bryanhenry): This is a copy from //src/sys/dash. Ideally we wouldn't need to copy this target |
| # around to include bin/sh in packages, but get_target_outputs seems to only work on targets in the |
| # current file. See if there's a way to improve this. |
| zircon_extras_manifest("dash_bin_manifest") { |
| visibility = [ ":*" ] |
| manifest = "image" |
| patterns = [ "bin/sh" ] |
| } |
| |
| test_package("fdio_spawn_tests") { |
| deps = [ |
| ":bin", |
| ":dash_bin_manifest", |
| ":fake_launcher_util", |
| ":return_arg_test_util", |
| ":spawn_child_util", |
| ] |
| |
| # This includes bin/sh in the package |
| extra = get_target_outputs(":dash_bin_manifest") |
| |
| binaries = [ |
| { |
| name = "fake_launcher_util" |
| }, |
| { |
| name = "return_arg_test_util" |
| }, |
| { |
| name = "spawn_child_util" |
| }, |
| |
| # These 'binaries' (really just text files with either a "#!resolve" or "#!" directive) are |
| # copied straight out of the source directory into bin/ in the package, but the package template |
| # expects the source path to be relative to root_build_dir, so we first rebase to that. |
| { |
| name = "resolve_once" |
| source = rebase_path("test_bins/resolve_once", root_build_dir) |
| }, |
| { |
| name = "resolve_twice" |
| source = rebase_path("test_bins/resolve_twice", root_build_dir) |
| }, |
| { |
| name = "resolve_infinite_loop" |
| source = rebase_path("test_bins/resolve_infinite_loop", root_build_dir) |
| }, |
| { |
| name = "resolve_to_not_found" |
| source = rebase_path("test_bins/resolve_to_not_found", root_build_dir) |
| }, |
| { |
| name = "echo_arguments.sh" |
| source = rebase_path("test_bins/echo_arguments.sh", root_build_dir) |
| }, |
| { |
| name = "use_script_as_interpreter" |
| source = |
| rebase_path("test_bins/use_script_as_interpreter", root_build_dir) |
| }, |
| { |
| name = "shebang_infinite_loop" |
| source = rebase_path("test_bins/shebang_infinite_loop", root_build_dir) |
| }, |
| { |
| name = "attempt_use_shell_outside_package.sh" |
| source = rebase_path("test_bins/attempt_use_shell_outside_package.sh", |
| root_build_dir) |
| }, |
| { |
| name = "too_long_shebang" |
| source = rebase_path("test_bins/too_long_shebang", root_build_dir) |
| }, |
| { |
| name = "use_resolve_from_shebang" |
| source = rebase_path("test_bins/use_resolve_from_shebang", root_build_dir) |
| }, |
| { |
| name = "use_shebang_from_resolve" |
| source = rebase_path("test_bins/use_shebang_from_resolve", root_build_dir) |
| }, |
| ] |
| |
| tests = [ |
| { |
| name = "fdio_spawn_tests" |
| environments = basic_envs |
| }, |
| ] |
| } |