diff --git a/autotest_run.sh b/autotest_run.sh new file mode 100755 index 0000000000..17774074e2 --- /dev/null +++ b/autotest_run.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +# Copyright (c) 2010 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 is intended as a wrapper to execute autotest tests for a given +# board. + +# Load common constants. This should be the first executable line. +# The path to common.sh should be relative to your script's location. +. "$(dirname "$0")/common.sh" + +# Script must be run inside the chroot +restart_in_chroot_if_needed $* +get_default_board + +DEFINE_string board "${DEFAULT_BOARD}" \ + "The board to run tests for." + +FLAGS_HELP="usage: $0 " +FLAGS "$@" || exit 1 +eval set -- "${FLAGS_ARGV}" + +# Define a directory which will not be cleaned by portage automatically. So we +# could achieve incremental build between two autoserv runs. +BUILD_RUNTIME="/build/${FLAGS_board}/usr/local/autotest/" + +# Hack: set the CHROMEOS_ROOT variable by hand here +CHROMEOS_ROOT=/home/${USER}/trunk/ + +# Ensure the configures run by autotest pick up the right config.site +CONFIG_SITE=/usr/share/config.site + +[ -z "${FLAGS_board}" ] && \ + die "You must specify --board=" + +function setup_ssh() { + eval $(ssh-agent) > /dev/null + # TODO(jrbarnette): This is a temporary hack, slated for removal + # before it was ever created. It's a bug, and you should fix it + # right away! + chmod 400 \ + ${CHROMEOS_ROOT}/src/scripts/mod_for_test_scripts/ssh_keys/testing_rsa + ssh-add \ + ${CHROMEOS_ROOT}/src/scripts/mod_for_test_scripts/ssh_keys/testing_rsa +} + +function teardown_ssh() { + ssh-agent -k > /dev/null +} + +src_test() { + # TODO: These places currently need to be writeable but shouldn't be + sudo chmod a+w ${BUILD_RUNTIME}/server/{tests,site_tests} + + setup_ssh + cd "${BUILD_RUNTIME}" + + local args=() + if [[ -n ${AUTOSERV_TEST_ARGS} ]]; then + args=("-a" "${AUTOSERV_TEST_ARGS}") + fi + + local timestamp=$(date +%Y-%m-%d-%H.%M.%S) + + # Do not use sudo, it'll unset all your environment + LOGNAME=${USER} ./server/autoserv -r /tmp/results.${timestamp} \ + ${AUTOSERV_ARGS} "${args[@]}" + + teardown_ssh +} + +src_test diff --git a/run_remote_tests.sh b/run_remote_tests.sh index 9df83a5b6c..babbbdceb0 100755 --- a/run_remote_tests.sh +++ b/run_remote_tests.sh @@ -271,20 +271,25 @@ function main() { info "Running chrome autotest ${control_file}" fi - local autoserv_test_args="${FLAGS_args}" - if [ -n "${autoserv_test_args}" ]; then - autoserv_test_args="-a \"${autoserv_test_args}\"" - fi - local autoserv_args="-m ${FLAGS_remote} --ssh-port ${FLAGS_ssh_port} \ + export AUTOSERV_TEST_ARGS="${FLAGS_args}" + export AUTOSERV_ARGS="-m ${FLAGS_remote} \ + --ssh-port ${FLAGS_ssh_port} \ ${option} ${control_file} -r ${results_dir} ${verbose}" if [ ${FLAGS_build} -eq ${FLAGS_FALSE} ]; then - pushd ${autotest_dir} > /dev/null - sudo chmod a+w server/{tests,site_tests} - ./server/autoserv ${autoserv_args} ${autoserv_test_args} - popd > /dev/null + cat > "${TMP}/run_test.sh" <&2 else cp "${BUILD_DIR}/environment" "${TMP}/run_test.sh" GRAPHICS_BACKEND=${GRAPHICS_BACKEND:-OPENGL} + if [ -n "${AUTOSERV_TEST_ARGS}" ]; then + AUTOSERV_TEST_ARGS="-a \"${AUTOSERV_TEST_ARGS}\"" + fi cat >> "${TMP}/run_test.sh" <