blob: 1e1347deeaff7609b59c100b00657608713ebfe0 [file] [log] [blame]
#!/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 $?
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/updates.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
;;
-*)
fx-error "first given argument \"$1\" looks like a flag, a package name must be supplied before all flags."
exit 1
;;
*)
target="$1"
shift
esac
check-for-amber-server || return -1
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 "$@"