xref: /qemu/tests/docker/run (revision ec960b9a73f48b8b0bc7d5d31a173e90bd38a290)
1#!/bin/bash -e
2#
3# Docker test runner
4#
5# Copyright (c) 2016 Red Hat Inc.
6#
7# Authors:
8#  Fam Zheng <famz@redhat.com>
9#
10# This work is licensed under the terms of the GNU GPL, version 2
11# or (at your option) any later version. See the COPYING file in
12# the top-level directory.
13
14set -e
15
16if test -n "$V"; then
17    set -x
18fi
19
20BASE="$(dirname $(readlink -e $0))"
21
22# Prepare the environment
23. /etc/profile || true
24export PATH=/usr/lib/ccache:$PATH
25
26if test -n "$J"; then
27    export MAKEFLAGS="$MAKEFLAGS -j$J"
28fi
29
30# We are in the container so the whole file system belong to us
31export TEST_DIR=/tmp/qemu-test
32mkdir -p $TEST_DIR/{src,build,install}
33
34# Extract the source tarballs
35tar -C $TEST_DIR/src -xzf $BASE/qemu.tgz
36for p in dtc pixman; do
37    if test -f $BASE/$p.tgz; then
38        tar -C $TEST_DIR/src/$p -xzf $BASE/$p.tgz
39        export FEATURES="$FEATURES $p"
40    fi
41done
42
43if test -n "$SHOW_ENV"; then
44    if test -f /packages.txt; then
45        echo "Packages installed:"
46        cat /packages.txt
47        echo
48    fi
49    echo "Environment variables:"
50    env
51    echo
52fi
53
54export QEMU_SRC="$TEST_DIR/src"
55
56cd "$QEMU_SRC/tests/docker"
57
58CMD="$QEMU_SRC/tests/docker/$@"
59
60if test -n "$DEBUG"; then
61    echo "* Prepared to run command:"
62    echo "  $CMD"
63    echo "* Hit Ctrl-D to continue, or type 'exit 1' to abort"
64    echo
65    $SHELL
66fi
67
68if "$CMD"; then
69    exit 0
70elif test -n "$DEBUG"; then
71    echo "* Command failed:"
72    echo "  $CMD"
73    echo "* Hit Ctrl-D to exit"
74    echo
75    # Force error after shell exits
76    $SHELL && exit 1
77else
78    exit 1
79fi
80