blob: 06fa0215185feaab09012dbc716cbc0803fa59c5 [file] [log] [blame] [edit]
#!/bin/bash
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This script requires that you run build_packages first.
# Special because this can only run inside the chroot.
if [ ! -r /mnt/host/source/src/scripts/common.sh ]; then
echo "Must run within chroot" >&2
exit 1
fi
. /mnt/host/source/src/scripts/common.sh
# Flags
DEFINE_string board "${DEFAULT_BOARD}" \
"Target board of DUT running the tests"
DEFINE_boolean smoke "${FLAGS_FALSE}" \
"Run a minimal set of tests for sanity"
DEFINE_boolean commit "${FLAGS_FALSE}" \
"Run the tests required to pass the Commit Queue"
DEFINE_boolean canary "${FLAGS_FALSE}" \
"Run all tests required for canary builds to pass"
DEFINE_boolean labqual "${FLAGS_FALSE}" \
"Run the BVT tests required for lab qualification"
DEFINE_boolean debug "${FLAGS_FALSE}" \
"Print commands that would've been run without doing anything"
# These options only matter if we're using Servo, which only
# happens when --labqual is specified.
DEFINE_string servo_host "" \
"When running servo tests, specifies the host running servod"
DEFINE_string servo_port "" \
"When running servo tests, specifies the port for contacting servod"
# Parse command line; die on errors
FLAGS_HELP="usage: $(basename $0) [flags] <hostname-or-ipaddr>"
FLAGS "${@}" || exit 1
eval set -- "${FLAGS_ARGV}"
set -e
if [ -z "${FLAGS_board}" ]; then
die "--board required"
fi
if [ $# -ne 1 ]; then
die "Must specify exactly one DUT"
fi
DUT="$1"
OPTIONS=( --board="${FLAGS_board}" )
TESTS=( suite:bvt-{inline,cq,perbuild,labqual} )
SUITE_CHECK=0
if [ ${FLAGS_smoke} -eq ${FLAGS_TRUE} ]; then
SUITE_CHECK=$(( SUITE_CHECK + 1 ))
TESTS=( suite:bvt-inline )
fi
if [ ${FLAGS_commit} -eq ${FLAGS_TRUE} ]; then
SUITE_CHECK=$(( SUITE_CHECK + 1 ))
TESTS=( suite:bvt-{inline,cq} )
fi
if [ ${FLAGS_canary} -eq ${FLAGS_TRUE} ]; then
SUITE_CHECK=$(( SUITE_CHECK + 1 ))
# Use the default tests.
fi
if [ ${FLAGS_labqual} -eq ${FLAGS_TRUE} ]; then
SUITE_CHECK=$(( SUITE_CHECK + 1 ))
TESTS=( suite:labqual)
# Handle Servo options for the lab qualification tests.
if [ -n "${FLAGS_servo_host}" ]; then
SERVO_ARGS="--args=servo_host=${FLAGS_servo_host}"
if [ -n "${FLAGS_servo_port}" ]; then
SERVO_ARGS="${SERVO_ARGS} servo_port=${FLAGS_servo_port}"
fi
OPTIONS+=( "${SERVO_ARGS}" )
elif [ -n "${FLAGS_servo_port}" ]; then
OPTIONS+=( "--args=servo_port=${FLAGS_servo_port}" )
fi
fi
if [ ${SUITE_CHECK} -gt 1 ]; then
die "can specify at most one of --smoke --commit --canary or --labqual"
fi
DEBUG=
if [ ${FLAGS_debug} -eq ${FLAGS_TRUE} ]; then
DEBUG=echo
fi
$DEBUG test_that "${OPTIONS[@]}" "$DUT" "${TESTS[@]}"
AUTOTEST_STATUS=$?
# Run a subset of Tast tests for qualifying a model before lab deployment.
$DEBUG tast -verbose run -build=false "$DUT" '(!disabled && "group:labqual")'
TAST_STATUS=$?
if [ ${AUTOTEST_STATUS} -ne 0 ] || [ ${TAST_STATUS} -ne 0 ]; then
die "Autotest exited with ${AUTOTEST_STATUS}; Tast exited with ${TAST_STATUS}"
fi