| #!/bin/bash |
| # Copyright 2018 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. |
| |
| ### build and run tests on host |
| |
| ## |
| ## Usage: fx run-host-tests [-z] [host test names ...] [-- [test runner flags]] |
| ## Builds and runs the given host tests. |
| ## With "-z" passed, only Zircon tests will be run - and |
| ## without it only tests from Garnet and above. |
| ## Test runner flags can typically be --gtest_filter=TestSuiteName.TestName |
| ## to restrict to a particular test or set of tests. |
| ## |
| |
| set -o errexit |
| set -o pipefail |
| |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? |
| fx-config-read |
| |
| TEST_NAMES=() |
| function main { |
| while [[ -n "$1" ]]; do |
| case "$1" in |
| -z) ZIRCON=1 ;; |
| # break at bare double dash |
| # allow passing args to runtests |
| --) shift |
| break |
| ;; |
| *) TEST_NAMES+=("$1");; |
| esac |
| shift |
| done |
| |
| if [[ $ZIRCON -eq 1 ]]; then |
| host_test_dir="${ZIRCON_BUILDROOT}/host_tests" |
| fx-command-run build "-v" |
| runtests_cmd=("${ZIRCON_TOOLS_DIR}/runtests") |
| |
| if [[ -n "$TEST_NAMES" ]]; then |
| # Comma-separated list of host test names to filter by. |
| IFS="," runtests_cmd+=("-t" "${TEST_NAMES[@]}") |
| fi |
| # remaining arguments after -- are passed to test runner |
| "${runtests_cmd[@]}" "${host_test_dir}" -- "$@" |
| else |
| "${FUCHSIA_DIR}/tools/devshell/contrib/exec-host-tests"\ |
| "--manifest" "${FUCHSIA_BUILD_DIR}/tests.json"\ |
| "--names" "${TEST_NAMES[@]}"\ |
| "--build-dir" "${FUCHSIA_BUILD_DIR}"\ |
| "--ninja" "${PREBUILT_NINJA}" \ |
| "--"\ |
| "$@" |
| fi |
| } |
| |
| main "$@" |