summaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/check
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2014-05-24 23:24:55 +0200
committerKevin Wolf <kwolf@redhat.com>2014-06-27 20:00:00 +0200
commite8f8624d3b920de968c56e76691f419b16d1ee4a (patch)
treed40969767d80552df97ef222ace32f3e1f1df5d5 /tests/qemu-iotests/check
parent6b8aeca574a15668c47296d8e0c4f96c72e63c36 (diff)
downloadqemu-e8f8624d3b920de968c56e76691f419b16d1ee4a.zip
iotests: Allow out-of-tree run
As out-of-tree builds are preferred for qemu, running the qemu-iotests in that out-of-tree build should be supported as well. To do so, a symbolic link has to be created pointing to the check script in the source directory. That script will check whether it has been run through a symlink, and if so, will assume it is run in the build tree. All output and temporary operations performed by iotests are then redirected here and, unless specified otherwise by the user, QEMU_PROG etc. will be set to paths appropriate for the build tree. Also, drop making every test case executable if it is not yet, as this would modify the source tree which is not desired for out-of-tree runs and should be fixed in the repository anyway. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/check')
-rwxr-xr-xtests/qemu-iotests/check98
1 files changed, 83 insertions, 15 deletions
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index e2ed5a95f8..69f328b57c 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -34,22 +34,89 @@ timestamp=${TIMESTAMP:=false}
# generic initialization
iam=check
+_init_error()
+{
+ echo "$iam: $1" >&2
+ exit 1
+}
+
+if [ -L "$0" ]
+then
+ # called from the build tree
+ source_iotests=$(dirname "$(readlink "$0")")
+ if [ -z "$source_iotests" ]
+ then
+ _init_error "failed to obtain source tree name from check symlink"
+ fi
+ source_iotests=$(cd "$source_iotests"; pwd) || _init_error "failed to enter source tree"
+ build_iotests=$PWD
+else
+ # called from the source tree
+ source_iotests=$PWD
+ # this may be an in-tree build (note that in the following code we may not
+ # assume that it truly is and have to test whether the build results
+ # actually exist)
+ build_iotests=$PWD
+fi
+
+build_root="$build_iotests/../.."
+
+if [ -x "$build_iotests/socket_scm_helper" ]
+then
+ export SOCKET_SCM_HELPER="$build_iotests/socket_scm_helper"
+fi
+
+# if ./qemu exists, it should be prioritized and will be chosen by common.config
+if [[ -z "$QEMU_PROG" && ! -x './qemu' ]]
+then
+ arch=$(uname -m 2> /dev/null)
+
+ if [[ -n $arch && -x "$build_root/$arch-softmmu/qemu-system-$arch" ]]
+ then
+ export QEMU_PROG="$build_root/$arch-softmmu/qemu-system-$arch"
+ else
+ pushd "$build_root" > /dev/null
+ for binary in *-softmmu/qemu-system-*
+ do
+ if [ -x "$binary" ]
+ then
+ export QEMU_PROG="$build_root/$binary"
+ break
+ fi
+ done
+ popd > /dev/null
+ fi
+fi
+
+if [[ -z $QEMU_IMG_PROG && -x "$build_root/qemu-img" && ! -x './qemu-img' ]]
+then
+ export QEMU_IMG_PROG="$build_root/qemu-img"
+fi
+
+if [[ -z $QEMU_IO_PROG && -x "$build_root/qemu-io" && ! -x './qemu-io' ]]
+then
+ export QEMU_IO_PROG="$build_root/qemu-io"
+fi
+
+if [[ -z $QEMU_NBD_PROG && -x "$build_root/qemu-nbd" && ! -x './qemu-nbd' ]]
+then
+ export QEMU_NBD_PROG="$build_root/qemu-nbd"
+fi
+
# we need common.config
-if ! . ./common.config
+if ! . "$source_iotests/common.config"
then
- echo "$iam: failed to source common.config"
- exit 1
+ _init_error "failed to source common.config"
fi
# we need common.rc
-if ! . ./common.rc
+if ! . "$source_iotests/common.rc"
then
- echo "check: failed to source common.rc"
- exit 1
+ _init_error "failed to source common.rc"
fi
# we need common
-. ./common
+. "$source_iotests/common"
#if [ `id -u` -ne 0 ]
#then
@@ -194,7 +261,7 @@ do
echo " - expunged"
rm -f $seq.out.bad
echo "/^$seq\$/d" >>$tmp.expunged
- elif [ ! -f $seq ]
+ elif [ ! -f "$source_iotests/$seq" ]
then
echo " - no such test?"
echo "/^$seq\$/d" >>$tmp.expunged
@@ -215,9 +282,10 @@ do
start=`_wallclock`
$timestamp && echo -n " ["`date "+%T"`"]"
- [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
+ export OUTPUT_DIR=$PWD
+ (cd "$source_iotests";
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
- ./$seq >$tmp.out 2>&1
+ ./$seq >$tmp.out 2>&1)
sts=$?
$timestamp && _timestamp
stop=`_wallclock`
@@ -242,17 +310,17 @@ do
err=true
fi
- reference=$seq.out
+ reference="$source_iotests/$seq.out"
if [ "$CACHEMODE" = "none" ]; then
- [ -f $seq.out.nocache ] && reference=$seq.out.nocache
+ [ -f "$source_iotests/$seq.out.nocache" ] && reference="$source_iotests/$seq.out.nocache"
fi
- if [ ! -f $reference ]
+ if [ ! -f "$reference" ]
then
echo " - no qualified output"
err=true
else
- if diff -w $reference $tmp.out >/dev/null 2>&1
+ if diff -w "$reference" $tmp.out >/dev/null 2>&1
then
echo ""
if $err
@@ -264,7 +332,7 @@ do
else
echo " - output mismatch (see $seq.out.bad)"
mv $tmp.out $seq.out.bad
- $diff -w $reference $seq.out.bad
+ $diff -w "$reference" $seq.out.bad
err=true
fi
fi