Script which launches QEMU and runs robot CI test against it
This script will be run within automation to do a basic QEMU
CI test against the input openbmc build.
Change-Id: I6ffccd7f5767bec9bc673b1a41bd7bd1d960924c
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
diff --git a/scripts/boot-qemu-test.exp b/scripts/boot-qemu-test.exp
new file mode 100755
index 0000000..f4c3d38
--- /dev/null
+++ b/scripts/boot-qemu-test.exp
@@ -0,0 +1,39 @@
+#!/usr/bin/expect
+#
+# Launch QEMU and verify we can login then sleep for defined amount of time
+# before exiting
+#
+# Requires following env variables be set:
+# QEMU_RUN_TIMER Amount of time to run the QEMU instance
+# HOME Location of scripts
+
+set timeout "$env(QEMU_RUN_TIMER)*2"
+set command "$env(HOME)/boot-qemu.sh"
+
+spawn $command
+
+expect {
+ timeout { send_user "\nFailed to boot\n"; exit 1 }
+ eof { send_user "\nFailure, got EOF"; exit 1 }
+ "qemuarm login:"
+}
+
+send "root\r"
+
+expect {
+ timeout { send_user "\nFailed, no login prompt\n"; exit 1 }
+ eof { send_user "\nFailure, got EOF"; exit 1 }
+ "Password:"
+}
+
+send "0penBmc\r"
+
+expect {
+ timeout { send_user "\nFailed, could not login\n"; exit 1 }
+ eof { send_user "\nFailure, got EOF"; exit 1 }
+ "root@qemuarm:~#"
+}
+
+send_user "OPENBMC-READY\n"
+sleep "$env(QEMU_RUN_TIMER)"
+send_user "OPENBMC-EXITING\n"
diff --git a/scripts/boot-qemu.sh b/scripts/boot-qemu.sh
new file mode 100755
index 0000000..e0cd4de
--- /dev/null
+++ b/scripts/boot-qemu.sh
@@ -0,0 +1,43 @@
+#!/bin/bash -xe
+#
+# Launch QEMU using the raw commands
+#
+# Parameters:
+# parm1: <optional, QEMU architecture to use >
+# default is ${QEMU_ARCH} - ppc64le-linux or x86_64-linux
+# parm2: <optional, full path to base directory of qemu binary and images >
+# default is ${HOME}
+
+set -uo pipefail
+
+QEMU_ARCH=${1:-$QEMU_ARCH}
+echo "QEMU_ARCH = $QEMU_ARCH"
+if [[ -z $QEMU_ARCH ]]; then
+ echo "Did not pass in required QEMU arch parameter"
+ exit -1
+fi
+
+BASE_DIR=${2:-$HOME}
+echo "BASE_DIR = $BASE_DIR"
+if [[ ! -d $BASE_DIR ]]; then
+ echo "No input directory and HOME not set!"
+ exit -1
+fi
+
+cd ${BASE_DIR}
+
+./tmp/sysroots/${QEMU_ARCH}/usr/bin/qemu-system-arm \
+ -nographic \
+ -kernel ./tmp/deploy/images/qemuarm/zImage-qemuarm.bin \
+ -machine versatilepb \
+ -drive file=./tmp/deploy/images/qemuarm/obmc-phosphor-image-qemuarm.ext4,format=raw \
+ -no-reboot \
+ -show-cursor \
+ -usb \
+ -usbdevice wacom-tablet \
+ -no-reboot -m 128 \
+ -redir tcp:22::22 \
+ -redir tcp:443::443 \
+ --append \
+ "root=/dev/sda rw console=ttyAMA0,115200 console=tty mem=128M highres=off \
+ rootfstype=ext4 console=ttyS0"
diff --git a/scripts/build-qemu-robot-docker.sh b/scripts/build-qemu-robot-docker.sh
new file mode 100755
index 0000000..d1339ac
--- /dev/null
+++ b/scripts/build-qemu-robot-docker.sh
@@ -0,0 +1,75 @@
+#!/bin/bash -xe
+#
+# Build the required docker image to run QEMU and Robot test cases
+#
+# Parameters:
+# parm1: <optional, the name of the docker image to generate>
+# default is openbmc/ubuntu-robot-qemu
+
+set -uo pipefail
+
+DOCKER_IMG_NAME=${1:-"openbmc/ubuntu-robot-qemu"}
+
+# Determine our architecture, ppc64le or the other one
+if [ $(uname -m) == "ppc64le" ]; then
+ DOCKER_BASE="ppc64le/"
+else
+ DOCKER_BASE=""
+fi
+
+################################# docker img # #################################
+# Create docker image that can run QEMU and Robot Tests
+Dockerfile=$(cat << EOF
+FROM ${DOCKER_BASE}ubuntu:latest
+
+ENV DEBIAN_FRONTEND noninteractive
+
+RUN apt-get update && apt-get install -yy \
+ debianutils \
+ gawk \
+ git \
+ python \
+ python-dev \
+ python-setuptools \
+ socat \
+ texinfo \
+ wget \
+ gcc \
+ libffi-dev \
+ libssl-dev \
+ xterm \
+ mwm \
+ ssh \
+ vim \
+ iputils-ping \
+ sudo \
+ cpio \
+ unzip \
+ diffstat \
+ expect \
+ curl
+
+RUN easy_install \
+ tox \
+ pip \
+ requests
+
+RUN pip install \
+ robotframework \
+ robotframework-requests \
+ robotframework-sshlibrary \
+ robotframework-scplibrary
+
+RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
+RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} \
+ ${USER}
+USER ${USER}
+ENV HOME ${HOME}
+RUN /bin/bash
+EOF
+)
+
+################################# docker img # #################################
+
+# Build above image
+docker build -t ${DOCKER_IMG_NAME} - <<< "${Dockerfile}"
diff --git a/scripts/run-robot.sh b/scripts/run-robot.sh
new file mode 100755
index 0000000..4c311c2
--- /dev/null
+++ b/scripts/run-robot.sh
@@ -0,0 +1,36 @@
+#!/bin/bash -x
+# Extract and run the OpenBMC robot test suite
+#
+# The robot test results will be copied to ${HOME}
+#
+# Requires following env variables be set:
+# IP_ADDR IP Address of openbmc
+# SSH_PORT SSH port of openbmc
+# HTTPS_PORT HTTPS port of openbmc
+#
+# Optional env variable
+# ROBOT_CODE_HOME Location to extract the code
+# Default will be a temp location in /tmp/
+
+# we don't want to fail on bad rc since robot tests may fail
+
+ROBOT_CODE_HOME=${ROBOT_CODE_HOME:-/tmp/$(whoami)/${RANDOM}/obmc-robot/}
+
+git clone https://github.com/openbmc/openbmc-test-automation.git \
+ ${ROBOT_CODE_HOME}
+
+cd ${ROBOT_CODE_HOME}
+
+chmod ugo+rw -R ${ROBOT_CODE_HOME}/*
+
+# Execute the CI tests
+export OPENBMC_HOST=${IP_ADDR}
+export SSH_PORT=${SSH_PORT}
+export HTTPS_PORT=${HTTPS_PORT}
+
+tox -e qemu -- --include CI tests
+
+cp ${ROBOT_CODE_HOME}/*.xml ${HOME}/
+cp ${ROBOT_CODE_HOME}/*.html ${HOME}/
+
+#rm -rf ${ROBOT_CODE_HOME}