xref: /openbmc/qemu/tests/docker/common.rc (revision 3f9747a73891e50d9c09d2fc3dbba6f1fdd03a13)
1#!/bin/sh
2#
3# Common routines for docker test scripts.
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
14requires()
15{
16    for c in $@; do
17        if ! echo "$FEATURES" | grep -wq -e "$c"; then
18            echo "Prerequisite '$c' not present, skip"
19            exit 0
20        fi
21    done
22}
23
24configure_qemu()
25{
26    config_opts="--enable-werror \
27                 ${TARGET_LIST:+--target-list=${TARGET_LIST}} \
28                 --prefix=$INSTALL_DIR \
29                 $QEMU_CONFIGURE_OPTS $EXTRA_CONFIGURE_OPTS \
30                 $@"
31    echo "Configure options:"
32    echo $config_opts
33    $QEMU_SRC/configure $config_opts || \
34        { cat config.log && test_fail "Failed to run 'configure'"; }
35}
36
37build_qemu()
38{
39    configure_qemu $@
40    make $MAKEFLAGS
41}
42
43check_qemu()
44{
45    # default to make check unless the caller specifies
46    if test -z "$@"; then
47        INVOCATION="check"
48    else
49        INVOCATION="$@"
50    fi
51    make $MAKEFLAGS $INVOCATION
52}
53
54test_fail()
55{
56    echo "$@"
57    exit 1
58}
59
60prep_fail()
61{
62    echo "$@"
63    exit 2
64}
65
66install_qemu()
67{
68    make install $MAKEFLAGS DESTDIR=$PWD/=destdir
69    ret=$?
70    rm -rf $PWD/=destdir
71    return $ret
72}
73