]> git.proxmox.com Git - qemu.git/commitdiff
qemu-iotests: Valgrind support
authorKevin Wolf <kwolf@redhat.com>
Thu, 28 Jun 2012 14:55:54 +0000 (16:55 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 17 Jul 2012 14:48:32 +0000 (16:48 +0200)
check -valgrind wraps all qemu-io calls with valgrind. This makes it a
bit easier to debug problems that occur somewhere deep in a test case.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
tests/qemu-iotests/common
tests/qemu-iotests/common.rc

index eeb70cbcdcb670867964f3c93c057cba2c39625f..1f6fdf5c56087a75c8b33c6c3b7ebd33f1518ad1 100644 (file)
@@ -41,6 +41,7 @@ sortme=false
 expunge=true
 have_test_arg=false
 randomize=false
+valgrind=false
 rm -f $tmp.list $tmp.tmp $tmp.sed
 
 export IMGFMT=raw
@@ -212,6 +213,11 @@ testlist options
            xpand=false
            ;;
 
+    -valgrind)
+        valgrind=true
+           xpand=false
+        ;;
+
        -g)     # -g group ... pick from group file
            group=true
            xpand=false
@@ -345,3 +351,8 @@ fi
 [ "$QEMU" = "" ] && _fatal "qemu not found"
 [ "$QEMU_IMG" = "" ] && _fatal "qemu-img not found"
 [ "$QEMU_IO" = "" ] && _fatal "qemu-img not found"
+
+if $valgrind; then
+    export REAL_QEMU_IO="$QEMU_IO_PROG"
+    export QEMU_IO_PROG=valgrind_qemu_io
+fi
index e535874e4cae1bf467062892fdf37a4891f68958..5e3a524bc86a22d0d188458a0683798e291aae42 100644 (file)
@@ -53,6 +53,16 @@ else
     TEST_IMG=$IMGPROTO:$TEST_DIR/t.$IMGFMT
 fi
 
+function valgrind_qemu_io()
+{
+    valgrind --log-file=/tmp/$$.valgrind --error-exitcode=99 $REAL_QEMU_IO "$@"
+    if [ $? != 0 ]; then
+        cat /tmp/$$.valgrind
+    fi
+    rm -f /tmp/$$.valgrind
+}
+
+
 _optstr_add()
 {
     if [ -n "$1" ]; then