blob: 2d0b18600a1bb8d9b835edec3d0be989a07ef327 [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
Andrew Geisslerd008c542017-02-02 10:46:20 -060039obmc_qemu_docker=$(docker run --rm \
40 --detach \
Andrew Geissler0205e8d2016-08-10 07:46:19 -050041 --user root \
42 --env HOME=${HOME} \
43 --env QEMU_RUN_TIMER=${QEMU_RUN_TIMER} \
44 --env QEMU_ARCH=${QEMU_ARCH} \
45 --workdir "${HOME}" \
46 --volume "${UPSTREAM_WORKSPACE}":"${HOME}" \
47 --tty \
48 ${DOCKER_IMG_NAME} ${HOME}/boot-qemu-test.exp)
49
50# We can use default ports because we're going to have the 2
51# docker instances talk over their private network
52DOCKER_SSH_PORT=22
53DOCKER_HTTPS_PORT=443
54DOCKER_QEMU_IP_ADDR="$(docker inspect $obmc_qemu_docker | \
55 grep -m 1 "IPAddress\":" | cut -d '"' -f 4)"
56
57# Now wait for the openbmc qemu docker instance to get to standby
58attempt=60
59while [ $attempt -gt 0 ]; do
60 attempt=$(( $attempt - 1 ))
61 echo "Waiting for qemu to get to standby (attempt: $attempt)..."
62 result=$(docker logs $obmc_qemu_docker)
63 if grep -q 'OPENBMC-READY' <<< $result ; then
64 echo "QEMU is ready!"
65 # Give QEMU a few secs to stablize
66 sleep 5
67 break
68 fi
69 sleep 2
70done
71
72if [ "$attempt" -eq 0 ]; then
73 echo "Timed out waiting for QEMU, exiting"
74 exit 1
75fi
76
77# Now run the robot test
78
79# Timestamp for job
80echo "Robot Test started, $(date)"
81
82mkdir -p ${WORKSPACE}
83cd ${WORKSPACE}
84
85# Copy in the script which will execute the robot tests
86cp $DIR/scripts/run-robot.sh ${WORKSPACE}
87
88# Run the docker container to execute the robot test cases
89# The test results will be put in ${WORKSPACE}
Andrew Geisslerd008c542017-02-02 10:46:20 -060090docker run --rm \
91 --user root \
Andrew Geissler0205e8d2016-08-10 07:46:19 -050092 --env HOME=${HOME} \
93 --env IP_ADDR=${DOCKER_QEMU_IP_ADDR} \
94 --env SSH_PORT=${DOCKER_SSH_PORT} \
95 --env HTTPS_PORT=${DOCKER_HTTPS_PORT} \
96 --workdir ${HOME} \
97 --volume ${WORKSPACE}:${HOME} \
98 --tty \
99 ${DOCKER_IMG_NAME} ${HOME}/run-robot.sh
100
101# Now stop the QEMU docker image
102docker stop $obmc_qemu_docker