From 8a4af3a999bd36fd0aa8ae367913dab0770f6206 Mon Sep 17 00:00:00 2001 From: Ken Mixter Date: Fri, 5 Feb 2010 19:22:35 -0800 Subject: [PATCH] Make run_remote_tests also update the chroot autotest Don't punish the good people trying to write python-only autotests by requiring them to sit through a long build_autotest run to test every change. run_remote_tests and build_autotest both update the chroot copy now. Review URL: http://codereview.chromium.org/578027 --- autotest_lib.sh | 18 ++++++++++++++++++ build_autotest.sh | 8 ++------ run_remote_tests.sh | 18 ++++++++++-------- 3 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 autotest_lib.sh diff --git a/autotest_lib.sh b/autotest_lib.sh new file mode 100644 index 0000000000..ac7be63156 --- /dev/null +++ b/autotest_lib.sh @@ -0,0 +1,18 @@ +# 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. +# +# Provides common commands for dealing running/building autotest + +# Populates the chroot's /usr/local/autotest directory based on +# the given source directory. +# args: +# $1 - original source directory +function update_chroot_autotest() { + local original=$1 + echo "Updating chroot Autotest from ${original}..." + local autotest_dir="${DEFAULT_CHROOT_DIR}/usr/local/autotest" + sudo mkdir -p "${autotest_dir}" + sudo chmod 777 "${autotest_dir}" + cp -fpru ${original}/{client,conmux,server,tko,utils,global_config.ini,shadow_config.ini} ${autotest_dir} +} diff --git a/build_autotest.sh b/build_autotest.sh index 632eb608b2..6e81a04d0a 100755 --- a/build_autotest.sh +++ b/build_autotest.sh @@ -14,6 +14,7 @@ # mod_image_for_test.sh. . "$(dirname "$0")/common.sh" +. "$(dirname "$0")/autotest_lib.sh" # Script must be run inside the chroot assert_inside_chroot @@ -37,12 +38,7 @@ AUTOTEST_DEST="/usr/local/autotest" # Copy a local "installation" of autotest into the chroot, to avoid # polluting the src dir with tmp files, results, etc. -echo "Installing Autotest..." -sudo mkdir -p ${AUTOTEST_DEST} -sudo chmod 777 ${AUTOTEST_DEST} -cd ${CHROOT_TRUNK_DIR}/src/third_party/autotest/files -cp -fpru {client,conmux,server,tko,utils,global_config.ini,shadow_config.ini} \ - ${AUTOTEST_DEST} +update_chroot_autotest "${CHROOT_TRUNK_DIR}/src/third_party/autotest/files" # Create python package init files for top level test case dirs. function touchInitPy() { diff --git a/run_remote_tests.sh b/run_remote_tests.sh index b6502d09b4..4801b8a556 100755 --- a/run_remote_tests.sh +++ b/run_remote_tests.sh @@ -10,6 +10,7 @@ # The path to common.sh should be relative to your script's location. . "$(dirname $0)/common.sh" +. "$(dirname $0)/autotest_lib.sh" . "$(dirname $0)/remote_access.sh" DEFAULT_OUTPUT_FILE=test-output-$(date '+%Y%m%d.%H%M%S') @@ -103,7 +104,7 @@ function main() { set -e - AUTOTEST_DIR="${DEFAULT_CHROOT_DIR}/usr/local/autotest" + local 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) @@ -112,17 +113,18 @@ function main() { trap cleanup EXIT - # 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 + # Always copy into installed autotest directory. This way if a user + # is just modifying scripts, they take effect without having to wait + # for the laborious build_autotest.sh command. + local original="${GCLIENT_ROOT}/src/third_party/autotest/files" + update_chroot_autotest "${original}" + + local autoserv="${autotest_dir}/server/autoserv" local control_files_to_run="" # Now search for tests which unambiguously include the given identifier - local search_path=$(echo ${AUTOTEST_DIR}/{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 | \