Skip dropping caches in each test and between iterations during factory tests.

Dropping caches (writing back all dirty pages to disk and clearing all the caches) is not necessary for factory tests. It can reduce the latency significantly. The scale is about 27s -> 3s, for running 2 empty tests.

Review URL: http://codereview.chromium.org/1780011
This commit is contained in:
Tom Wai-Hong Tam 2010-04-29 14:57:37 +08:00
parent 9ffc3b32a3
commit bf772cffaa
3 changed files with 86 additions and 45 deletions

View File

@ -90,33 +90,6 @@ FLAGS_to=`eval readlink -f ${FLAGS_to}`
# Use this image as the source image to copy
SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin"
# If we're asked to modify the image for test, then let's make a copy and
# modify that instead.
if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then
if [ ! -f "${FLAGS_from}/chromiumos_test_image.bin" ] || \
[ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ] ; then
# Copy it.
echo "Creating test image from original..."
cp -f "${SRC_IMAGE}" "${FLAGS_from}/chromiumos_test_image.bin"
# Check for manufacturing image.
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then
FACTORY_ARGS="--factory"
fi
# Modify it. Pass --yes so that mod_image_for_test.sh won't ask us if we
# really want to modify the image; the user gave their assent already with
# --test-image and the original image is going to be preserved.
"${SCRIPTS_DIR}/mod_image_for_test.sh" --image \
"${FLAGS_from}/chromiumos_test_image.bin" ${FACTORY_ARGS} --yes
echo "Done with mod_image_for_test."
else
echo "Using cached test image."
fi
SRC_IMAGE="${FLAGS_from}/chromiumos_test_image.bin"
echo "Source test image is: ${SRC_IMAGE}"
fi
STATEFUL_DIR="${FLAGS_from}/stateful_partition"
mkdir -p "${STATEFUL_DIR}"
@ -175,6 +148,34 @@ if [ ${FLAGS_install_autotest} -eq ${FLAGS_TRUE} ] ; then
fi
# If we're asked to modify the image for test, then let's make a copy and
# modify that instead.
if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then
if [ ! -f "${FLAGS_from}/chromiumos_test_image.bin" ] || \
[ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ] ; then
# Copy it.
echo "Creating test image from original..."
cp -f "${SRC_IMAGE}" "${FLAGS_from}/chromiumos_test_image.bin"
# Check for manufacturing image.
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then
FACTORY_ARGS="--factory"
fi
# Modify it. Pass --yes so that mod_image_for_test.sh won't ask us if we
# really want to modify the image; the user gave their assent already with
# --test-image and the original image is going to be preserved.
"${SCRIPTS_DIR}/mod_image_for_test.sh" --image \
"${FLAGS_from}/chromiumos_test_image.bin" ${FACTORY_ARGS} --yes
echo "Done with mod_image_for_test."
else
echo "Using cached test image."
fi
SRC_IMAGE="${FLAGS_from}/chromiumos_test_image.bin"
echo "Source test image is: ${SRC_IMAGE}"
fi
# Let's do it.
if [ -b "${FLAGS_to}" ]
then

View File

@ -0,0 +1,17 @@
#!/bin/bash
# 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.
echo "Create global_config.ini in autotest directory."
pushd ${STATEFUL_DIR}
cat > ${STATEFUL_DIR}/home/autotest-client/global_config.ini <<EOF
[CLIENT]
drop_caches: False
drop_caches_between_iterations: False
EOF
popd

View File

@ -46,37 +46,44 @@ if [ ! -f $FLAGS_image ] ; then
exit 1
fi
# Make sure anything mounted in the rootfs is cleaned up ok on exit.
cleanup_rootfs_mounts() {
# Make sure anything mounted in the rootfs/stateful is cleaned up ok on exit.
cleanup_mounts() {
# Occasionally there are some daemons left hanging around that have our
# root image file system open. We do a best effort attempt to kill them.
PIDS=`sudo lsof -t "${ROOT_FS_DIR}" | sort | uniq`
# root/stateful image file system open. We do a best effort attempt to kill
# them.
PIDS=`sudo lsof -t "$1" | sort | uniq`
for pid in ${PIDS}
do
local cmdline=`cat /proc/$pid/cmdline`
echo "Killing process that has open file on our rootfs: $cmdline"
echo "Killing process that has open file on the mounted directory: $cmdline"
sudo kill $pid || /bin/true
done
}
cleanup_rootfs_loop() {
sudo umount "${LOOP_DEV}"
sleep 1 # in case $LOOP_DEV is in use
sudo losetup -d "${LOOP_DEV}"
cleanup_loop() {
sudo umount "$1"
sleep 1 # in case the loop device is in use
sudo losetup -d "$1"
}
cleanup() {
# Disable die on error.
set +e
cleanup_rootfs_mounts
if [ -n "${LOOP_DEV}" ]
cleanup_mounts "${ROOT_FS_DIR}"
if [ -n "${ROOT_LOOP_DEV}" ]
then
cleanup_rootfs_loop
cleanup_loop "${ROOT_LOOP_DEV}"
fi
rmdir "${ROOT_FS_DIR}"
cleanup_mounts "${STATEFUL_DIR}"
if [ -n "${STATEFUL_LOOP_DEV}" ]
then
cleanup_loop "${STATEFUL_LOOP_DEV}"
fi
rmdir "${STATEFUL_DIR}"
# Turn die on error back on.
set -e
}
@ -100,19 +107,34 @@ set -e
ROOT_FS_DIR=$(dirname "${FLAGS_image}")/rootfs
mkdir -p "${ROOT_FS_DIR}"
STATEFUL_DIR=$(dirname "${FLAGS_image}")/stateful_partition
mkdir -p "${STATEFUL_DIR}"
trap cleanup EXIT
# Figure out how to loop mount the rootfs partition. It should be partition 3
# on the disk image.
offset=$(partoffset "${FLAGS_image}" 3)
LOOP_DEV=$(sudo losetup -f)
if [ -z "$LOOP_DEV" ]; then
ROOT_LOOP_DEV=$(sudo losetup -f)
if [ -z "$ROOT_LOOP_DEV" ]; then
echo "No free loop device"
exit 1
fi
sudo losetup -o $(( $offset * 512 )) "${LOOP_DEV}" "${FLAGS_image}"
sudo mount "${LOOP_DEV}" "${ROOT_FS_DIR}"
sudo losetup -o $(( $offset * 512 )) "${ROOT_LOOP_DEV}" "${FLAGS_image}"
sudo mount "${ROOT_LOOP_DEV}" "${ROOT_FS_DIR}"
# The stateful partition should be partition 1 on the disk image.
offset=$(partoffset "${FLAGS_image}" 1)
STATEFUL_LOOP_DEV=$(sudo losetup -f)
if [ -z "$STATEFUL_LOOP_DEV" ]; then
echo "No free loop device"
exit 1
fi
sudo losetup -o $(( $offset * 512 )) "${STATEFUL_LOOP_DEV}" "${FLAGS_image}"
sudo mount "${STATEFUL_LOOP_DEV}" "${STATEFUL_DIR}"
STATEFUL_DIR="${STATEFUL_DIR}"
MOD_TEST_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts"
# Run test setup script to modify the image
@ -123,7 +145,8 @@ if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then
MOD_FACTORY_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_factory_scripts"
# Run factory setup script to modify the image
sudo GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${ROOT_FS_DIR}" \
QUALDB="${FLAGS_qualdb}" "${MOD_FACTORY_ROOT}/factory_setup.sh"
STATEFUL_DIR="${STATEFUL_DIR}/dev_image" QUALDB="${FLAGS_qualdb}" \
"${MOD_FACTORY_ROOT}/factory_setup.sh"
fi
cleanup