common.rc 1.3 KB
Newer Older
F
Fam Zheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/bin/sh
#
# Common routines for docker test scripts.
#
# Copyright (c) 2016 Red Hat Inc.
#
# Authors:
#  Fam Zheng <famz@redhat.com>
#
# This work is licensed under the terms of the GNU GPL, version 2
# or (at your option) any later version. See the COPYING file in
# the top-level directory.

requires()
{
    for c in $@; do
        if ! echo "$FEATURES" | grep -wq -e "$c"; then
            echo "Prerequisite '$c' not present, skip"
            exit 0
        fi
    done
}

24
configure_qemu()
F
Fam Zheng 已提交
25
{
26 27
    config_opts="--enable-werror \
                 ${TARGET_LIST:+--target-list=${TARGET_LIST}} \
F
Fam Zheng 已提交
28
                 --prefix=$INSTALL_DIR \
29
                 $QEMU_CONFIGURE_OPTS $EXTRA_CONFIGURE_OPTS \
30 31 32
                 $@"
    echo "Configure options:"
    echo $config_opts
33 34
    $QEMU_SRC/configure $config_opts || \
        { cat config.log && test_fail "Failed to run 'configure'"; }
35 36 37 38 39
}

build_qemu()
{
    configure_qemu $@
40
    make $MAKEFLAGS
F
Fam Zheng 已提交
41
}
F
Fam Zheng 已提交
42

43 44 45 46 47 48 49 50 51 52 53
check_qemu()
{
    # default to make check unless the caller specifies
    if test -z "$@"; then
        INVOCATION="check"
    else
        INVOCATION="$@"
    fi
    make $MAKEFLAGS $INVOCATION
}

F
Fam Zheng 已提交
54 55 56 57 58 59 60 61 62 63 64
test_fail()
{
    echo "$@"
    exit 1
}

prep_fail()
{
    echo "$@"
    exit 2
}
65 66 67 68 69 70 71 72

install_qemu()
{
    make install $MAKEFLAGS DESTDIR=$PWD/=destdir
    ret=$?
    rm -rf $PWD/=destdir
    return $ret
}