cceaf1db6f
Instead of ./check failing when a binary is missing, we try each test case now and each one fails with tons of test case diffs. Also, all the variables were initialized by "check" prior to "common" being sourced, and then (uselessly) checked for emptiness again in "check". Centralize the search for programs in "common" (which will soon be one with "check"), including the "realpath" invocation which can be done just once in "check" rather than in the tests. For qnio_server, move the detection to "common", simplifying set_prog_path to stop handling the unused second argument, and embedding the "realpath" pass. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
157 lines
3.7 KiB
Bash
157 lines
3.7 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Copyright (C) 2009 Red Hat, Inc.
|
|
# Copyright (c) 2000-2003,2006 Silicon Graphics, Inc. All Rights Reserved.
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU General Public License as
|
|
# published by the Free Software Foundation.
|
|
#
|
|
# This program is distributed in the hope that it would be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# all tests should use a common language setting to prevent golden
|
|
# output mismatches.
|
|
export LANG=C
|
|
|
|
PATH=".:$PATH"
|
|
|
|
HOSTOS=`uname -s`
|
|
arch=`uname -m`
|
|
|
|
export PWD=`pwd`
|
|
|
|
export _QEMU_HANDLE=0
|
|
|
|
# make sure we have a standard umask
|
|
umask 022
|
|
|
|
_optstr_add()
|
|
{
|
|
if [ -n "$1" ]; then
|
|
echo "$1,$2"
|
|
else
|
|
echo "$2"
|
|
fi
|
|
}
|
|
|
|
_qemu_wrapper()
|
|
{
|
|
(
|
|
if [ -n "${QEMU_NEED_PID}" ]; then
|
|
echo $BASHPID > "${QEMU_TEST_DIR}/qemu-${_QEMU_HANDLE}.pid"
|
|
fi
|
|
exec "$QEMU_PROG" $QEMU_OPTIONS "$@"
|
|
)
|
|
}
|
|
|
|
_qemu_img_wrapper()
|
|
{
|
|
(exec "$QEMU_IMG_PROG" $QEMU_IMG_OPTIONS "$@")
|
|
}
|
|
|
|
_qemu_io_wrapper()
|
|
{
|
|
local VALGRIND_LOGFILE="${TEST_DIR}"/$$.valgrind
|
|
local QEMU_IO_ARGS="$QEMU_IO_OPTIONS"
|
|
if [ "$IMGOPTSSYNTAX" = "true" ]; then
|
|
QEMU_IO_ARGS="--image-opts $QEMU_IO_ARGS"
|
|
if [ -n "$IMGKEYSECRET" ]; then
|
|
QEMU_IO_ARGS="--object secret,id=keysec0,data=$IMGKEYSECRET $QEMU_IO_ARGS"
|
|
fi
|
|
fi
|
|
local RETVAL
|
|
(
|
|
if [ "${VALGRIND_QEMU}" == "y" ]; then
|
|
exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"
|
|
else
|
|
exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"
|
|
fi
|
|
)
|
|
RETVAL=$?
|
|
if [ "${VALGRIND_QEMU}" == "y" ]; then
|
|
if [ $RETVAL == 99 ]; then
|
|
cat "${VALGRIND_LOGFILE}"
|
|
fi
|
|
rm -f "${VALGRIND_LOGFILE}"
|
|
fi
|
|
(exit $RETVAL)
|
|
}
|
|
|
|
_qemu_nbd_wrapper()
|
|
{
|
|
(
|
|
echo $BASHPID > "${QEMU_TEST_DIR}/qemu-nbd.pid"
|
|
exec "$QEMU_NBD_PROG" $QEMU_NBD_OPTIONS "$@"
|
|
)
|
|
}
|
|
|
|
_qemu_vxhs_wrapper()
|
|
{
|
|
(
|
|
echo $BASHPID > "${TEST_DIR}/qemu-vxhs.pid"
|
|
exec "$QEMU_VXHS_PROG" $QEMU_VXHS_OPTIONS "$@"
|
|
)
|
|
}
|
|
|
|
export QEMU=_qemu_wrapper
|
|
export QEMU_IMG=_qemu_img_wrapper
|
|
export QEMU_IO=_qemu_io_wrapper
|
|
export QEMU_NBD=_qemu_nbd_wrapper
|
|
export QEMU_VXHS=_qemu_vxhs_wrapper
|
|
|
|
QEMU_IMG_EXTRA_ARGS=
|
|
if [ "$IMGOPTSSYNTAX" = "true" ]; then
|
|
QEMU_IMG_EXTRA_ARGS="--image-opts $QEMU_IMG_EXTRA_ARGS"
|
|
if [ -n "$IMGKEYSECRET" ]; then
|
|
QEMU_IMG_EXTRA_ARGS="--object secret,id=keysec0,data=$IMGKEYSECRET $QEMU_IMG_EXTRA_ARGS"
|
|
fi
|
|
fi
|
|
export QEMU_IMG_EXTRA_ARGS
|
|
|
|
|
|
default_machine=$($QEMU -machine help | sed -n '/(default)/ s/ .*//p')
|
|
default_alias_machine=$($QEMU -machine help | \
|
|
sed -n "/(alias of $default_machine)/ { s/ .*//p; q; }")
|
|
if [[ "$default_alias_machine" ]]; then
|
|
default_machine="$default_alias_machine"
|
|
fi
|
|
|
|
export QEMU_DEFAULT_MACHINE="$default_machine"
|
|
|
|
if [ -z "$TEST_DIR" ]; then
|
|
TEST_DIR=`pwd`/scratch
|
|
fi
|
|
|
|
QEMU_TEST_DIR="${TEST_DIR}"
|
|
|
|
if [ ! -e "$TEST_DIR" ]; then
|
|
mkdir "$TEST_DIR"
|
|
fi
|
|
|
|
if [ ! -d "$TEST_DIR" ]; then
|
|
echo "common.config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
|
|
exit 1
|
|
fi
|
|
|
|
export TEST_DIR
|
|
|
|
if [ -z "$SAMPLE_IMG_DIR" ]; then
|
|
SAMPLE_IMG_DIR="$source_iotests/sample_images"
|
|
fi
|
|
|
|
if [ ! -d "$SAMPLE_IMG_DIR" ]; then
|
|
echo "common.config: Error: \$SAMPLE_IMG_DIR ($SAMPLE_IMG_DIR) is not a directory"
|
|
exit 1
|
|
fi
|
|
|
|
export SAMPLE_IMG_DIR
|
|
|
|
# make sure this script returns success
|
|
true
|