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 # Use this image as the source image to copy
SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" 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" STATEFUL_DIR="${FLAGS_from}/stateful_partition"
mkdir -p "${STATEFUL_DIR}" mkdir -p "${STATEFUL_DIR}"
@ -175,6 +148,34 @@ if [ ${FLAGS_install_autotest} -eq ${FLAGS_TRUE} ] ; then
fi 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. # Let's do it.
if [ -b "${FLAGS_to}" ] if [ -b "${FLAGS_to}" ]
then 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 exit 1
fi fi
# Make sure anything mounted in the rootfs is cleaned up ok on exit. # Make sure anything mounted in the rootfs/stateful is cleaned up ok on exit.
cleanup_rootfs_mounts() { cleanup_mounts() {
# Occasionally there are some daemons left hanging around that have our # 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. # root/stateful image file system open. We do a best effort attempt to kill
PIDS=`sudo lsof -t "${ROOT_FS_DIR}" | sort | uniq` # them.
PIDS=`sudo lsof -t "$1" | sort | uniq`
for pid in ${PIDS} for pid in ${PIDS}
do do
local cmdline=`cat /proc/$pid/cmdline` 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 sudo kill $pid || /bin/true
done done
} }
cleanup_rootfs_loop() { cleanup_loop() {
sudo umount "${LOOP_DEV}" sudo umount "$1"
sleep 1 # in case $LOOP_DEV is in use sleep 1 # in case the loop device is in use
sudo losetup -d "${LOOP_DEV}" sudo losetup -d "$1"
} }
cleanup() { cleanup() {
# Disable die on error. # Disable die on error.
set +e set +e
cleanup_rootfs_mounts cleanup_mounts "${ROOT_FS_DIR}"
if [ -n "${LOOP_DEV}" ] if [ -n "${ROOT_LOOP_DEV}" ]
then then
cleanup_rootfs_loop cleanup_loop "${ROOT_LOOP_DEV}"
fi fi
rmdir "${ROOT_FS_DIR}" 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. # Turn die on error back on.
set -e set -e
} }
@ -100,19 +107,34 @@ set -e
ROOT_FS_DIR=$(dirname "${FLAGS_image}")/rootfs ROOT_FS_DIR=$(dirname "${FLAGS_image}")/rootfs
mkdir -p "${ROOT_FS_DIR}" mkdir -p "${ROOT_FS_DIR}"
STATEFUL_DIR=$(dirname "${FLAGS_image}")/stateful_partition
mkdir -p "${STATEFUL_DIR}"
trap cleanup EXIT trap cleanup EXIT
# Figure out how to loop mount the rootfs partition. It should be partition 3 # Figure out how to loop mount the rootfs partition. It should be partition 3
# on the disk image. # on the disk image.
offset=$(partoffset "${FLAGS_image}" 3) offset=$(partoffset "${FLAGS_image}" 3)
LOOP_DEV=$(sudo losetup -f) ROOT_LOOP_DEV=$(sudo losetup -f)
if [ -z "$LOOP_DEV" ]; then if [ -z "$ROOT_LOOP_DEV" ]; then
echo "No free loop device" echo "No free loop device"
exit 1 exit 1
fi fi
sudo losetup -o $(( $offset * 512 )) "${LOOP_DEV}" "${FLAGS_image}" sudo losetup -o $(( $offset * 512 )) "${ROOT_LOOP_DEV}" "${FLAGS_image}"
sudo mount "${LOOP_DEV}" "${ROOT_FS_DIR}" 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" MOD_TEST_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts"
# Run test setup script to modify the image # 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" MOD_FACTORY_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_factory_scripts"
# Run factory setup script to modify the image # Run factory setup script to modify the image
sudo GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${ROOT_FS_DIR}" \ 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 fi
cleanup cleanup