From 7a4c08110742efcec0a16e3ea107a8e91781eea0 Mon Sep 17 00:00:00 2001 From: Eric Li Date: Wed, 7 Apr 2010 12:51:05 -0700 Subject: [PATCH] remove build_autotest.sh and change run_remote_tests.sh to use new autotest script. This change should go with http://codereview.chromium.org/1545014 together. Review URL: http://codereview.chromium.org/1603004 --- autotest | 2 +- build_autotest.sh | 86 +-------------------------------------------- run_remote_tests.sh | 84 ++++++++++++++++--------------------------- 3 files changed, 33 insertions(+), 139 deletions(-) diff --git a/autotest b/autotest index 0d28dd632b..28b025b7e2 100755 --- a/autotest +++ b/autotest @@ -99,7 +99,7 @@ def parse_args_and_help(): print print 'Options inherited from autoserv:' run([AUTOSERV, '--help']) - sys.exit(-1) + sys.exit(0) return options, args diff --git a/build_autotest.sh b/build_autotest.sh index 43752303ca..45c344791e 100755 --- a/build_autotest.sh +++ b/build_autotest.sh @@ -12,89 +12,5 @@ # install the compiled client tests directly onto the rootfs image. # Includes common already -. "$(dirname $0)/autotest_lib.sh" +./autotest --build=all $@ -# Script must be run inside the chroot -assert_inside_chroot - -DEFAULT_TESTS_LIST="all" - -DEFINE_string build "${DEFAULT_TESTS_LIST}" \ - "a comma seperated list of autotest client tests to be prebuilt." b -DEFINE_boolean prompt $FLAGS_TRUE "Prompt user when building all tests." -DEFINE_boolean autox $FLAGS_TRUE "Build autox along with autotest" -DEFINE_boolean buildcheck $FLAGS_TRUE "Fail if tests fail to build" -DEFINE_integer jobs -1 "How many packages to build in parallel at maximum." - -# More useful help -FLAGS_HELP="usage: $0 [flags]" - -# parse the command-line -FLAGS "$@" || exit 1 -eval set -- "${FLAGS_ARGV}" -set -e - -check_board - -if [[ "${FLAGS_jobs}" -ne -1 ]]; then - EMERGE_JOBS="--jobs=${FLAGS_jobs}" -fi - -# build default pre-compile client tests list. -ALL_TESTS="compilebench,dbench,disktest,ltp,netperf2,unixbench" -CLIENT_TEST_PATH="../third_party/autotest/files/client/site_tests" -for SITE_TEST in ${CLIENT_TEST_PATH}/* -do - if [ -d ${SITE_TEST} ] - then - ALL_TESTS="${ALL_TESTS},${SITE_TEST##${CLIENT_TEST_PATH}/}" - fi -done - -# Load the overlay specific blacklist and remove any matching tests. -BOARD_BASENAME=$(echo "${FLAGS_board}" |cut -d '_' -f 1) -PRIMARY_BOARD_OVERLAY="${SRC_ROOT}/overlays/overlay-${BOARD_BASENAME}" -BLACKLIST_FILE="${PRIMARY_BOARD_OVERLAY}/autotest-blacklist" -if [ -r "${BLACKLIST_FILE}" ] -then - BLACKLISTED_TESTS=$(cat ${BLACKLIST_FILE}) - - for TEST in ${BLACKLISTED_TESTS} - do - ALL_TESTS=${ALL_TESTS/#${TEST},/} # match first test (test,...) - ALL_TESTS=${ALL_TESTS/,${TEST},/,} # match middle tests (...,test,...) - ALL_TESTS=${ALL_TESTS/%,${TEST}/} # match last test (...,test) - done -fi - -if [ ${FLAGS_build} == ${DEFAULT_TESTS_LIST} ] -then - if [ ${FLAGS_prompt} -eq ${FLAGS_TRUE} ] - then - echo -n "You want to pre-build all client tests and it may take a long time" - echo " to finish. " - read -p "Are you sure you want to continue?(N/y)" answer - answer=${answer:0:1} - if [ "${answer}" != "Y" ] && [ "${answer}" != "y" ] - then - echo "Use --build to specify tests you like to pre-compile." - echo -n "E.g.: ./enter_chroot.sh \"./build_autotest.sh " - echo "--build=system_SAT\"" - exit 0 - fi - fi - TEST_LIST=${ALL_TESTS} -else - TEST_LIST=${FLAGS_build} -fi - -# Decide on USE flags based on options -USE= -[ $FLAGS_autox -eq "$FLAGS_FALSE" ] && USE="${USE} -autox" -[ $FLAGS_buildcheck -eq "$FLAGS_TRUE" ] && USE="${USE} buildcheck" - -GCLIENT_ROOT="${GCLIENT_ROOT}" TEST_LIST=${TEST_LIST} \ - FEATURES="${FEATURES} -buildpkg -collision-protect" \ - USE="$USE" "emerge-${FLAGS_board}" \ - chromeos-base/autotest ${EMERGE_JOBS} \ - || die "build_autotest failed." diff --git a/run_remote_tests.sh b/run_remote_tests.sh index 6239137c15..144328c039 100755 --- a/run_remote_tests.sh +++ b/run_remote_tests.sh @@ -10,10 +10,12 @@ # 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" -DEFINE_boolean build ${FLAGS_FALSE} "Build tests as well as running them" b +get_default_board + +DEFINE_string board "$DEFAULT_BOARD" \ + "The board for which you are building autotest" DEFINE_string chroot "${DEFAULT_CHROOT_DIR}" "alternate chroot location" c DEFINE_boolean cleanup ${FLAGS_FALSE} "Clean up temp directory" DEFINE_integer iterations 1 "Iterations to run every top level test" i @@ -149,7 +151,14 @@ function main() { set -e # Set global TMP for remote_access.sh's sake - TMP=$(mktemp -d /tmp/run_remote_tests.XXXX) + if [[ ${INSIDE_CHROOT} -eq 0 ]] + then + TMP=$(mktemp -d ${FLAGS_chroot}/tmp/run_remote_tests.XXXX) + TMP_INSIDE_CHROOT=$(echo ${TMP#${FLAGS_chroot}}) + else + TMP=$(mktemp -d /tmp/run_remote_tests.XXXX) + TMP_INSIDE_CHROOT=${TMP} + fi trap cleanup EXIT @@ -158,25 +167,16 @@ function main() { local autotest_dir="" if [[ -z "${FLAGS_prepackaged_autotest}" ]]; then learn_board - # 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" - autotest_dir="/build/${FLAGS_board}/usr/local/autotest" - if [[ ${INSIDE_CHROOT} -eq 0 ]]; then - autotest_dir="${FLAGS_chroot}/${autotest_dir}" - fi - update_chroot_autotest "${original}" "${autotest_dir}" + autotest_dir="${GCLIENT_ROOT}/src/third_party/autotest/files" else autotest_dir="${FLAGS_prepackaged_autotest}" fi - 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 {client,server}/{tests,site_tests}) + pushd ${autotest_dir} > /dev/null for test_request in $FLAGS_ARGV; do test_request=$(remove_quotes "${test_request}") ! finds=$(find ${search_path} -maxdepth 2 -type f \( -name control.\* -or \ @@ -202,6 +202,7 @@ function main() { control_files_to_run="${control_files_to_run} '${finds}'" done done + popd > /dev/null echo "" @@ -216,48 +217,15 @@ function main() { done if [[ -z "${FLAGS_results_dir_root}" ]]; then - FLAGS_results_dir_root="${TMP}" + FLAGS_results_dir_root="${TMP_INSIDE_CHROOT}" fi mkdir -p "${FLAGS_results_dir_root}" - if [[ ${FLAGS_build} -eq ${FLAGS_TRUE} ]]; then - # Create a list of files to build based on all the client tests - # the user has specified. If they have specified at least one - # that is a server test, offer to build all client tests since - # it's quite hard to know what client tests a server test might - # use. - local build_param="" - for control_file in ${control_files_to_run}; do - control_file=$(remove_quotes "${control_file}") - local type=$(read_test_type "${control_file}") - if [[ "${type}" == "server" ]]; then - build_param="" - break - fi - if [[ -n "${build_param}" ]]; then - build_param="${build_param}," - fi - local simple_path=$(basename $(dirname $control_file)) - build_param="${build_param}${simple_path}" - done - local enter_chroot="" - if [[ ${INSIDE_CHROOT} -eq 0 ]]; then - enter_chroot="./enter_chroot.sh --" - fi - if [[ -n "${build_param}" ]]; then - build_param="--build=${build_param}" - fi - echo "" - echo_color "yellow" ">>> Building " \ - "./build_autotest.sh --board=${FLAGS_board} ${build_param}" - ${enter_chroot} ./build_autotest.sh --board=${FLAGS_board} ${build_param} - fi - for control_file in ${control_files_to_run}; do # Assume a line starts with TEST_TYPE = control_file=$(remove_quotes "${control_file}") - local type=$(read_test_type "${control_file}") + local type=$(read_test_type "${autotest_dir}/${control_file}") local option if [[ "${type}" == "client" ]]; then option="-c" @@ -268,7 +236,7 @@ function main() { echo_color "yellow" ">>> Running ${type} test " ${control_file} local short_name=$(basename $(dirname "${control_file}")) local results_dir_name="${short_name}" - local results_dir="${FLAGS_results_dir_root}/${results_dir_name}" + local results_dir="${TMP_INSIDE_CHROOT}/${results_dir_name}" rm -rf "${results_dir}" local verbose="" if [[ ${FLAGS_verbose} -eq $FLAGS_TRUE ]]; then @@ -276,8 +244,18 @@ function main() { fi RAN_ANY_TESTS=${FLAGS_TRUE} - ${autoserv} -m "${FLAGS_remote}" "${option}" "${control_file}" \ - -r "${results_dir}" ${verbose} + + local enter_chroot="" + local autotest="${GCLIENT_ROOT}/src/scripts/autotest" + if [[ ${INSIDE_CHROOT} -eq 0 ]]; then + enter_chroot="./enter_chroot.sh --" + autotest="./autotest" + fi + + ${enter_chroot} ${autotest} --board "${FLAGS_board}" -m "${FLAGS_remote}" \ + "${option}" "${control_file}" -r "${results_dir}" ${verbose} + + results_dir="${TMP}/${results_dir_name}" local test_status="${results_dir}/status.log" local test_result_dir="${results_dir}/${short_name}" local keyval_file="${test_result_dir}/results/keyval"