| #!/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. |
| |
| ### run host tests |
| |
| ## |
| ## Usage: fx run-host-tests [-z] [host test names ...] |
| ## 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. |
| ## If no host test names are provided, then all available |
| ## host tests will be run. |
| ## |
| |
| set -o errexit |
| set -o pipefail |
| |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/lib/vars.sh |
| fx-config-read |
| |
| ARGS=() |
| TEST_NAMES=() |
| function main { |
| while [[ -n "$1" ]]; do |
| case "$1" in |
| -v) ARGS+=("-v");; |
| -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_BUILD_DIR}/host_tests" |
| fx-command-run build-zircon "-v" |
| else |
| host_test_dir="${FUCHSIA_BUILD_DIR}/host_tests" |
| # If test names are supplied, rebuild the associated tests; else rebuild |
| # everything under the GN 'host_tests' label. |
| if [[ -n "$TEST_NAMES" ]]; then |
| build_targets=(${TEST_NAMES[@]/#/host_tests/}) |
| else |
| build_targets=("./build/gn:host_tests") |
| fi |
| fx-command-run build "${build_targets[@]}" |
| fi |
| |
| runtests_cmd=("${ZIRCON_TOOLS_DIR}/runtests" "${ARGS[@]}") |
| |
| 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}" -- "$@" |
| } |
| |
| main "$@" |