Two major changes here:

1. work with the new portage build system. Yes, cross compiling works.

2. work with new upstream changes to build a single or a subset of site test which specified from command line.

I will update the how-to document after all code checked in.

Please also refer to change from 582012 which had been included here and 582012 will be abandoned after this CL checked in.

Review URL: http://codereview.chromium.org/596110
This commit is contained in:
Eric Li 2010-02-15 12:00:58 -08:00
parent 742b51bae5
commit 944281ff8b

View File

@ -4,30 +4,25 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
# This script makes autotest client tests inside an Ubuntu chroot # This script makes autotest client tests inside a chroot environment. The idea
# environment. The idea is to compile any platform-dependent autotest # is to compile any platform-dependent autotest client tests in the build
# client tests in the build environment, since client systems under # environment, since client systems under test lack the proper toolchain.
# test lack the proper toolchain.
# #
# The user can later run autotest against an ssh enabled test client system, or # The user can later run autotest against an ssh enabled test client system, or
# install the compiled client tests directly onto the rootfs image, using # install the compiled client tests directly onto the rootfs image.
# mod_image_for_test.sh.
. "$(dirname "$0")/common.sh" . "$(dirname "$0")/common.sh"
. "$(dirname "$0")/autotest_lib.sh"
# Script must be run inside the chroot # Script must be run inside the chroot
assert_inside_chroot assert_inside_chroot
DEFAULT_CONTROL=client/site_tests/setup/control DEFAULT_TESTS_LIST="all"
DEFINE_string control "${DEFAULT_CONTROL}" \
"Setup control file -- path relative to the destination autotest directory" c
DEFINE_string board "" \
"Board name for the target you are building if using portage build system"
DEFINE_string board "" \ DEFINE_string board "" \
"The board for which you are building autotest" "The board for which you are building autotest"
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"
# More useful help # More useful help
FLAGS_HELP="usage: $0 [flags]" FLAGS_HELP="usage: $0 [flags]"
@ -37,43 +32,49 @@ FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}" eval set -- "${FLAGS_ARGV}"
set -e set -e
AUTOTEST_SRC="${GCLIENT_ROOT}/src/third_party/autotest/files"
# Destination in chroot to install autotest.
AUTOTEST_DEST="/usr/local/autotest/${FLAGS_board}"
# If new build system flag passed, use ebuild and exit if [ -z ${FLAGS_board} ]
if [ -n "${FLAGS_board}" ]; then then
sudo GCLIENT_ROOT="${GCLIENT_ROOT}" FLAGS_control=${FLAGS_control} \ echo "You are required to specify a board name from the command line."
"emerge-${FLAGS_board}" -a chromeos-base/autotest echo "Supported boards are:"
for board in ../overlays/overlay-*
do
echo ${board:20}
done
exit 0 exit 0
fi fi
# Copy a local "installation" of autotest into the chroot, to avoid
# polluting the src dir with tmp files, results, etc.
update_chroot_autotest "${CHROOT_TRUNK_DIR}/src/third_party/autotest/files" \
"${AUTOTEST_DEST}"
# Create python package init files for top level test case dirs. # build default pre-compile client tests list.
function touchInitPy() { ALL_TESTS="compilebench,dbench,disktest,ltp,unixbench"
local dirs=${1} for SITE_TEST in ../third_party/autotest/files/client/site_tests/*
for base_dir in $dirs do
do if [ -d ${SITE_TEST} ]
local sub_dirs="$(find ${base_dir} -maxdepth 1 -type d)" then
for sub_dir in ${sub_dirs} ALL_TESTS="${ALL_TESTS},${SITE_TEST:48}"
do fi
touch ${sub_dir}/__init__.py done
done
touch ${base_dir}/__init__.py
done
}
cd ${AUTOTEST_DEST} if [ ${FLAGS_build} == ${DEFAULT_TESTS_LIST} ]
touchInitPy client/tests client/site_tests then
touch __init__.py if [ ${FLAGS_prompt} -eq ${FLAGS_TRUE} ]
then
echo -n "You want to prebuild 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
# Export GCLIENT_ROOT so that tests have access to the source and build trees GCLIENT_ROOT="${GCLIENT_ROOT}" TEST_LIST=${TEST_LIST} \
export GCLIENT_ROOT "emerge-${FLAGS_board}" chromeos-base/autotest
# run the magic test setup script.
echo "Building tests using ${FLAGS_control}..."
client/bin/autotest ${FLAGS_control}