Max,

Just a common question for this case, if sshx block driver wasn't built into qemu-img, this case would fail as below:


exec /home/haoqf/KVMonz/qemu/tests/qemu-iotests/../../qemu-img info --image-opts driver=ssh,host=localhost,port=0.42,path=/foo qemu-img: Could not open 'driver=ssh,host=localhost,port=0.42,path=/foo': Unknown driver 'ssh'

Adding 162.notrun can bypass this case but it would skip it even if qemu-img has sshx block driver, in which case I think it should be run.

So How about adding a script to dynamically check at runtime if the current env qemu-img can meet the requirement to run the test or not?

I made a sample here whose result is:

[Without sshx built in]

./check -qcow2 162
... ...
162 0s ... [not run] case 162 not applicable!
Not run: 162
Passed all 0 tests

[Without sshx built in]
./check -qcow2 162
... ...
162 0s ...
Passed all 1 tests

Rough code patch is(new file 162.check is introduced to check if sshx is built in):

diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 4cba215..e7ef395 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -18,7 +18,6 @@
 #
 # Control script for QA
 #
-
 status=0
 needwrap=true
 try=0
@@ -291,6 +290,24 @@ do
         start=`_wallclock`
         $timestamp && echo -n "        ["`date "+%T"`"]"

+       check_ret=0
+ if [ -f "$source_iotests/$seq.check" -a -x "$source_iotests/$seq.check" ]; then + if [ "$(head -n 1 "$source_iotests/$seq.check")" == "#!/usr/bin/env python" ]; then
+                $PYTHON $seq.check
+            else
+                ./$seq.check
+           fi
+           check_ret=$?
+       fi
+       if [ $check_ret -ne 0 ]; then
+            $timestamp || echo -n " [not run] "
+            $timestamp && echo " [not run]" && echo -n "        $seq -- "
+           echo "case $seq not applicable!"
+            notrun="$notrun $seq"
+           seq="after_$seq"
+           continue
+       fi
+
if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then
             run_command="$PYTHON $seq"
         else

diff --git a/tests/qemu-iotests/162.check b/tests/qemu-iotests/162.check
new file mode 100755
index 0000000..a80df7a
--- /dev/null
+++ b/tests/qemu-iotests/162.check
@@ -0,0 +1,35 @@
+#!/bin/bash
+#Return 0 if the case can run, others can not
+#Typically the block drivers can be queried by "qemu-img --help" and
+#the output is as:
+#Supported formats: dmg luks ssh sheepdog nbd null-aio null-co host_cdrom host_device file blkreplay blkverify blkdebug parallels quorum qed qcow2 vvfat vpc bochs cloop vmdk vdi qcow raw
+#set -x
+
+#. ./common.config
+found=0
+. ./common.rc
+. ./common.filter
+#_supported_fmt generic
+#_supported_os Linux
+blk_drivers=`$QEMU_IMG --help|grep "Supported formats:"|sed 's/Supported formats://'`
+#echo "drivers:"$blk_drivers
+#echo $blk_drivers|awk '{print $0}'
+found=$(
+echo $blk_drivers|awk '{n=split($0, arr_drivers, " ");
+ for(i=1; i<=n; i++) print arr_drivers[i]}' | { while read driver
+               do
+                   if [ "$driver"x = "sshx" ]; then
+                       echo 1
+                       exit
+                   fi
+               done
+               echo 0
+       }
+)
+
+#echo "ret:$found"
+if [ "$found" = "1" ]; then
+   exit 0
+fi
+
+exit 1

Thanks!

Hao QingFeng


在 2016-09-29 4:46, Max Reitz 写道:
162 is potentially racy and makes some invalid assumptions about what
should happen when connecting to a non-existing domain name. This series
fixes both issues.


v4:
- Added documentation for the new --fork option [Kevin]


git-backport-diff against v3:

Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream
patch
[down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences,
respectively

001/3:[0004] [FC] 'qemu-nbd: Add --fork option'
002/3:[----] [--] 'iotests: Remove raciness from 162'
003/3:[----] [--] 'iotests: Do not rely on unavailable domains in 162'


Max Reitz (3):
   qemu-nbd: Add --fork option
   iotests: Remove raciness from 162
   iotests: Do not rely on unavailable domains in 162

  qemu-nbd.c                 | 17 ++++++++++++++++-
  qemu-nbd.texi              |  2 ++
  tests/qemu-iotests/162     | 22 ++++++++++++++++------
  tests/qemu-iotests/162.out |  2 +-
  4 files changed, 35 insertions(+), 8 deletions(-)


--
QingFeng Hao


Reply via email to