]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qemu-iotests: add poke_file utility function
authorStefan Hajnoczi <stefanha@redhat.com>
Tue, 6 Aug 2013 07:44:49 +0000 (15:44 +0800)
committerKevin Wolf <kwolf@redhat.com>
Tue, 6 Aug 2013 13:27:32 +0000 (15:27 +0200)
The new poke_file function sets bytes at an offset in a file given a
printf-style format string.  It can be used to corrupt an image file for
test coverage of error paths.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
tests/qemu-iotests/common.rc

index e9ba3586b56b1e2d5773f7c85bf6100fe411a0f3..5e077c3573ea1bcb7565b4dda8d6a645586038a1 100644 (file)
@@ -34,6 +34,12 @@ dd()
    fi
 }
 
+# poke_file 'test.img' 512 '\xff\xfe'
+poke_file()
+{
+    printf "$3" | dd "of=$1" bs=1 "seek=$2" conv=notrunc &>/dev/null
+}
+
 # we need common.config
 if [ "$iam" != "check" ]
 then