| #!/bin/bash | |
| # Copyright 2017 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 a test package and run on target. | |
| ### PKG_TARGET is fully qualified or under fuchsia-pkg://fuchsia.com/ | |
| ## usage: fx run-test PKG_TARGET [runtests flags] | |
| ## Builds the specified test package (e.g., appmgr_integration_tests), copies it to the | |
| ## target, and executes it. | |
| ## | |
| ## If using this command, please run 'fx build' again before paving your device | |
| ## because 'fx build updates' used by this script does not build images so it | |
| ## can leave paver in weird state. | |
| ## | |
| ## Arguments: | |
| ## All arguments are passed directly to `runtests`, see `fx run-test -h` for all flags. | |
| set -e | |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? | |
| fx-config-read | |
| function main { | |
| if [[ $# -lt 1 ]]; then | |
| fx-command-help | |
| exit 1 | |
| fi | |
| case "$1" in | |
| -h|--help) | |
| fx-command-help | |
| echo -e >&2 "\nRuntests help follows:" | |
| fx-command-run shell runtests -h | |
| exit 0 | |
| ;; | |
| -*) | |
| echo >&2 "error: first given argument \"$1\" looks like a flag, a package name must be supplied before all flags." | |
| exit 1 | |
| ;; | |
| *) | |
| target="$1" | |
| shift | |
| esac | |
| if [[ -z "$(pgrep -f "amber-files/repository")" ]]; then | |
| echo "WARNING: It looks like amber-srv is not running." | |
| echo "WARNING: You probably need to start \"fx serve-updates\"" | |
| exit 1 | |
| fi | |
| echo -e "Building ..." | |
| # build all packages as there is no way to only build one and push it to | |
| # update repository. | |
| fx-command-run build updates | |
| echo -e "\nPush package to device" | |
| fx-command-run push-package "${target}" | |
| fx-command-run shell runtests "pkgfs/packages/${target}/0/test" "$@" | |
| } | |
| main "$@" |