Update the default mount directory and header
Ran into issues that seemed to be related to file paths and location
changes. To resolve them changed the default directory where the
upstream directory is mounted so that it now mounts in the same
directory that is now used in the build-setup.sh container
/tmp/openbmc/build. Made it into a variable so that it can be changed as
is needed. Updated the architecture detection to use the nicer looking
version and updated the header and a few of the comments.
Change-Id: I802d6927f2e34ceaf92c4763b1ae6cf08b96cbbc
Signed-off-by: Alanny Lopez <alanny.lopez@ibm.com>
diff --git a/run-qemu-robot-test.sh b/run-qemu-robot-test.sh
index d6e29a0..32786b9 100755
--- a/run-qemu-robot-test.sh
+++ b/run-qemu-robot-test.sh
@@ -1,50 +1,88 @@
#!/bin/bash -xe
-
-# This script is for starting QEMU against the input build and running
-# the robot CI test suite against it.
+###############################################################################
#
-# Parameters:
-# UPSTREAM_WORKSPACE = <required, base dir of QEMU image>
-# WORKSPACE = <optional, temp dir for robot script>
+# This script is for starting QEMU against the input build and running the
+# robot CI test suite against it.(ROBOT CI TEST CURRENTLY WIP)
+#
+###############################################################################
+#
+# Parameters used by the script:
+# UPSTREAM_WORKSPACE = The directory from which the QEMU components are being
+# imported from. Generally, this is the build directory
+# that is generated by the OpenBMC build-setup.sh script
+# when run with "target=qemu".
+# Example: /home/builder/workspace/openbmc-build/build.
+#
+# Optional Variables:
+#
+# WORKSPACE = Path of the workspace directory where some intermediate
+# files will be saved to.
+# QEMU_RUN_TIMER = Defaults to 300, a timer for the QEMU container.
+# DOCKER_IMG_NAME = Defaults to openbmc/ubuntu-robot-qemu, the name the
+# Docker image will be tagged with when built.
+# OBMC_BUILD_DIR = Defaults to /tmp/openbmc/build, the path to the
+# directory where the UPSTREAM_WORKSPACE build files will
+# be mounted to. Since the build containers have been
+# changed to use /tmp as the parent directory for their
+# builds, move the mounting location to be the same to
+# resolve issues with file links or referrals to exact
+# paths in the original build directory. If the build
+# directory was changed in the build-setup.sh run, this
+# variable should also be changed. Otherwise, the default
+# should be used.
+#
+###############################################################################
set -uo pipefail
-QEMU_RUN_TIMER=300
+QEMU_RUN_TIMER=${QEMU_RUN_TIMER:-300}
WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
-DOCKER_IMG_NAME="openbmc/ubuntu-robot-qemu"
+DOCKER_IMG_NAME=${DOCKER_IMG_NAME:-openbmc/ubuntu-robot-qemu}
+OBMC_BUILD_DIR=${OBMC_BUILD_DIR:-/tmp/openbmc/build}
+UPSTREAM_WORKSPACE=${UPSTREAM_WORKSPACE:-${1}}
-# Get base directory of our repo so we can find the scripts later
-DIR="${BASH_SOURCE%/*}"
-if [[ ! -d "$DIR" || "$DIR" == "." ]]; then DIR="$PWD"; fi
+# Determine the architecture
+ARCH=$(uname -m)
-cd ${UPSTREAM_WORKSPACE}
-
-# Determine our architecture, ppc64le or the other one
-if [ $(uname -m) == "ppc64le" ]; then
+# Determine the prefix of the Dockerfile's base image and the QEMU_ARCH variable
+case ${ARCH} in
+ "ppc64le")
DOCKER_BASE="ppc64le/"
QEMU_ARCH="ppc64le-linux"
-else
+ ;;
+ "x86_64")
DOCKER_BASE=""
QEMU_ARCH="x86_64-linux"
-fi
+ ;;
+ *)
+ echo "Unsupported system architecture(${ARCH}) found for docker image"
+ exit 1
+esac
-# Create the docker image that QEMU and Robot will run in
+# Get the base directory of the openbmc-build-scripts repo so we can return
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+# Create the base Docker image for QEMU and Robot
. "$DIR/scripts/build-qemu-robot-docker.sh" "$DOCKER_IMG_NAME"
# Copy the scripts to start and verify QEMU in the workspace
cp $DIR/scripts/boot-qemu* ${UPSTREAM_WORKSPACE}
+# Move into the upstream workspace directory
+cd ${UPSTREAM_WORKSPACE}
+
# Start QEMU docker instance
# root in docker required to open up the https/ssh ports
obmc_qemu_docker=$(docker run --detach \
--user root \
- --env HOME=${HOME} \
+ --env HOME=${OBMC_BUILD_DIR} \
--env QEMU_RUN_TIMER=${QEMU_RUN_TIMER} \
--env QEMU_ARCH=${QEMU_ARCH} \
- --workdir "${HOME}" \
- --volume "${UPSTREAM_WORKSPACE}":"${HOME}" \
+ --workdir "${OBMC_BUILD_DIR}" \
+ --volume "${UPSTREAM_WORKSPACE}":"${OBMC_BUILD_DIR}" \
--tty \
- ${DOCKER_IMG_NAME} ${HOME}/boot-qemu-test.exp)
+ ${DOCKER_IMG_NAME} ${OBMC_BUILD_DIR}/boot-qemu-test.exp)
+
# We can use default ports because we're going to have the 2
# docker instances talk over their private network
@@ -53,7 +91,7 @@
DOCKER_QEMU_IP_ADDR="$(docker inspect $obmc_qemu_docker | \
grep -m 1 "IPAddress\":" | cut -d '"' -f 4)"
-# Now wait for the openbmc qemu docker instance to get to standby
+# Now wait for the OpenBMC QEMU Docker instance to get to standby
attempt=60
while [ $attempt -gt 0 ]; do
attempt=$(( $attempt - 1 ))
@@ -73,7 +111,7 @@
exit 1
fi
-# Now run the robot test
+# Now run the Robot test
# Timestamp for job
echo "Robot Test started, $(date)"
@@ -81,10 +119,10 @@
mkdir -p ${WORKSPACE}
cd ${WORKSPACE}
-# Copy in the script which will execute the robot tests
+# Copy in the script which will execute the Robot tests
cp $DIR/scripts/run-robot.sh ${WORKSPACE}
-# Run the docker container to execute the robot test cases
+# Run the Docker container to execute the Robot test cases
# The test results will be put in ${WORKSPACE}
docker run --rm \
--user root \
@@ -97,5 +135,5 @@
--tty \
${DOCKER_IMG_NAME} ${HOME}/run-robot.sh
-# Now stop the QEMU docker image
+# Now stop the QEMU Docker image
docker stop $obmc_qemu_docker