| # Copyright 2020 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. |
| |
| # Tests for the bash scripts in the GN SDK. |
| |
| import("//build/go/go_test.gni") |
| import("//scripts/sdk/gn/test/build/host_script_test.gni") |
| |
| group("tests") { |
| testonly = true |
| deps = [ ":gn_sdk_script_tests($host_toolchain)" ] |
| } |
| |
| # This is the list of test scripts that should be run to |
| # test the bash f* scripts. |
| test_scripts = [ |
| "fconfig-test.sh", |
| "fcp-test.sh", |
| "fdevtools-test.sh", |
| "femu-exec-wrapper-test.sh", |
| "femu-test.sh", |
| "fpave-test.sh", |
| "fpublish-test.sh", |
| "fserve-remote-test.sh", |
| "fserve-test.sh", |
| "fssh-test.sh", |
| "fuchsia-common-tests.sh", |
| "femu-osx-test.sh", |
| ] |
| |
| # Copies the files needed for the tests to the out dir |
| # This stages the data and builds the metadata needed to |
| # have these files included in the test runtime deps. |
| # |
| # The datasets are copied to the data_path directory. |
| # The source_base_dir must be a prefix of the files |
| # being copied. The target_base dir is the destination |
| # directory within the data_path. |
| # |
| # There are multiple datasets, one for each unique source_base_dir. |
| host_script_test_data("gn_sdk_bash_tests") { |
| data_path = "gn_sdk_bash_tests" |
| datasets = [ |
| { |
| source_base_dir = "//scripts/sdk/gn/testdata/meta" |
| target_base_dir = "scripts/sdk/gn/testdata/meta" |
| files = [ "//scripts/sdk/gn/testdata/meta/manifest.json" ] |
| }, |
| { |
| source_base_dir = "//scripts/sdk/gn/base/bin" |
| target_base_dir = "scripts/sdk/gn/base/bin" |
| files = [ |
| "//scripts/sdk/gn/base/bin/fconfig.sh", |
| "//scripts/sdk/gn/base/bin/fcp.sh", |
| "//scripts/sdk/gn/base/bin/fdevtools.sh", |
| "//scripts/sdk/gn/base/bin/femu-exec-wrapper.sh", |
| "//scripts/sdk/gn/base/bin/femu.sh", |
| "//scripts/sdk/gn/base/bin/fpave.sh", |
| "//scripts/sdk/gn/base/bin/fpublish.sh", |
| "//scripts/sdk/gn/base/bin/fserve-remote.sh", |
| "//scripts/sdk/gn/base/bin/fserve.sh", |
| "//scripts/sdk/gn/base/bin/fssh.sh", |
| "//scripts/sdk/gn/base/bin/fuchsia-common.sh", |
| "//scripts/sdk/gn/base/bin/devshell/lib/image_build_vars.sh", |
| ] |
| }, |
| { |
| source_base_dir = "//scripts/sdk/gn/bash_tests" |
| target_base_dir = "scripts/sdk/gn/bash_tests" |
| files = [ |
| "//scripts/sdk/gn/bash_tests/gn-bash-test-lib.sh", |
| "//scripts/sdk/gn/bash_tests/script_runner.sh", |
| ] |
| foreach(f, test_scripts) { |
| files += [ "//scripts/sdk/gn/bash_tests/$f" ] |
| } |
| }, |
| { |
| source_base_dir = "//tools/devshell/tests/lib" |
| target_base_dir = "tools/devshell/tests/lib" |
| files = [ |
| "//tools/devshell/tests/lib/bash_test_framework.sh", |
| "//tools/devshell/tests/lib/fuchsia-mock.sh", |
| "//tools/devshell/tests/lib/mock.sh", |
| ] |
| }, |
| { |
| source_base_dir = "//scripts" |
| target_base_dir = "scripts" |
| files = [ "//scripts/start-unsecure-internet.sh" ] |
| }, |
| { |
| source_base_dir = "//tools/devshell" |
| target_base_dir = "tools/devshell" |
| files = [ |
| "//tools/devshell/emu", |
| "//tools/devshell/lib/fvm.sh", |
| "//tools/devshell/lib/emu-ifup-macos.sh", |
| "//tools/devshell/tests/subcommands/data/fx_remote_test/verify-default-keys.sh", |
| ] |
| }, |
| { |
| source_base_dir = target_out_dir |
| target_base_dir = "scripts/sdk/gn/bash_tests" |
| files = [ "${target_out_dir}/run_all_bash_tests_driver.sh" ] |
| }, |
| ] |
| data_deps = [ ":run_all_bash_tests_driver" ] |
| } |
| |
| generated_file("run_all_bash_tests_driver") { |
| outputs = [ "${target_out_dir}/run_all_bash_tests_driver.sh" ] |
| contents = read_file("script_header.sh", "list lines") |
| foreach(s, test_scripts) { |
| contents += [ "script_runner $s" ] |
| } |
| } |
| |
| host_script_test("gn_sdk_script_tests") { |
| # Script path is relative to $testroot |
| test_root = "gn_sdk_bash_tests" |
| test_script = |
| "gn_sdk_bash_tests/scripts/sdk/gn/bash_tests/run_all_bash_tests_driver.sh" |
| data_deps = [ ":gn_sdk_bash_tests" ] |
| } |