Allow boot directly into mfg test.

Add feature to mod_image_for_test to patch rootfs.
Change initctl path to get network but no chrome.
./image_to_usb.sh --install_mfg --install_autotest --test_image
which calls ./mod_image_for_test.sh --manuf

Review URL: http://codereview.chromium.org/1542011
This commit is contained in:
Nick Sanders 2010-04-16 19:53:55 -07:00
parent acee63274c
commit 3c8023380e
3 changed files with 143 additions and 8 deletions

View File

@ -21,6 +21,9 @@ DEFINE_string from "" \
"Directory containing chromiumos_image.bin" "Directory containing chromiumos_image.bin"
DEFINE_string to "" "${DEFAULT_TO_HELP}" DEFINE_string to "" "${DEFAULT_TO_HELP}"
DEFINE_boolean yes ${FLAGS_FALSE} "Answer yes to all prompts" "y" DEFINE_boolean yes ${FLAGS_FALSE} "Answer yes to all prompts" "y"
DEFINE_boolean force_copy ${FLAGS_FALSE} "Always rebuild test image"
DEFINE_boolean factory ${FLAGS_FALSE} \
"Whether to generate a factory runin image. Implies aututest and test"
DEFINE_boolean install_autotest ${FLAGS_FALSE} \ DEFINE_boolean install_autotest ${FLAGS_FALSE} \
"Whether to install autotest to the stateful partition." "Whether to install autotest to the stateful partition."
DEFINE_boolean copy_kernel ${FLAGS_FALSE} \ DEFINE_boolean copy_kernel ${FLAGS_FALSE} \
@ -34,6 +37,13 @@ DEFINE_string build_root "/build" \
FLAGS "$@" || exit 1 FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}" eval set -- "${FLAGS_ARGV}"
# Require autotest for manucaturing image.
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then
echo "Factory image requires --install_autotest and --test_image, setting."
FLAGS_install_autotest=${FLAGS_TRUE}
FLAGS_test_image=${FLAGS_TRUE}
fi
# Inside the chroot, so output to usb.img in the same dir as the other # Inside the chroot, so output to usb.img in the same dir as the other
# Script can be run either inside or outside the chroot. # Script can be run either inside or outside the chroot.
if [ ${INSIDE_CHROOT} -eq 1 ] if [ ${INSIDE_CHROOT} -eq 1 ]
@ -84,22 +94,42 @@ fi
FLAGS_from=`eval readlink -f ${FLAGS_from}` FLAGS_from=`eval readlink -f ${FLAGS_from}`
FLAGS_to=`eval readlink -f ${FLAGS_to}` FLAGS_to=`eval readlink -f ${FLAGS_to}`
# Done evaluating arguments, lets go!
echo "Caching sudo authentication"
sudo -v
echo "Done"
# 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 # If we're asked to modify the image for test, then let's make a copy and
# modify that instead. # modify that instead.
if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then
if [ ! -f "${FLAGS_from}/chromiumos_test_image.bin" ] ; then if [ ! -f "${FLAGS_from}/chromiumos_test_image.bin" ] || \
[ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ] ; then
# Copy it. # Copy it.
echo "Creating test image from original..." echo "Creating test image from original..."
cp -f "${SRC_IMAGE}" "${FLAGS_from}/chromiumos_test_image.bin" 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
# Check for yes
if [ ${FLAGS_yes} -eq ${FLAGS_TRUE} ] ; then
YES="--yes"
fi
# Modify it. # Modify it.
"${SCRIPTS_DIR}/mod_image_for_test.sh" --image \ "${SCRIPTS_DIR}/mod_image_for_test.sh" --image \
"${FLAGS_from}/chromiumos_test_image.bin" --yes "${FLAGS_from}/chromiumos_test_image.bin" ${FACTORY_ARGS} ${YES}
echo "Done with mod_image_for_test."
else
echo "Using cached test image."
fi fi
# Use it.
SRC_IMAGE="${FLAGS_from}/chromiumos_test_image.bin" SRC_IMAGE="${FLAGS_from}/chromiumos_test_image.bin"
echo "Source test image is: ${SRC_IMAGE}"
fi fi
STATEFUL_DIR="${FLAGS_from}/stateful_partition" STATEFUL_DIR="${FLAGS_from}/stateful_partition"
@ -140,6 +170,8 @@ if [ ${FLAGS_install_autotest} -eq ${FLAGS_TRUE} ] ; then
echo "Install autotest into stateful partition..." echo "Install autotest into stateful partition..."
autotest_client="/home/autotest-client" autotest_client="/home/autotest-client"
sudo mkdir -p "${stateful_root}${autotest_client}" sudo mkdir -p "${stateful_root}${autotest_client}"
sudo ln -sf /mnt/stateful_partition/dev_image${autotest_client} \
${stateful_root}/autotest
sudo cp -fpru ${AUTOTEST_SRC}/client/* \ sudo cp -fpru ${AUTOTEST_SRC}/client/* \
"${stateful_root}/${autotest_client}" "${stateful_root}/${autotest_client}"
@ -152,7 +184,7 @@ if [ ${FLAGS_install_autotest} -eq ${FLAGS_TRUE} ] ; then
rmdir "${STATEFUL_DIR}" rmdir "${STATEFUL_DIR}"
else else
echo "/usr/local/autotest under ${DEFAULT_CHROOT_DIR} is not installed." echo "/usr/local/autotest under ${DEFAULT_CHROOT_DIR} is not installed."
echo "Please call make_autotest.sh inside chroot first." echo "Please call build_autotest.sh inside chroot first."
exit -1 exit -1
fi fi
fi fi
@ -166,7 +198,7 @@ then
# Warn if it looks like they supplied a partition as the destination. # Warn if it looks like they supplied a partition as the destination.
if echo "${FLAGS_to}" | grep -q '[0-9]$'; then if echo "${FLAGS_to}" | grep -q '[0-9]$'; then
local drive=$(echo "${FLAGS_to}" | sed -re 's/[0-9]+$//') drive=$(echo "${FLAGS_to}" | sed -re 's/[0-9]+$//')
if [ -b "${drive}" ]; then if [ -b "${drive}" ]; then
echo echo
echo "NOTE: It looks like you may have supplied a partition as the " echo "NOTE: It looks like you may have supplied a partition as the "

View File

@ -0,0 +1,88 @@
diff -Naur old/etc/init/dump-boot-stats.conf new/etc/init/dump-boot-stats.conf
--- old/etc/init/dump-boot-stats.conf 2010-04-05 21:33:11.000000000 -0700
+++ new/etc/init/dump-boot-stats.conf 2010-04-05 21:00:48.000000000 -0700
@@ -7,7 +7,7 @@
# when login-prompt-ready is received, grabs the current uptime and
# disk stats. Also sends uptime to metrics client for perf dashboard
-start on login-prompt-ready
+start on stopping startup
# This is run-once rather than a service.
task
diff -Naur old/etc/init/factory.conf new/etc/init/factory.conf
--- old/etc/init/factory.conf 1969-12-31 16:00:00.000000000 -0800
+++ new/etc/init/factory.conf 2010-04-05 20:59:07.000000000 -0700
@@ -0,0 +1,17 @@
+
+description "Chrome OS factory startup stub"
+author "chromium-os-dev@googlegroups.com"
+
+start on stopping autotest
+
+script
+
+cd /usr/local/autotest
+if [ ! -e factory_started ]; then
+ touch factory_started
+ date >> /var/log/factory.log
+ cp -f site_tests/suite_Factory/control.full control
+ ./bin/autotest control >> /var/log/factory.log 2>&1
+fi
+end script
+
diff -Naur old/etc/init/autotest.conf new/etc/init/autotest.conf
--- old/etc/init/autotest.conf 1969-12-31 16:00:00.000000000 -0800
+++ new/etc/init/autotest.conf 2010-04-05 20:59:07.000000000 -0700
@@ -0,0 +1,15 @@
+
+description "Chrome OS autotest startup stub"
+author "chromium-os-dev@googlegroups.com"
+
+start on started udev
+
+script
+# Sleep as the current upstart sequence gives no clear completion signal.
+# TODO: investigate generating authoritative bootup finished event.
+sleep 10
+cd /usr/local/autotest
+date >> /var/log/factory.log
+./tools/autotest >> /var/log/factory.log 2>&1
+end script
+
diff -Naur old/etc/init/tty1.conf new/etc/init/tty1.conf
--- old/etc/init/tty1.conf 1969-12-31 16:00:00.000000000 -0800
+++ new/etc/init/tty1.conf 2010-04-05 20:59:07.000000000 -0700
@@ -0,0 +1,9 @@
+start on startup
+stop on starting halt or starting reboot
+
+respawn
+script
+cd /
+/sbin/agetty 38400 tty1 linux -l /bin/bash -n
+end script
+
diff -Naur old/sbin/chromeos_startup new/sbin/chromeos_startup
--- old/sbin/chromeos_startup 2010-04-05 21:33:52.000000000 -0700
+++ new/sbin/chromeos_startup 2010-04-05 21:38:02.000000000 -0700
@@ -20,18 +20,12 @@
# Moblin trick: Disable blinking cursor. Without this a splash screen
# will show a distinct cursor shape even when the cursor is set to none.
-echo 0 > /sys/devices/virtual/graphics/fbcon/cursor_blink
+# echo 0 > /sys/devices/virtual/graphics/fbcon/cursor_blink
# Since we defer udev until later in the boot process, we pre-populate /dev
# with the set of devices needed for X and other early services to run.
cp -a -f /lib/chromiumos/devices/* /dev
-# Splash screen!
-if [ -x /usr/bin/ply-image ]
-then
- /usr/bin/ply-image /usr/share/chromeos-assets/images/login_splash.png &
-fi
-
mount -n -t tmpfs tmp /tmp
mount -n -t tmpfs -onosuid,nodev shmfs /dev/shm
mount -n -t devpts -onoexec,nosuid,gid=5,mode=0620 devpts /dev/pts

View File

@ -19,7 +19,7 @@ DEFINE_string board "$DEFAULT_BOARD" "Board for which the image was built"
DEFINE_string qualdb "/tmp/run_remote_tests.*" \ DEFINE_string qualdb "/tmp/run_remote_tests.*" \
"Location of qualified component file" "Location of qualified component file"
DEFINE_string image "" "Location of the rootfs raw image file" DEFINE_string image "" "Location of the rootfs raw image file"
DEFINE_boolean manuf $FLAGS_FALSE "Modify the image for manufacturing testing" DEFINE_boolean factory $FLAGS_FALSE "Modify the image for manufacturing testing"
DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" "y" DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" "y"
# Parse command line # Parse command line
@ -120,9 +120,25 @@ sudo GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${ROOT_FS_DIR}" \
"${MOD_SCRIPTS_ROOT}/test_setup.sh" "${MOD_SCRIPTS_ROOT}/test_setup.sh"
# Run manufacturing test setup # Run manufacturing test setup
if [ ${FLAGS_manuf} -eq ${FLAGS_TRUE} ]; then if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then
echo "Modifying image ${FLAGS_image} for manufacturing test..." echo "Modifying image ${FLAGS_image} for manufacturing test..."
echo "Disabling ui.conf, don't do chrome startup on boot."
sudo mv ${ROOT_FS_DIR}/etc/init/ui.conf \
${ROOT_FS_DIR}/etc/init/ui.conf.disabled
echo "Applying patch to init scripts"
MOD_MFG_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_factory_scripts"
pushd ${ROOT_FS_DIR}
sudo patch -d ${ROOT_FS_DIR} -p1 < ${MOD_MFG_ROOT}/factory.patch
popd
echo "Modifying Release Description for Factory."
FILE="${ROOT_FS_DIR}/etc/lsb-release"
sudo sed -i 's/Test/Factory/' $FILE
echo "Done applying patch."
# Try to use the sytem component file in the most recent autotest result # Try to use the sytem component file in the most recent autotest result
FLAGS_qualdb=$(ls -dt ${FLAGS_qualdb} 2>&-| head -1) FLAGS_qualdb=$(ls -dt ${FLAGS_qualdb} 2>&-| head -1)
@ -142,7 +158,6 @@ if [ ${FLAGS_manuf} -eq ${FLAGS_TRUE} ]; then
${ROOT_FS_DIR}/usr/local/manufacturing/qualified_components ${ROOT_FS_DIR}/usr/local/manufacturing/qualified_components
else else
echo "No qualified component file found at: ${FLAGS_qualdb}" echo "No qualified component file found at: ${FLAGS_qualdb}"
exit 1
fi fi
fi fi