| #!/bin/bash | |
| # 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. | |
| #### CATEGORY=Test | |
| ### Entry point for all Fuchsia tests (host, target and end-to-end) | |
| ## Usage: fx test [testName ...] | |
| ## | |
| ## This is an incomplete list of options. Run 'fx test --help' for the complete set of options. | |
| ## Options: | |
| ## -h, --help | |
| ## --test-filter Runs specific test cases in v2 suite. Can be specified multiple | |
| ## times to pass in multiple patterns. | |
| ## example: --test-filter glob1 --test-filter glob2 | |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? | |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/dart_utils.sh || exit $? | |
| fx-config-read | |
| # Device discovery and building missing symbolizer are slow operations that | |
| # don't need to happen when the user requests specific operations, like help and | |
| # info. | |
| skip_slow_setup=false | |
| for arg in "$@"; do | |
| if [[ "$arg" == "--help" || "$arg" == "-h" || "$arg" == "--info" || "$arg" == "--dry" ]]; then | |
| skip_slow_setup=true | |
| break | |
| fi | |
| if [[ "$arg" == "--" ]]; then | |
| break | |
| fi | |
| done | |
| if ! $skip_slow_setup; then | |
| # force build of required symbolizer host tools if they don't exist: | |
| fx-command-run host-tool --print symbolizer > /dev/null | |
| fx-command-run host-tool --print symbol-index > /dev/null | |
| # initialize some variables required for E2E tests: | |
| export FUCHSIA_DEVICE_ADDR="$(get-fuchsia-device-addr)" | |
| if [[ "$FUCHSIA_DEVICE_ADDR" == "::1" && -z "$SL4F_HTTP_PORT" ]]; then | |
| # Device addr is localhost, assume that means that ports were forwarded with | |
| # fx serve-remote from a remote workstation/laptop with a device attached. | |
| export SL4F_HTTP_PORT=9080 | |
| fi | |
| port="$(get-device-ssh-port)" | |
| if [[ -n "${port}" ]]; then | |
| export FUCHSIA_SSH_PORT="${port}" | |
| fi | |
| FUCHSIA_SSH_KEY="$(get-ssh-privkey)" || exit $? | |
| export FUCHSIA_SSH_KEY | |
| export FUCHSIA_TEST_OUTDIR="${FUCHSIA_OUT_DIR}/test_out/$(date +'%F-%H:%M:%S')" | |
| fi | |
| args=() | |
| # TODO(fxbug.dev/53267): Using tput colors is more reliable than letting Dart do its | |
| # own terminal detection. Remove once Dart can do its own detection more | |
| # robustly. | |
| if [[ ! -t 1 ]] || ! tput colors >/dev/null 2>&1; then | |
| args+=("--simple") | |
| fi | |
| run-dart-tool fxtest "${args[@]}" "$@" |