From: Stefan Hajnoczi Date: Tue, 6 Aug 2013 07:44:49 +0000 (+0800) Subject: qemu-iotests: add poke_file utility function X-Git-Tag: v1.6.0-rc2~10^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=23ea2ecc2a43d850bc9482068201ece5da36a448;p=thirdparty%2Fqemu.git qemu-iotests: add poke_file utility function 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 Signed-off-by: Kevin Wolf --- diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index e9ba3586b56..5e077c3573e 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -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