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 14# This might be set by ENV of a docker container... it is always 15# overridden by TARGET_LIST if the user sets it. We special case 16# "none" to allow for other options like --disable-tcg to restrict the 17# builds we eventually do. 18if test "$DEF_TARGET_LIST" = "none"; then 19 DEF_TARGET_LIST="" 20else 21 DEF_TARGET_LIST=${DEF_TARGET_LIST:-"x86_64-softmmu,aarch64-softmmu"} 22fi 23 24enable_rust="" 25if [ "$ENABLE_RUST" = "1" ]; then 26 enable_rust="--enable-rust" 27 if [ -n "$RUST_TARGET" ]; then 28 enable_rust="$enable_rust --rust-target-triple=$RUST_TARGET" 29 fi 30fi 31 32requires_binary() 33{ 34 found=0 35 for c in $@; do 36 for d in /bin /usr/bin /usr/local/bin 37 do 38 if test -f "$d/$c" 39 then 40 found=1 41 fi 42 done 43 done 44 if test "$found" != "1" 45 then 46 echo "Prerequisite '$c' not present, skip" 47 exit 0 48 fi 49} 50 51configure_qemu() 52{ 53 config_opts="--enable-werror \ 54 ${TARGET_LIST:+--target-list=${TARGET_LIST}} \ 55 --prefix=$INSTALL_DIR \ 56 $enable_rust \ 57 $QEMU_CONFIGURE_OPTS $EXTRA_CONFIGURE_OPTS \ 58 $@" 59 echo "Configure options:" 60 echo $config_opts 61 $QEMU_SRC/configure $config_opts || \ 62 { cat config.log >&2 ; cat meson-logs/meson-log.txt >&2 ; test_fail "Failed to run 'configure'"; } 63} 64 65build_qemu() 66{ 67 configure_qemu $@ 68 make $MAKEFLAGS 69} 70 71check_qemu() 72{ 73 # default to make check unless the caller specifies 74 if [ $# = 0 ]; then 75 INVOCATION="${TEST_COMMAND:-make $MAKEFLAGS check}" 76 else 77 INVOCATION="make $MAKEFLAGS $@" 78 fi 79 80 $INVOCATION 81} 82 83test_fail() 84{ 85 echo "$@" >&2 86 exit 1 87} 88 89prep_fail() 90{ 91 echo "$@" 92 exit 2 93} 94 95install_qemu() 96{ 97 make install $MAKEFLAGS DESTDIR=$PWD/=destdir 98 ret=$? 99 rm -rf $PWD/=destdir 100 return $ret 101} 102