qemu robot test: allow specifying IMAGE_LOC
The existing script assumes qemuarm and the MACHINE under test are
in the same folder. This change adds an option to specify a
different location for the MACHINE image.
Tested:
UPSTREAM_WORKSPACE=/home/nanzhou_google_com/openbmc
DEFAULT_IMAGE_LOC=./build/romulus/tmp/deploy/images
QEMU_BIN=./qemuarm/tmp/sysroots/x86_64/usr/bin/qemu-system-arm
MACHINE=romulus ./openbmc-build-scripts/run-qemu-robot
-test.sh
I cloned the openbmc distro in my home dir. Then source setup
qemuarm and romulus separately, and finished the builds.
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I37800de63fe9d64dd28ffc6c5a4d3c0ea181a597
diff --git a/run-qemu-robot-test.sh b/run-qemu-robot-test.sh
index e40dd4a..b704f9b 100755
--- a/run-qemu-robot-test.sh
+++ b/run-qemu-robot-test.sh
@@ -48,6 +48,10 @@
# MACHINE = Machine to run test against. The options are "witherspoon",
# "palmetto", "romulus", or undefined (default). Default
# will use the versatilepb model.
+#
+# DEFAULT_IMAGE_LOC = The image location of the target MACHINE. Default to
+# "./tmp/deploy/images/"
+#
###############################################################################
set -uo pipefail
@@ -61,6 +65,7 @@
LAUNCH=${LAUNCH:-local}
DEFAULT_MACHINE=versatilepb
MACHINE=${MACHINE:-${DEFAULT_MACHINE}}
+DEFAULT_IMAGE_LOC=${DEFAULT_IMAGE_LOC:-./tmp/deploy/images/}
# The automated test suite needs a real machine type so
# if we're using versatilepb for our qemu start parameter
@@ -117,6 +122,7 @@
--env QEMU_ARCH="${QEMU_ARCH}" \
--env QEMU_BIN="${QEMU_BIN}" \
--env MACHINE="${MACHINE}" \
+ --env DEFAULT_IMAGE_LOC="${DEFAULT_IMAGE_LOC}" \
--workdir "${OBMC_BUILD_DIR}" \
--volume "${UPSTREAM_WORKSPACE}:${OBMC_BUILD_DIR}:ro" \
--tty \
diff --git a/scripts/boot-qemu.sh b/scripts/boot-qemu.sh
index c07112e..fd52c9e 100755
--- a/scripts/boot-qemu.sh
+++ b/scripts/boot-qemu.sh
@@ -62,15 +62,14 @@
# Find the correct drive file, and save its name. OpenBMC has 3 different
# image formats. The UBI based one, the standard static.mtd one, and the
# default QEMU basic image (rootfs.ext4).
-
-DEFAULT_IMAGE_LOC="./tmp/deploy/images/"
-if [ -f ${DEFAULT_IMAGE_LOC}/"${MACHINE}"/obmc-phosphor-image-"${MACHINE}".ubi.mtd ]; then
+DEFAULT_IMAGE_LOC="${DEFAULT_IMAGE_LOC:-./tmp/deploy/images/}"
+if [ -f "${DEFAULT_IMAGE_LOC}/${MACHINE}/obmc-phosphor-image-${MACHINE}".ubi.mtd ]; then
DRIVE="obmc-phosphor-image-${MACHINE}.ubi.mtd"
-elif [ -f ${DEFAULT_IMAGE_LOC}/"${MACHINE}"/obmc-phosphor-image-"${MACHINE}".static.mtd ]; then
+elif [ -f "${DEFAULT_IMAGE_LOC}/${MACHINE}/obmc-phosphor-image-${MACHINE}".static.mtd ]; then
DRIVE="obmc-phosphor-image-${MACHINE}.static.mtd"
else
# shellcheck disable=SC2010
- DRIVE=$(ls ${DEFAULT_IMAGE_LOC}/qemuarm | grep rootfs.ext4)
+ DRIVE=$(ls "${DEFAULT_IMAGE_LOC}"/qemuarm | grep rootfs.ext4)
fi
# Copy the drive file off to /tmp so that QEMU does not write anything back
@@ -81,9 +80,9 @@
# The drive file is stored in different locations depending on if we are
# using the default or real platforms.
if [ "${MACHINE}" = "${DEFAULT_MACHINE}" ]; then
- cp ${DEFAULT_IMAGE_LOC}/qemuarm/"${DRIVE}" "${TMP_DRIVE_PATH}"
+ cp "${DEFAULT_IMAGE_LOC}/qemuarm/${DRIVE}" "${TMP_DRIVE_PATH}"
else
- cp ${DEFAULT_IMAGE_LOC}/"${MACHINE}"/"${DRIVE}" "${TMP_DRIVE_PATH}"
+ cp "${DEFAULT_IMAGE_LOC}/${MACHINE}/${DRIVE}" "${TMP_DRIVE_PATH}"
fi
# Obtain IP from /etc/hosts if IP is not valid set to localhost
@@ -124,9 +123,9 @@
-serial mon:vc \
-serial mon:stdio \
-serial null \
- -kernel ${DEFAULT_IMAGE_LOC}/qemuarm/zImage \
+ -kernel "${DEFAULT_IMAGE_LOC}"/qemuarm/zImage \
-append 'root=/dev/vda rw highres=off console=ttyS0 mem=256M ip=dhcp console=ttyAMA0,115200 console=tty'\
- -dtb ${DEFAULT_IMAGE_LOC}/qemuarm/zImage-versatile-pb.dtb
+ -dtb "${DEFAULT_IMAGE_LOC}"/qemuarm/zImage-versatile-pb.dtb
else
# shellcheck disable=SC2086 # NIC is intentionally word-split.
${QEMU_BIN} \