OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. |
| 6 |
| 7 # Script to install and launch autotest. |
| 8 |
| 9 . "$(dirname "$0")/common.sh" |
| 10 |
| 11 # Script must be run inside the chroot |
| 12 assert_inside_chroot |
| 13 |
| 14 DEFINE_string client_control "" "client test case to execute" "c" |
| 15 DEFINE_boolean force false "force reinstallation of autotest" "f" |
| 16 DEFINE_string machine "" "if present, execute autotest on this host." "m" |
| 17 DEFINE_string test_key "${GCLIENT_ROOT}/src/platform/testing/testing_rsa" \ |
| 18 "rsa key to use for autoserv" "k" |
| 19 |
| 20 # More useful help |
| 21 FLAGS_HELP="usage: $0 [flags]" |
| 22 |
| 23 # parse the command-line |
| 24 FLAGS "$@" || exit 1 |
| 25 eval set -- "${FLAGS_ARGV}" |
| 26 set -e |
| 27 |
| 28 AUTOTEST_CHROOT_DEST="/usr/local/autotest" |
| 29 AUTOTEST_SRC="${GCLIENT_ROOT}/src/third_party/autotest/files" |
| 30 echo $AUTOTEST_SRC |
| 31 |
| 32 CHROOT_AUTHSOCK_PREFIX="/tmp/chromiumos_test_agent" |
| 33 |
| 34 function cleanup { |
| 35 if [ "${TEST_AUTH_SOCKET:0:26}" == ${CHROOT_AUTHSOCK_PREFIX} ] |
| 36 then |
| 37 echo "cleaning up chrooted ssh-agent." |
| 38 kill ${SSH_AGENT_PID} |
| 39 fi |
| 40 } |
| 41 |
| 42 trap cleanup EXIT |
| 43 |
| 44 # Copy a local "installation" of autotest into the chroot, to avoid |
| 45 # polluting the src dir with tmp files, results, etc. |
| 46 # TODO: use rsync to ensure we don't get stuck with an old install. |
| 47 if [ 1 != ${FLAGS_force} ] || [ ! -f "${AUTOTEST_CHROOT_DEST}/server/autosrv" ] |
| 48 then |
| 49 echo -n "Installing Autotest... " |
| 50 sudo mkdir -p "${AUTOTEST_CHROOT_DEST}" |
| 51 sudo cp -rp ${AUTOTEST_SRC}/* ${AUTOTEST_CHROOT_DEST} |
| 52 echo "done." |
| 53 else |
| 54 echo "Autotest found in chroot, skipping copy." |
| 55 fi |
| 56 |
| 57 # Add all third_party and system tests to site_tests. |
| 58 for type in client server |
| 59 do |
| 60 echo -n "Adding ${type}_tests into autotest's ${type}/site_tests... " |
| 61 sudo cp -rp ${GCLIENT_ROOT}/src/platform/testing/${type}_tests/* \ |
| 62 ${AUTOTEST_CHROOT_DEST}/${type}/site_tests/ |
| 63 done |
| 64 |
| 65 # If ssh-agent isn't already running, start one (possibly inside the chroot) |
| 66 if [ ! -n "${SSH_AGENT_PID}" ] |
| 67 then |
| 68 echo "Setting up ssh-agent in chroot for testing." |
| 69 TEST_AUTH_SOCKET=$(mktemp -u ${CHROOT_AUTHSOCK_PREFIX}.XXXX) |
| 70 eval $(/usr/bin/ssh-agent -a ${TEST_AUTH_SOCKET}) |
| 71 fi |
| 72 |
| 73 # Install authkey for testing |
| 74 |
| 75 chmod 400 $FLAGS_test_key |
| 76 /usr/bin/ssh-add $FLAGS_test_key 2> /dev/null |
| 77 |
| 78 if [ -n "${FLAGS_machine}" ] |
| 79 then |
| 80 CLIENT_CONTROL_FILE=${FLAGS_client_control} |
| 81 # run only a specific test/suite if requested |
| 82 if [ ! -n "${CLIENT_CONTROL_FILE}" ] |
| 83 then |
| 84 # Generate meta-control file to run all existing site tests. |
| 85 CLIENT_CONTROL_FILE=\ |
| 86 "${AUTOTEST_CHROOT_DEST}/client/site_tests/AllTests/control" |
| 87 echo "No control file specified. Running all tests." |
| 88 fi |
| 89 # Kick off autosrv for specified test |
| 90 autoserv_cmd="${AUTOTEST_CHROOT_DEST}/server/autoserv \ |
| 91 -m ${FLAGS_machine} \ |
| 92 -c ${CLIENT_CONTROL_FILE}" |
| 93 echo "running autoserv: " ${autoserv_cmd} |
| 94 ${autoserv_cmd} |
| 95 else |
| 96 echo "To execute autotest manually: |
| 97 eval \$(ssh-agent) # start ssh-agent |
| 98 ssh-add $FLAGS_test_key # add test key to agent |
| 99 # Then execute autoserv: |
| 100 $autoserv_cmd" |
| 101 fi |
| 102 |
OLD | NEW |