| #!/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. | |
| #### CATEGORY=Run, inspect and debug | |
| #### DEPRECATED | |
| ### build a test package and run on target. | |
| ## usage: fx run-test PKG_TARGET [runtests flags] | |
| ## | |
| ## This command is being deprecated in favor of `fx test`. Read more at: | |
| ## https://fuchsia.dev/fuchsia-src/development/testing/running_tests_as_components#converting_from_run-test_or_run-host-tests | |
| ## | |
| ## Builds the update package group, updates the device as necessary, and then | |
| ## executes the test as specified by [runtests flags] (or all tests in | |
| ## PKG_TARGET if no flags are given). | |
| ## | |
| ## Arguments: | |
| ## PKG_TARGET A package name as appears in `fx list-packages` | |
| ## All later arguments are passed directly to `runtests`, see `fx run-test -h` for all flags. | |
| ## | |
| ## Known Bugs: | |
| ## PKG-592: After run-test, performing a pave without executing 'fx build' | |
| ## results in "appmgr not started after 20s", as this command only builds new | |
| ## packages, it avoids creating new paver artifacts, as such, a pave without a | |
| ## fresh build produces a system with inconsistent state. | |
| 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 | |
| # Determine if the given package name ($1) is in the base package list | |
| function is-in-base { | |
| grep "^$1$" "${FUCHSIA_BUILD_DIR}/base_packages.list" > /dev/null | |
| } | |
| 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 | |
| fx-warn "This command is being deprecated in favor of \`fx test\`. Read more at:\n - https://fuchsia.dev/fuchsia-src/development/testing/running_tests_as_components#converting_from_run-test_or_run-host-tests\n" | |
| check-for-amber-server || return 1 | |
| if is-in-base "${target}"; then | |
| fx-warn "As ${target} is in 'base'. An OTA will follow." | |
| fi | |
| echo >&2 "Building ..." | |
| # build all packages as there is no way to only build one and push it to | |
| # update repository. | |
| fx-command-run build updates | |
| # TODO: once incremental workflow lands, `fx-command-run update` should | |
| # instead always execute. | |
| if is-in-base "${target}"; then | |
| echo >&2 "Package ${target} is in 'base', performing system update..." | |
| fx-command-run update | |
| echo >&2 "System update complete, waiting for device to return" | |
| fx-command-run wait | |
| else | |
| echo >&2 "Updating ${target} cache on device" | |
| if ! fx-command-run push-package "${target}"; then | |
| return 2 | |
| fi | |
| fi | |
| # TODO: remove reliance on pkgfs/packages. | |
| fx-command-run shell runtests "pkgfs/packages/${target}/0/test" "$@" 2>&1 \ | |
| | fx-command-run symbolize | |
| } | |
| main "$@" |