blob: fea93cea9eafc052d8fdefd4851375fabf37b381 [file] [log] [blame]
#!/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
function main {
if [[ $# -gt 0 ]] && [[ $1 = "-z" ]]; then
host_test_dir="${ZIRCON_BUILD_DIR}/host_tests"
fx-command-run build-zircon "-v"
shift
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.
[[ $# -gt 0 ]] && build_targets="${@/#/host_tests/}" ||
build_targets="./build/gn:host_tests"
fx-command-run build "${build_targets}"
fi
runtests_cmd="${ZIRCON_TOOLS_DIR}/runtests -v"
if [[ $# -gt 0 ]]; then
# Comma-separated list of host test names to filter by.
local IFS=","
filtered_host_tests="'$*'"
runtests_cmd="${runtests_cmd} -t ${filtered_host_tests}"
fi
runtests_cmd="${runtests_cmd} ${host_test_dir}"
eval "${runtests_cmd}"
}
main "$@"