mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-05 04:06:33 +02:00
Cleanup and merge autotest wrappers.
Review URL: http://codereview.chromium.org/546137
This commit is contained in:
parent
224c7fda0c
commit
a6db82ed3e
@ -11,4 +11,4 @@ KEYS_DIR=ssh_keys
|
||||
ROOT_AUTHKEYS=/root/.ssh/authorized_keys
|
||||
|
||||
mkdir -p /root/.ssh
|
||||
cat ${KEYS_DIR}/* >> ${ROOT_AUTHKEYS}
|
||||
cat ${KEYS_DIR}/*.pub >> ${ROOT_AUTHKEYS}
|
||||
|
||||
27
mod_for_test_scripts/ssh_keys/testing_rsa
Normal file
27
mod_for_test_scripts/ssh_keys/testing_rsa
Normal file
@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEoAIBAAKCAQEAvsNpFdK5lb0GfKx+FgsrsM/2+aZVFYXHMPdvGtTz63ciRhq0
|
||||
Jnw7nln1SOcHraSz3/imECBg8NHIKV6rA+B9zbf7pZXEv20x5Ul0vrcPqYWC44PT
|
||||
tgsgvi8s0KZUZN93YlcjZ+Q7BjQ/tuwGSaLWLqJ7hnHALMJ3dbEM9fKBHQBCrG5H
|
||||
OaWD2gtXj7jp04M/WUnDDdemq/KMg6E9jcrJOiQ39IuTpas4hLQzVkKAKSrpl6MY
|
||||
2etHyoNarlWhcOwitArEDwf3WgnctwKstI/MTKB5BTpO2WXUNUv4kXzA+g8/l1al
|
||||
jIG13vtd9A/IV3KFVx/sLkkjuZ7z2rQXyNKuJwIBIwKCAQA79EWZJPh/hI0CnJyn
|
||||
16AEXp4T8nKDG2p9GpCiCGnq6u2Dvz/u1pZk97N9T+x4Zva0GvJc1vnlST7objW/
|
||||
Y8/ET8QeGSCT7x5PYDqiVspoemr3DCyYTKPkADKn+cLAngDzBXGHDTcfNP4U6xfr
|
||||
Qc5JK8BsFR8kApqSs/zCU4eqBtp2FVvPbgUOv3uUrFnjEuGs9rb1QZ0K6o08L4Cq
|
||||
N+e2nTysjp78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ne
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@ -4,16 +4,15 @@
|
||||
|
||||
# Library for setting up remote access and running remote commands.
|
||||
|
||||
DEFAULT_PRIVATE_KEY="$SRC_ROOT/platform/testing/testing_rsa"
|
||||
DEFAULT_PRIVATE_KEY="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts/\
|
||||
ssh_keys/testing_rsa"
|
||||
|
||||
DEFINE_string remote "" "remote hostname/IP of running Chromium OS instance"
|
||||
DEFINE_string private_key "$DEFAULT_PRIVATE_KEY" \
|
||||
"Private key of root account on remote host"
|
||||
|
||||
function remote_sh() {
|
||||
# Disable strict host checking so that we don't prompt the user when
|
||||
# the host key file is removed and just go ahead and add it.
|
||||
REMOTE_OUT=$(ssh -o StrictHostKeyChecking=no -o \
|
||||
REMOTE_OUT=$(ssh -o StrictHostKeyChecking=no -o \
|
||||
UserKnownHostsFile=$TMP_KNOWN_HOSTS root@$FLAGS_remote "$@")
|
||||
return ${PIPESTATUS[0]}
|
||||
}
|
||||
@ -25,7 +24,7 @@ function remote_sh_allow_changed_host_key() {
|
||||
|
||||
function set_up_remote_access() {
|
||||
if [ -z "$SSH_AGENT_PID" ]; then
|
||||
eval `ssh-agent`
|
||||
eval $(ssh-agent)
|
||||
fi
|
||||
cp $FLAGS_private_key $TMP_PRIVATE_KEY
|
||||
chmod 0400 $TMP_PRIVATE_KEY
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright (c) 2009 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.
|
||||
|
||||
# Script to install and launch autotest.
|
||||
|
||||
. "$(dirname "$0")/common.sh"
|
||||
|
||||
# Script must be run inside the chroot
|
||||
assert_inside_chroot
|
||||
|
||||
set -e
|
||||
|
||||
TEST_RSA_KEY="${GCLIENT_ROOT}/src/platform/testing/testing_rsa"
|
||||
CHROOT_AUTHSOCK_PREFIX="/tmp/chromiumos_test_agent"
|
||||
|
||||
function cleanup {
|
||||
if [ "${TEST_AUTH_SOCKET:0:26}" == ${CHROOT_AUTHSOCK_PREFIX} ]
|
||||
then
|
||||
echo "cleaning up chrooted ssh-agent."
|
||||
kill ${SSH_AGENT_PID}
|
||||
fi
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
# If ssh-agent isn't already running, start one (possibly inside the chroot)
|
||||
if [ ! -n "${SSH_AGENT_PID}" ]
|
||||
then
|
||||
echo "Setting up ssh-agent in chroot for testing."
|
||||
TEST_AUTH_SOCKET=$(mktemp -u ${CHROOT_AUTHSOCK_PREFIX}.XXXX)
|
||||
eval $(/usr/bin/ssh-agent -a ${TEST_AUTH_SOCKET})
|
||||
fi
|
||||
|
||||
# Install authkey for testing
|
||||
chmod 400 $TEST_RSA_KEY
|
||||
/usr/bin/ssh-add $TEST_RSA_KEY
|
||||
|
||||
autoserv_cmd="./server/autoserv $@"
|
||||
echo "running: " ${autoserv_cmd}
|
||||
AUTOTEST_ROOT="/usr/local/autotest"
|
||||
pushd ${AUTOTEST_ROOT} 1> /dev/null
|
||||
${autoserv_cmd}
|
||||
popd 1> /dev/null
|
||||
|
||||
@ -21,8 +21,7 @@ DEFINE_boolean verbose ${FLAGS_FALSE} "Show verbose autoserv output" v
|
||||
DEFINE_boolean update_db ${FLAGS_FALSE} "Put results in autotest database" u
|
||||
DEFINE_string machine_desc "" "Machine description used in database"
|
||||
DEFINE_string build_desc "" "Build description used in database"
|
||||
DEFINE_string results_dir_root "" \
|
||||
"Directory to place individual autoserv results files (default to TMP)"
|
||||
DEFINE_string chroot_dir "${DEFAULT_CHROOT_DIR}" "alternate chroot location" c
|
||||
|
||||
function cleanup() {
|
||||
if [[ $FLAGS_cleanup -eq ${FLAGS_TRUE} ]]; then
|
||||
@ -30,6 +29,11 @@ function cleanup() {
|
||||
else
|
||||
echo "Left temporary files at ${TMP}"
|
||||
fi
|
||||
if [[ -n "${SSH_AGENT_PID}" ]]
|
||||
then
|
||||
kill ${SSH_AGENT_PID} 2>/dev/null
|
||||
unset SSH_AGENT_PID SSH_AUTH_SOCK
|
||||
fi
|
||||
}
|
||||
|
||||
# Returns an error if the test_result_file has text which indicates
|
||||
@ -102,39 +106,39 @@ function main() {
|
||||
|
||||
set -e
|
||||
|
||||
AUTOTEST_DIR="${DEFAULT_CHROOT_DIR}/usr/local/autotest"
|
||||
|
||||
# Set global TMP for remote_access.sh's sake
|
||||
TMP=$(mktemp -d /tmp/run_remote_tests.XXXX)
|
||||
|
||||
if [[ -z "${FLAGS_results_dir_root}" ]]; then
|
||||
FLAGS_results_dir_root="${TMP}"
|
||||
fi
|
||||
|
||||
rm -f "${FLAGS_output_file}"
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
cp -r "${SRC_ROOT}/third_party/autotest/files" "${TMP}/autotest"
|
||||
|
||||
# Check for installed autotest.
|
||||
local autoserv="${AUTOTEST_DIR}/server/autoserv"
|
||||
if [[ ! -f "${autoserv}" ]]; then
|
||||
echo "Cannot find autotest in build dir. Run build_autotest.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local control_files_to_run=""
|
||||
local any_failures=0
|
||||
|
||||
# Now search for tests which unambiguously include the given identifier
|
||||
local search_path=$(echo ${TMP}/autotest/{client,server}/{tests,site_tests})
|
||||
local search_path=$(echo ${AUTOTEST_DIR}/{client,server}/{tests,site_tests})
|
||||
for test_request in $FLAGS_ARGV; do
|
||||
test_request=$(remove_quotes "${test_request}")
|
||||
! finds=$(find ${search_path} -type f -name control | \
|
||||
egrep "${test_request}")
|
||||
if [[ -z "${finds}" ]]; then
|
||||
echo "Can not find match for ${test_request}"
|
||||
any_failures=1
|
||||
continue
|
||||
exit 1
|
||||
fi
|
||||
local matches=$(echo "${finds}" | wc -l)
|
||||
if [[ ${matches} -gt 1 ]]; then
|
||||
echo "${test_request} is ambiguous:"
|
||||
echo "${finds}"
|
||||
any_failures=1
|
||||
continue
|
||||
exit 1
|
||||
fi
|
||||
for i in $(seq 1 $FLAGS_iterations); do
|
||||
control_files_to_run="${control_files_to_run} '${finds}'"
|
||||
@ -149,8 +153,6 @@ function main() {
|
||||
if [[ -z "${FLAGS_machine_desc}" ]]; then
|
||||
FLAGS_machine_desc="${FLAGS_remote}"
|
||||
fi
|
||||
|
||||
local autoserv="${TMP}/autotest/server/autoserv"
|
||||
|
||||
for control_file in ${control_files_to_run}; do
|
||||
# Assume a line starts with TEST_TYPE =
|
||||
@ -169,20 +171,15 @@ function main() {
|
||||
echo "Running ${type} test ${control_file}"
|
||||
local short_name=$(basename $(dirname "${control_file}"))
|
||||
local start_time=$(date '+%s')
|
||||
local results_dir_name="${short_name},${FLAGS_machine_desc},${start_time}"
|
||||
local results_dir="${FLAGS_results_dir_root}/${results_dir_name}"
|
||||
local results_dir="${TMP}/${short_name},${FLAGS_machine_desc},${start_time}"
|
||||
rm -rf "${results_dir}"
|
||||
local verbose=""
|
||||
if [[ ${FLAGS_verbose} -eq $FLAGS_TRUE ]]; then
|
||||
verbose="--verbose"
|
||||
fi
|
||||
if ! ${autoserv} -m "${FLAGS_remote}" "${option}" "${control_file}" \
|
||||
-r "${results_dir}" ${verbose}; then
|
||||
echo "Autoserv run of ${control_file} failed." | \
|
||||
tee -a "${FLAGS_output_file}"
|
||||
any_failures=1
|
||||
continue
|
||||
fi
|
||||
|
||||
${autoserv} -m "${FLAGS_remote}" "${option}" "${control_file}" \
|
||||
-r "${results_dir}" ${verbose}
|
||||
local test_status="${results_dir}/status"
|
||||
local test_result_dir="${results_dir}/${short_name}"
|
||||
local keyval_file="${test_result_dir}/results/keyval"
|
||||
@ -214,8 +211,6 @@ function main() {
|
||||
done
|
||||
|
||||
echo "Output stored to ${FLAGS_output_file}"
|
||||
|
||||
return ${any_failures}
|
||||
}
|
||||
|
||||
main $@
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user