iotests: Allow out-of-tree run
cover iotests: Allow out-of-tree run
This series enables qemu-iotests to be run in a build tree outside of the source tree. It also makes the tests use the command for invoking the Python interpreter specified through configure instead of always using "/usr/bin/env python".
Max Reitz (7):
iotests: Allow out-of-tree run
configure: Enable out-of-tree iotests
iotests: Add default common.env
iotests: Source common.env
iotests: Use $PYTHON for Python scripts
iotests: Drop Python version from 065's Shebang
iotests: Fix 083 for out-of-tree builds
configure | 12 ++++ tests/qemu-iotests/031 | 8 +-- tests/qemu-iotests/036 | 6 +- tests/qemu-iotests/039 | 18 +++--- tests/qemu-iotests/054 | 2 +- tests/qemu-iotests/060 | 20 +++---- tests/qemu-iotests/061 | 24 ++++---- tests/qemu-iotests/065 | 2 +- tests/qemu-iotests/083 | 10 ++-- tests/qemu-iotests/check | 102 ++++++++++++++++++++++++++++++---- tests/qemu-iotests/common | 8 +-- tests/qemu-iotests/common.config | 2 +- tests/qemu-iotests/common.env.default | 6 ++ tests/qemu-iotests/common.rc | 8 +-- tests/qemu-iotests/iotests.py | 3 +- 15 files changed, 165 insertions(+), 66 deletions(-) create mode 100644 tests/qemu-iotests/common.env.default
Signature · 1 line
1.9.2
PATCH 1/7 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.
--- tests/qemu-iotests/check | 78 ++++++++++++++++++++++++++++++++++------ tests/qemu-iotests/common | 8 ++--- tests/qemu-iotests/common.config | 2 +- tests/qemu-iotests/common.rc | 8 ++--- tests/qemu-iotests/iotests.py | 3 +- 5 files changed, 78 insertions(+), 21 deletions(-)
tests/qemu-iotests/check +67 -11
@@ -34,22 +34,77 @@ timestamp=${TIMESTAMP:=false} # generic initialization iam=check +if [ -L "$0" ] +then + # called from the build tree + source_iotests="$(cd "$(dirname "$(readlink "$0")")"; pwd)" + build_iotests="$PWD" + build_root="$build_iotests/../.." + + if [ -x "$build_iotests/socket_scm_helper" ] + then + export SOCKET_SCM_HELPER="$build_iotests/socket_scm_helper" + fi +else + # called from the source tree + source_iotests="$PWD" +fi + +if [ -n "$build_root" ] +then + if [ -z "$QEMU_PROG" ] + then + arch="$(uname -m 2> /dev/null)" + + if [ -n "$arch" -a -x "$build_root/$arch-softmmu/qemu-system-$arch" ] + then + export QEMU_PROG="$build_root/$arch-softmmu/qemu-system-$arch" + else + pushd -q "$build_root" + for binary in "*-softmmu/qemu-system-*" + do + if [ -x "$binary" ] + then + export QEMU_PROG="$build_root/$binary" + break + fi + done + popd -q + fi + fi + + if [ -z "$QEMU_IMG_PROG" -a -x "$build_root/qemu-img" ] + then + export QEMU_IMG_PROG="$build_root/qemu-img" + fi + + if [ -z "$QEMU_IO_PROG" -a -x "$build_root/qemu-io" ] + then + export QEMU_IO_PROG="$build_root/qemu-io" + fi + + if [ -z "$QEMU_NBD_PROG" -a -x "$build_root/qemu-nbd" ] + then + export QEMU_NBD_PROG="$build_root/qemu-nbd" + fi +fi + # we need common.config -if ! . ./common.config +if ! . "$source_iotests/common.config" then echo "$iam: failed to source common.config" exit 1 fi # we need common.rc -if ! . ./common.rc +if ! . "$source_iotests/common.rc" then echo "check: failed to source common.rc" exit 1 fi # we need common -. ./common +. "$source_iotests/common" #if [ `id -u` -ne 0 ] #then
@@ -194,7 +249,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 +270,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 +298,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 +320,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
tests/qemu-iotests/common +4 -4
@@ -59,7 +59,7 @@ do if $group then # arg after -g - group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{ + group_list=`sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{ s/ .*//p }'` if [ -z "$group_list" ]
@@ -84,7 +84,7 @@ s/ .*//p then # arg after -x [ ! -s $tmp.list ] && ls [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] >$tmp.list 2>/dev/null - group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{ + group_list=`sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{ s/ .*//p }'` if [ -z "$group_list" ]
@@ -366,7 +366,7 @@ testlist options BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \ | while read id do - if grep -s "^$id " group >/dev/null + if grep -s "^$id " "$source_iotests/group" >/dev/null then # in group file ... OK echo $id >>$tmp.list
@@ -402,7 +402,7 @@ else touch $tmp.list else # no test numbers, do everything from group file - sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list + sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <"$source_iotests/group" >$tmp.list fi fi
tests/qemu-iotests/common.config +1 -1
@@ -126,7 +126,7 @@ fi export TEST_DIR if [ -z "$SAMPLE_IMG_DIR" ]; then - SAMPLE_IMG_DIR=`pwd`/sample_images + SAMPLE_IMG_DIR="$source_iotests/sample_images" fi if [ ! -d "$SAMPLE_IMG_DIR" ]; then
tests/qemu-iotests/common.rc +4 -4
@@ -318,9 +318,9 @@ _do() status=1; exit fi - (eval "echo '---' \"$_cmd\"") >>$here/$seq.full + (eval "echo '---' \"$_cmd\"") >>"$OUTPUT_DIR/$seq.full" (eval "$_cmd") >$tmp._out 2>&1; ret=$? - cat $tmp._out >>$here/$seq.full + cat $tmp._out >>"$OUTPUT_DIR/$seq.full" if [ $# -eq 2 ]; then if [ $ret -eq 0 ]; then echo "done"
@@ -344,7 +344,7 @@ _do() # _notrun() { - echo "$*" >$seq.notrun + echo "$*" >"$OUTPUT_DIR/$seq.notrun" echo "$seq not run: $*" status=0 exit
@@ -354,7 +354,7 @@ _notrun() # _fail() { - echo "$*" | tee -a $here/$seq.full + echo "$*" | tee -a "$OUTPUT_DIR/$seq.full" echo "(see $seq.full for details)" status=1 exit 1
tests/qemu-iotests/iotests.py +2 -1
@@ -37,6 +37,7 @@ qemu_args = os.environ.get('QEMU', 'qemu').strip().split(' ') imgfmt = os.environ.get('IMGFMT', 'raw') imgproto = os.environ.get('IMGPROTO', 'file') test_dir = os.environ.get('TEST_DIR', '/var/tmp') +output_dir = os.environ.get('OUTPUT_DIR', '.') cachemode = os.environ.get('CACHEMODE') socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper')
@@ -278,7 +279,7 @@ def notrun(reason): # Each test in qemu-iotests has a number ("seq") seq = os.path.basename(sys.argv[0]) - open('%s.notrun' % seq, 'wb').write(reason + '\n') + open('%s/%s.notrun' % (output_dir, seq), 'wb').write(reason + '\n') print '%s not run: %s' % (seq, reason) sys.exit(0)
Signature · 1 line
1.9.2
Quoted 14 lines · Max Reitz
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_PROGetc. will be set to paths appropriate for the build tree.Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/check | 78 ++++++++++++++++++++++++++++++++++------
tests/qemu-iotests/check timestamp=${TIMESTAMP:=false} · line 40
Quoted 4 lines
tests/qemu-iotests/check +4
-0+if [ -L "$0" ] +then + # called from the build tree + source_iotests="$(cd "$(dirname "$(readlink "$0")")"; pwd)"
This is potentially dangerous. If readlink or dirname fails, you can invoke cd "" (which on bash is stupidly a no-op instead of an error), and end up calling pwd in the wrong directory. But in the common case it works, so I'm not sure it's worth bending over backwards to make it more robust.
Quoted 1 line
+ if [ -n "$arch" -a -x "$build_root/$arch-softmmu/qemu-system-$arch" ]
-a and -o are NOT portable inside []; POSIX strongly discourages their use because they can cause ambiguous parses:
Is [ ! '(' -o ')' ] true or false? Depends on whether it was parsed as { ! '(' } -o ')' (false -o true => true) or as ! { '(' -o ')' } (! (true -o true) => false)
But this is bash, so you could do:
if [[ $arch && -x $build_root/$arch-softmmu/qemu-system-$arch ]]
for less typing, and no risk of [] ambiguity.
tests/qemu-iotests/common.rc _do() · line 322
Quoted 8 lines
+++ b/tests/qemu-iotests/common.rc
tests/qemu-iotests/common.rc +1
-1@@ -318,9 +318,9 @@ _do() status=1; exit fi - (eval "echo '---' \"$_cmd\"") >>$here/$seq.full + (eval "echo '---' \"$_cmd\"") >>"$OUTPUT_DIR/$seq.full" (eval "$_cmd") >$tmp._out 2>&1; ret=$?
Pre-existing, but we're using 'eval'? That's probably a security risk if $_cmd can contain user-controlled text, such as an odd directory name.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 14 lines · Eric Blake
Quoted 13 lines · Max Reitz
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_PROGetc. will be set to paths appropriate for the build tree.Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/check | 78 ++++++++++++++++++++++++++++++++++------
Quoted 9 lines
tests/qemu-iotests/check timestamp=${TIMESTAMP:=false} · line 40
Quoted 4 lines
tests/qemu-iotests/check +4
-0+if [ -L "$0" ] +then + # called from the build tree + source_iotests="$(cd "$(dirname "$(readlink "$0")")"; pwd)"This is potentially dangerous. If readlink or dirname fails, you can invoke cd "" (which on bash is stupidly a no-op instead of an error), and end up calling pwd in the wrong directory. But in the common case it works, so I'm not sure it's worth bending over backwards to make it more robust.
I guess using something like
source_iotests="$(dirname "$(readlink "$0")")"; if [ -z "$source_iotests" ]; then; /* abort */; fi; source_iotests="$(cd "$dirname"; pwd)"
should work better, then?
Quoted 3 lines
Quoted 1 line
+ if [ -n "$arch" -a -x "$build_root/$arch-softmmu/qemu-system-$arch" ]
-a and -o are NOT portable inside []; POSIX strongly discourages their use because they can cause ambiguous parses:
Hm, I remembered you telling me something about -a before and looked in test's manpage but couldn't find anything bad. Well, it's the GNU manpage…
Quoted 9 lines
Is [ ! '(' -o ')' ] true or false? Depends on whether it was parsed as { ! '(' } -o ')' (false -o true => true) or as ! { '(' -o ')' } (! (true -o true) => false)
But this is bash, so you could do:
if [[ $arch && -x $build_root/$arch-softmmu/qemu-system-$arch ]]
for less typing, and no risk of [] ambiguity.
If you're telling me I'm free to use bashisms, I'll believe you. :-)
Quoted 10 lines
tests/qemu-iotests/common.rc _do() · line 322
Quoted 8 lines
+++ b/tests/qemu-iotests/common.rc
tests/qemu-iotests/common.rc +1
-1@@ -318,9 +318,9 @@ _do() status=1; exit fi - (eval "echo '---' \"$_cmd\"") >>$here/$seq.full + (eval "echo '---' \"$_cmd\"") >>"$OUTPUT_DIR/$seq.full" (eval "$_cmd") >$tmp._out 2>&1; ret=$?Pre-existing, but we're using 'eval'? That's probably a security risk if $_cmd can contain user-controlled text, such as an odd directory name.
Actually, I don't even see that function ("_do") being used anywhere in the iotests. We could probably drop it.
But the eval should be of no harm, as it is the intention of this function "_do" to execute the function given as a parameter. If anyone should make sure, this eval does not execute user-controlled text, it is the code using _do, I think.
Max
Quoted 7 lines · Max Reitz
Quoted 6 lines
Quoted 1 line
+ source_iotests="$(cd "$(dirname "$(readlink "$0")")"; pwd)"
This is potentially dangerous. If readlink or dirname fails, you can invoke cd "" (which on bash is stupidly a no-op instead of an error), and end up calling pwd in the wrong directory. But in the common case it works, so I'm not sure it's worth bending over backwards to make it more robust.
Quoted 6 lines
I guess using something like
source_iotests="$(dirname "$(readlink "$0")")"; if [ -z "$source_iotests" ]; then; /* abort */; fi; source_iotests="$(cd "$dirname"; pwd)"
should work better, then?
Or even safer with
source_iotests=$(cd "$dirname" && pwd) || /* abort */
in the second step, to ensure both the cd and pwd commands succeeded. (By the way, assignment context does not require "" when passing a single shell word, such as command substitution, so foo=$(...) and foo="$(...)" are identical)
Quoted 5 lines
Quoted 5 lines
Is [ ! '(' -o ')' ] true or false? Depends on whether it was parsed as { ! '(' } -o ')' (false -o true => true) or as ! { '(' -o ')' } (! (true -o true) => false)
Quoted 7 lines
Quoted 5 lines
But this is bash, so you could do:
if [[ $arch && -x $build_root/$arch-softmmu/qemu-system-$arch ]]
for less typing, and no risk of [] ambiguity.
If you're telling me I'm free to use bashisms, I'll believe you. :-)
Well, the script IS being run by /bin/bash, and you already ARE using bashisms elsewhere.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 14 lines · Eric Blake
Quoted 6 lines · Max Reitz
Quoted 6 lines
Quoted 1 line
+ source_iotests="$(cd "$(dirname "$(readlink "$0")")"; pwd)"
This is potentially dangerous. If readlink or dirname fails, you can invoke cd "" (which on bash is stupidly a no-op instead of an error), and end up calling pwd in the wrong directory. But in the common case it works, so I'm not sure it's worth bending over backwards to make it more robust.
Quoted 6 lines
I guess using something like
source_iotests="$(dirname "$(readlink "$0")")"; if [ -z "$source_iotests" ]; then; /* abort */; fi; source_iotests="$(cd "$dirname"; pwd)"
should work better, then?
Quoted 8 lines
Or even safer with
source_iotests=$(cd "$dirname" && pwd) || /* abort */
in the second step, to ensure both the cd and pwd commands succeeded. (By the way, assignment context does not require "" when passing a single shell word, such as command substitution, so foo=$(...) and foo="$(...)" are identical)
The more you know... (and of course I meant "$source_iotests" in the second step)
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Is [ ! '(' -o ')' ] true or false? Depends on whether it was parsed as { ! '(' } -o ')' (false -o true => true) or as ! { '(' -o ')' } (! (true -o true) => false)
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
But this is bash, so you could do:
if [[ $arch && -x $build_root/$arch-softmmu/qemu-system-$arch ]]
for less typing, and no risk of [] ambiguity.
If you're telling me I'm free to use bashisms, I'll believe you. :-)
Well, the script IS being run by
/bin/bash, and you already ARE using bashisms elsewhere.
I feared so. *g*
Max
PATCH 2/7 configure: Enable out-of-tree iotests
In reply to Max ReitzIn order to allow out-of-tree iotests, create a symlink for the check script in the build tree.
While doing so, also write configured options relevant to the iotests to common.env in the build tree; currently, this is the command to invoke Python 2.
--- configure | 12 ++++++++++++ 1 file changed, 12 insertions(+)
configure +12 -0
@@ -5206,6 +5206,18 @@ if test "$docs" = "yes" ; then mkdir -p QMP fi +# set up qemu-iotests in this build directory +iotests_common_env="tests/qemu-iotests/common.env" +iotests_check="tests/qemu-iotests/check" + +echo "# Automatically generated by configure - do not modify" > "$iotests_common_env" +echo >> "$iotests_common_env" +echo "export PYTHON='$python'" >> "$iotests_common_env" + +if [ ! -e "$iotests_check" ]; then + ln -s "$source_path/$iotests_check" "$iotests_check" +fi + # Save the configure command line for later reuse. cat <<EOD >config.status #!/bin/sh
Signature · 1 line
1.9.2
PATCH 3/7 iotests: Add default common.env
In reply to Max ReitzAdd a default common.env in case the one supposed to be emitted by configure cannot be found.
--- tests/qemu-iotests/common.env.default | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/qemu-iotests/common.env.default
tests/qemu-iotests/common.env.default new file +6 -0
@@ -0,0 +1,6 @@ +if command -v python2 > /dev/null +then + export PYTHON='python2' +else + export PYTHON='python' +fi
Signature · 1 line
1.9.2
PATCH 4/7 iotests: Source common.env
In reply to Max ReitzSource common.env in the iotests' check script. If the one supposed to be created by configure cannot be found, use common.env.default from the source tree.
--- tests/qemu-iotests/check | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
tests/qemu-iotests/check +17 -0
@@ -89,6 +89,23 @@ then fi fi +# we need common.env +if [ -n "$build_iotests" ] +then + configured_common_env="$build_iotests/common.env" +else + configured_common_env="$source_iotests/common.env" +fi + +if ! . "$configured_common_env" +then + if ! . "$source_iotests/common.env.default" + then + echo "$iam: failed to source common.env" + exit 1 + fi +fi + # we need common.config if ! . "$source_iotests/common.config" then
Signature · 1 line
1.9.2
Re: [Qemu-devel] [PATCH 4/7] iotests: Source common.env
Quoted 3 lines · Max Reitz
Source common.env in the iotests' check script. If the one supposed to be created by configure cannot be found, use common.env.default from the source tree.
If configure is supposed to create common.env, but we can't find it here, isn't it a bug of configure? If so, I don't think we need common.env.default, we need an error.
Thanks,
Fam
Quoted 38 lines
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/check | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)tests/qemu-iotests/check +17
-0@@ -89,6 +89,23 @@ then fi fi +# we need common.env +if [ -n "$build_iotests" ] +then + configured_common_env="$build_iotests/common.env" +else + configured_common_env="$source_iotests/common.env" +fi + +if ! . "$configured_common_env" +then + if ! . "$source_iotests/common.env.default" + then + echo "$iam: failed to source common.env" + exit 1 + fi +fi + # we need common.config if ! . "$source_iotests/common.config" thenSignature · 1 line
1.9.2
Re: [Qemu-devel] [PATCH 4/7] iotests: Source common.env
Quoted 7 lines · Fam Zheng
Quoted 3 lines · Max Reitz
Source common.env in the iotests' check script. If the one supposed to be created by configure cannot be found, use common.env.default from the source tree.
If configure is supposed to create common.env, but we can't find it here, isn't it a bug of configure? If so, I don't think we need common.env.default, we need an error.
In fact, I am getting an error. The first . "$configured_common_env" will print an error message, so the user should be informed of something going wrong.
You are right in that this should not happen. However, it may happen if the user decides to run the iotests from the source tree instead of the build tree if he/she is still used to the old way of invoking them. So I think, having a default common.env should solve this without creating new problems.
Max
Quoted 40 lines
Thanks,
FamQuoted 37 lines
Signed-off-by Max Reitz <[email protected]>--- tests/qemu-iotests/check | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)tests/qemu-iotests/check +17
-0@@ -89,6 +89,23 @@ then fi fi +# we need common.env +if [ -n "$build_iotests" ] +then + configured_common_env="$build_iotests/common.env" +else + configured_common_env="$source_iotests/common.env" +fi + +if ! . "$configured_common_env" +then + if ! . "$source_iotests/common.env.default" + then + echo "$iam: failed to source common.env" + exit 1 + fi +fi + # we need common.config if ! . "$source_iotests/common.config" thenSignature · 1 line
1.9.2
PATCH 5/7 iotests: Use $PYTHON for Python scripts
In reply to Max ReitzInstead of invoking Python scripts directly via ./, use $PYTHON to obtain the correct Python interpreter command.
--- tests/qemu-iotests/031 | 8 ++++---- tests/qemu-iotests/036 | 6 +++--- tests/qemu-iotests/039 | 18 +++++++++--------- tests/qemu-iotests/054 | 2 +- tests/qemu-iotests/060 | 20 ++++++++++---------- tests/qemu-iotests/061 | 24 ++++++++++++------------ tests/qemu-iotests/083 | 2 +- tests/qemu-iotests/check | 9 ++++++++- 8 files changed, 48 insertions(+), 41 deletions(-)
tests/qemu-iotests/031 +4 -4
@@ -56,22 +56,22 @@ for IMGOPTS in "compat=0.10" "compat=1.1"; do echo === Create image with unknown header extension === echo _make_test_img 64M - ./qcow2.py "$TEST_IMG" add-header-ext 0x12345678 "This is a test header extension" - ./qcow2.py "$TEST_IMG" dump-header + $PYTHON qcow2.py "$TEST_IMG" add-header-ext 0x12345678 "This is a test header extension" + $PYTHON qcow2.py "$TEST_IMG" dump-header _check_test_img echo echo === Rewrite header with no backing file === echo $QEMU_IMG rebase -u -b "" "$TEST_IMG" - ./qcow2.py "$TEST_IMG" dump-header + $PYTHON qcow2.py "$TEST_IMG" dump-header _check_test_img echo echo === Add a backing file and format === echo $QEMU_IMG rebase -u -b "/some/backing/file/path" -F host_device "$TEST_IMG" - ./qcow2.py "$TEST_IMG" dump-header + $PYTHON qcow2.py "$TEST_IMG" dump-header done # success, all done
tests/qemu-iotests/036 +3 -3
@@ -53,15 +53,15 @@ IMGOPTS="compat=1.1" echo === Create image with unknown autoclear feature bit === echo _make_test_img 64M -./qcow2.py "$TEST_IMG" set-feature-bit autoclear 63 -./qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 63 +$PYTHON qcow2.py "$TEST_IMG" dump-header echo echo === Repair image === echo _check_test_img -r all -./qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header # success, all done echo "*** done"
tests/qemu-iotests/039 +9 -9
@@ -58,7 +58,7 @@ _make_test_img $size $QEMU_IO -c "write -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io # The dirty bit must not be set -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features _check_test_img echo
@@ -73,7 +73,7 @@ $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io ulimit -c "$old_ulimit" # The dirty bit must be set -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features _check_test_img echo
@@ -82,7 +82,7 @@ echo "== Read-only access must still work ==" $QEMU_IO -r -c "read -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io # The dirty bit must be set -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features echo echo "== Repairing the image file must succeed =="
@@ -90,7 +90,7 @@ echo "== Repairing the image file must succeed ==" _check_test_img -r all # The dirty bit must not be set -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features echo echo "== Data should still be accessible after repair =="
@@ -109,12 +109,12 @@ $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io ulimit -c "$old_ulimit" # The dirty bit must be set -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features $QEMU_IO -c "write 0 512" "$TEST_IMG" | _filter_qemu_io # The dirty bit must not be set -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features echo echo "== Creating an image file with lazy_refcounts=off =="
@@ -128,7 +128,7 @@ $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io ulimit -c "$old_ulimit" # The dirty bit must not be set since lazy_refcounts=off -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features _check_test_img echo
@@ -144,8 +144,8 @@ $QEMU_IO -c "write 0 512" "$TEST_IMG" | _filter_qemu_io $QEMU_IMG commit "$TEST_IMG" # The dirty bit must not be set -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features -./qcow2.py "$TEST_IMG".base dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG".base dump-header | grep incompatible_features _check_test_img TEST_IMG="$TEST_IMG".base _check_test_img
tests/qemu-iotests/054 +1 -1
@@ -49,7 +49,7 @@ _make_test_img $((1024*1024))T echo echo "creating too large image (1 EB) using qcow2.py" _make_test_img 4G -./qcow2.py "$TEST_IMG" set-header size $((1024 ** 6)) +$PYTHON qcow2.py "$TEST_IMG" set-header size $((1024 ** 6)) _check_test_img # success, all done
tests/qemu-iotests/060 +10 -10
@@ -68,13 +68,13 @@ poke_file "$TEST_IMG" "$l1_offset" "\x80\x00\x00\x00\x00\x03\x00\x00" _check_test_img # The corrupt bit should not be set anyway -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features # Try to write something, thereby forcing the corrupt bit to be set $QEMU_IO -c "$OPEN_RW" -c "write -P 0x2a 0 512" | _filter_qemu_io # The corrupt bit must now be set -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features # Try to open the image R/W (which should fail) $QEMU_IO -c "$OPEN_RW" -c "read 0 512" 2>&1 | _filter_qemu_io \
@@ -99,19 +99,19 @@ poke_file "$TEST_IMG" "$(($rb_offset+8))" "\x00\x01" # Redirect new data cluster onto refcount block poke_file "$TEST_IMG" "$l2_offset" "\x80\x00\x00\x00\x00\x02\x00\x00" _check_test_img -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features $QEMU_IO -c "$OPEN_RW" -c "write -P 0x2a 0 512" | _filter_qemu_io -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features # Try to fix it _check_test_img -r all # The corrupt bit should be cleared -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features # Look if it's really really fixed $QEMU_IO -c "$OPEN_RW" -c "write -P 0x2a 0 512" | _filter_qemu_io -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features echo echo "=== Testing cluster data reference into inactive L2 table ==="
@@ -124,13 +124,13 @@ $QEMU_IO -c "$OPEN_RW" -c "write -P 2 0 512" | _filter_qemu_io poke_file "$TEST_IMG" "$l2_offset_after_snapshot" \ "\x80\x00\x00\x00\x00\x04\x00\x00" _check_test_img -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features $QEMU_IO -c "$OPEN_RW" -c "write -P 3 0 512" | _filter_qemu_io -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features _check_test_img -r all -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features $QEMU_IO -c "$OPEN_RW" -c "write -P 4 0 512" | _filter_qemu_io -./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features # Check data $QEMU_IO -c "$OPEN_RO" -c "read -P 4 0 512" | _filter_qemu_io
tests/qemu-iotests/061 +12 -12
@@ -48,9 +48,9 @@ echo "=== Testing version downgrade with zero expansion ===" echo IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io -./qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" -./qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io _check_test_img
@@ -59,9 +59,9 @@ echo "=== Testing dirty version downgrade ===" echo IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M $QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" | _filter_qemu_io -./qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" -./qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io _check_test_img
@@ -69,11 +69,11 @@ echo echo "=== Testing version downgrade with unknown compat/autoclear flags ===" echo IMGOPTS="compat=1.1" _make_test_img 64M -./qcow2.py "$TEST_IMG" set-feature-bit compatible 42 -./qcow2.py "$TEST_IMG" set-feature-bit autoclear 42 -./qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" set-feature-bit compatible 42 +$PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 42 +$PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" -./qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header _check_test_img echo
@@ -81,9 +81,9 @@ echo "=== Testing version upgrade and resize ===" echo IMGOPTS="compat=0.10" _make_test_img 64M $QEMU_IO -c "write -P 0x2a 42M 64k" "$TEST_IMG" | _filter_qemu_io -./qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IMG amend -o "compat=1.1,lazy_refcounts=on,size=128M" "$TEST_IMG" -./qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IO -c "read -P 0x2a 42M 64k" "$TEST_IMG" | _filter_qemu_io _check_test_img
@@ -92,9 +92,9 @@ echo "=== Testing dirty lazy_refcounts=off ===" echo IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M $QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" | _filter_qemu_io -./qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IMG amend -o "lazy_refcounts=off" "$TEST_IMG" -./qcow2.py "$TEST_IMG" dump-header +$PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io _check_test_img
tests/qemu-iotests/083 +1 -1
@@ -81,7 +81,7 @@ EOF nbd_url="nbd:127.0.0.1:$port:exportname=foo" fi - ./nbd-fault-injector.py $extra_args "127.0.0.1:$port" "$TEST_DIR/nbd-fault-injector.conf" 2>&1 >/dev/null & + $PYTHON nbd-fault-injector.py $extra_args "127.0.0.1:$port" "$TEST_DIR/nbd-fault-injector.conf" 2>&1 >/dev/null & wait_for_tcp_port "127.0.0.1:$port" $QEMU_IO -c "read 0 512" "$nbd_url" 2>&1 | _filter_qemu_io | filter_nbd
tests/qemu-iotests/check +8 -1
@@ -287,10 +287,17 @@ do start=`_wallclock` $timestamp && echo -n " ["`date "+%T"`"]" + + if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then + run_command="$PYTHON $seq" + else + [ ! -x "$source_iotests/$seq" ] && chmod u+x "$source_iotests/$seq" # ensure we can run it + run_command="./$seq" + fi export OUTPUT_DIR="$PWD" (cd "$source_iotests"; MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \ - ./$seq >$tmp.out 2>&1) + $run_command >$tmp.out 2>&1) sts=$? $timestamp && _timestamp stop=`_wallclock`
Signature · 1 line
1.9.2
Re: [Qemu-devel] [PATCH 5/7] iotests: Use $PYTHON for Python scripts
tests/qemu-iotests/check do · line 294
Quoted 13 lines · Max Reitz
tests/qemu-iotests/check +5
-0@@ -287,10 +287,17 @@ do start=`_wallclock` $timestamp && echo -n " ["`date "+%T"`"]" + + if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then + run_command="$PYTHON $seq" + else + [ ! -x "$source_iotests/$seq" ] && chmod u+x "$source_iotests/$seq" # ensure we can run it
No, I don't think we need chmod here, to change source tree. If the mode has no x bit, we need a git commit to fix it.
Fam
Quoted 14 lines
tests/qemu-iotests/check +3
-1+ run_command="./$seq" + fi export OUTPUT_DIR="$PWD" (cd "$source_iotests"; MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \ - ./$seq >$tmp.out 2>&1) + $run_command >$tmp.out 2>&1) sts=$? $timestamp && _timestamp stop=`_wallclock`Signature · 1 line
1.9.2
Re: [Qemu-devel] [PATCH 5/7] iotests: Use $PYTHON for Python scripts
Quoted 7 lines · Fam Zheng
Quoted 6 lines · Max Reitz
tests/qemu-iotests/check +0
-0@@ -287,10 +287,17 @@ do
Quoted 9 lines
tests/qemu-iotests/check do · line 294
Quoted 7 lines
tests/qemu-iotests/check +5
-0start=`_wallclock` $timestamp && echo -n " ["`date "+%T"`"]" + + if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then + run_command="$PYTHON $seq" + else + [ ! -x "$source_iotests/$seq" ] && chmod u+x "$source_iotests/$seq" # ensure we can run itNo, I don't think we need chmod here, to change source tree. If the mode has no x bit, we need a git commit to fix it.
This is in fact due to a mistake of mine when splitting the commits. In patch 1, there is a hunk with:
- [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
This should actually be part of this patch instead, so it is preexisting. However, you are right in that we should probably not do this, especially not for out-of-tree builds. I'll drop it from v2, if there are no objections.
Max
Quoted 16 lines
Fam
Quoted 14 lines
tests/qemu-iotests/check +3
-1+ run_command="./$seq" + fi export OUTPUT_DIR="$PWD" (cd "$source_iotests"; MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \ - ./$seq >$tmp.out 2>&1) + $run_command >$tmp.out 2>&1) sts=$? $timestamp && _timestamp stop=`_wallclock`Signature · 1 line
1.9.2
PATCH 6/7 iotests: Drop Python version from 065's Shebang
In reply to Max ReitzTest 065 specified python2 to be used in its Shebang; this might not work on systems without a python2 symlink and furthermore it is now counter-productive, as the check script compares the Shebang to "#!/usr/bin/env python" and only uses the Python interpreter selected by configure on an exact match.
--- tests/qemu-iotests/065 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qemu-iotests/065 +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python # # Test for additional information emitted by qemu-img info on qcow2 # images
Signature · 1 line
1.9.2
PATCH 7/7 iotests: Fix 083 for out-of-tree builds
In reply to Max Reitziotest 083 filters out debug messages from nbd, which are prefixed (and recognized) by __FILE__. However, the current filter (/^nbd\.c…/) is valid for in-tree builds only, as out-of-tree builds will have a path before that filename (e.g. "/tmp/qemu/nbd.c"). Fix this by adding .* before "nbd\.c".
While working on this, also fix the regexes: '.' should be escaped and a single backslash is not enough for escaping when enclosed by double quotes.
--- tests/qemu-iotests/083 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tests/qemu-iotests/083 +4 -4
@@ -44,7 +44,7 @@ choose_tcp_port() { wait_for_tcp_port() { while ! (netstat --tcp --listening --numeric | \ - grep "$1.*0.0.0.0:\*.*LISTEN") 2>&1 >/dev/null; do + grep "$1.*0\\.0\\.0\\.0:\\*.*LISTEN") 2>&1 >/dev/null; do sleep 0.1 done }
@@ -55,8 +55,8 @@ filter_nbd() { # callbacks sometimes, making them unreliable. # # Filter out the TCP port number since this changes between runs. - sed -e 's#^nbd.c:.*##g' \ - -e 's#nbd:127.0.0.1:[^:]*:#nbd:127.0.0.1:PORT:#g' + sed -e 's#^.*nbd\.c:.*##g' \ + -e 's#nbd:127\.0\.0\.1:[^:]*:#nbd:127\.0\.0\.1:PORT:#g' } check_disconnect() {
@@ -82,7 +82,7 @@ EOF fi $PYTHON nbd-fault-injector.py $extra_args "127.0.0.1:$port" "$TEST_DIR/nbd-fault-injector.conf" 2>&1 >/dev/null & - wait_for_tcp_port "127.0.0.1:$port" + wait_for_tcp_port "127\\.0\\.0\\.1:$port" $QEMU_IO -c "read 0 512" "$nbd_url" 2>&1 | _filter_qemu_io | filter_nbd echo
Signature · 1 line
1.9.2
Quoted 2 lines · Max Reitz
This series enables qemu-iotests to be run in a build tree outside of the source tree.
Yes, I've always used the long command to run iotests, namely,
$ (cd $SRC_PATH/tests/qemu-iotests; TEST_DIR=/tmp/qemu-iotests QEMU_PROG=~/build/last/x86_64-softmmu/qemu-system-x86_64 QEMU_IMG_PROG=~/build/last/qemu-img QEMU_IO_PROG=~/build/last/qemu-io QEMU_NBD_PROG=~/build/last/qemu-nbd ./check -qcow2 -o "" )
and I hated that. It'd be a great improvement to allow iotests to find the built binaries by itself.
Thanks for working on this!
Fam
Quoted 33 lines
Max Reitz (7):
iotests: Allow out-of-tree run
configure: Enable out-of-tree iotests
iotests: Add default common.env
iotests: Source common.env
iotests: Use $PYTHON for Python scripts
iotests: Drop Python version from 065's Shebang
iotests: Fix 083 for out-of-tree buildsconfigure | 12 ++++ tests/qemu-iotests/031 | 8 +-- tests/qemu-iotests/036 | 6 +- tests/qemu-iotests/039 | 18 +++--- tests/qemu-iotests/054 | 2 +- tests/qemu-iotests/060 | 20 +++---- tests/qemu-iotests/061 | 24 ++++---- tests/qemu-iotests/065 | 2 +- tests/qemu-iotests/083 | 10 ++-- tests/qemu-iotests/check | 102 ++++++++++++++++++++++++++++++---- tests/qemu-iotests/common | 8 +-- tests/qemu-iotests/common.config | 2 +- tests/qemu-iotests/common.env.default | 6 ++ tests/qemu-iotests/common.rc | 8 +-- tests/qemu-iotests/iotests.py | 3 +- 15 files changed, 165 insertions(+), 66 deletions(-) create mode 100644 tests/qemu-iotests/common.env.defaultSignature · 1 line
1.9.2