From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6iQz-0003Uw-PT for qemu-devel@nongnu.org; Tue, 06 Aug 2013 10:40:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V6iQs-0002qL-ID for qemu-devel@nongnu.org; Tue, 06 Aug 2013 10:40:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52039) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6iQs-0002q8-Bb for qemu-devel@nongnu.org; Tue, 06 Aug 2013 10:40:18 -0400 From: Kevin Wolf Date: Tue, 6 Aug 2013 16:39:44 +0200 Message-Id: <1375799990-995-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1375799990-995-1-git-send-email-kwolf@redhat.com> References: <1375799990-995-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 08/14] qemu-iotests: add poke_file utility function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Stefan Hajnoczi 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 --- tests/qemu-iotests/common.rc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index e9ba358..5e077c3 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 -- 1.8.1.4