blob: d6e29a01d278213d6c80ae381528af8af5f74fc2 [file] [log] [blame]
Andrew Geissler0205e8d2016-08-10 07:46:19 -05001#!/bin/bash -xe
2
3# This script is for starting QEMU against the input build and running
4# the robot CI test suite against it.
5#
6# Parameters:
7# UPSTREAM_WORKSPACE = <required, base dir of QEMU image>
8# WORKSPACE = <optional, temp dir for robot script>
9
10set -uo pipefail
11
12QEMU_RUN_TIMER=300
Andrew Geissler1df680a2016-08-22 14:37:39 -050013WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
Andrew Geissler0205e8d2016-08-10 07:46:19 -050014DOCKER_IMG_NAME="openbmc/ubuntu-robot-qemu"
15
16# Get base directory of our repo so we can find the scripts later
17DIR="${BASH_SOURCE%/*}"
18if [[ ! -d "$DIR" || "$DIR" == "." ]]; then DIR="$PWD"; fi
19
20cd ${UPSTREAM_WORKSPACE}
21
22# Determine our architecture, ppc64le or the other one
23if [ $(uname -m) == "ppc64le" ]; then
24 DOCKER_BASE="ppc64le/"
25 QEMU_ARCH="ppc64le-linux"
26else
27 DOCKER_BASE=""
28 QEMU_ARCH="x86_64-linux"
29fi
30
31# Create the docker image that QEMU and Robot will run in
32. "$DIR/scripts/build-qemu-robot-docker.sh" "$DOCKER_IMG_NAME"
33
34# Copy the scripts to start and verify QEMU in the workspace
35cp $DIR/scripts/boot-qemu* ${UPSTREAM_WORKSPACE}
36
37# Start QEMU docker instance
38# root in docker required to open up the https/ssh ports
Leonel Gonzalez10a193c2017-02-10 11:06:58 -060039obmc_qemu_docker=$(docker run --detach \
Andrew Geissler0205e8d2016-08-10 07:46:19 -050040 --user root \
41 --env HOME=${HOME} \
42 --env QEMU_RUN_TIMER=${QEMU_RUN_TIMER} \
43 --env QEMU_ARCH=${QEMU_ARCH} \
44 --workdir "${HOME}" \
45 --volume "${UPSTREAM_WORKSPACE}":"${HOME}" \
46 --tty \
47 ${DOCKER_IMG_NAME} ${HOME}/boot-qemu-test.exp)
48
49# We can use default ports because we're going to have the 2
50# docker instances talk over their private network
51DOCKER_SSH_PORT=22
52DOCKER_HTTPS_PORT=443
53DOCKER_QEMU_IP_ADDR="$(docker inspect $obmc_qemu_docker | \
54 grep -m 1 "IPAddress\":" | cut -d '"' -f 4)"
55
56# Now wait for the openbmc qemu docker instance to get to standby
57attempt=60
58while [ $attempt -gt 0 ]; do
59 attempt=$(( $attempt - 1 ))
60 echo "Waiting for qemu to get to standby (attempt: $attempt)..."
61 result=$(docker logs $obmc_qemu_docker)
62 if grep -q 'OPENBMC-READY' <<< $result ; then
63 echo "QEMU is ready!"
64 # Give QEMU a few secs to stablize
65 sleep 5
66 break
67 fi
68 sleep 2
69done
70
71if [ "$attempt" -eq 0 ]; then
72 echo "Timed out waiting for QEMU, exiting"
73 exit 1
74fi
75
76# Now run the robot test
77
78# Timestamp for job
79echo "Robot Test started, $(date)"
80
81mkdir -p ${WORKSPACE}
82cd ${WORKSPACE}
83
84# Copy in the script which will execute the robot tests
85cp $DIR/scripts/run-robot.sh ${WORKSPACE}
86
87# Run the docker container to execute the robot test cases
88# The test results will be put in ${WORKSPACE}
Andrew Geisslerd008c542017-02-02 10:46:20 -060089docker run --rm \
90 --user root \
Andrew Geissler0205e8d2016-08-10 07:46:19 -050091 --env HOME=${HOME} \
92 --env IP_ADDR=${DOCKER_QEMU_IP_ADDR} \
93 --env SSH_PORT=${DOCKER_SSH_PORT} \
94 --env HTTPS_PORT=${DOCKER_HTTPS_PORT} \
95 --workdir ${HOME} \
96 --volume ${WORKSPACE}:${HOME} \
97 --tty \
98 ${DOCKER_IMG_NAME} ${HOME}/run-robot.sh
99
100# Now stop the QEMU docker image
101docker stop $obmc_qemu_docker