From patchwork Tue Aug 6 01:40:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 264830 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 72DC42C0040 for ; Tue, 6 Aug 2013 11:42:09 +1000 (EST) Received: from localhost ([::1]:41433 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6WHn-0005Fv-BJ for incoming@patchwork.ozlabs.org; Mon, 05 Aug 2013 21:42:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6WHE-00055r-PL for qemu-devel@nongnu.org; Mon, 05 Aug 2013 21:41:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V6WH8-00074A-OP for qemu-devel@nongnu.org; Mon, 05 Aug 2013 21:41:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2396) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6WH8-000744-7l for qemu-devel@nongnu.org; Mon, 05 Aug 2013 21:41:26 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r761fPDI024603 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 5 Aug 2013 21:41:25 -0400 Received: from T430s.redhat.com (vpn1-5-221.sin2.redhat.com [10.67.5.221]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r761f1It004035; Mon, 5 Aug 2013 21:41:21 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 6 Aug 2013 09:40:37 +0800 Message-Id: <1375753243-19530-5-git-send-email-famz@redhat.com> In-Reply-To: <1375753243-19530-1-git-send-email-famz@redhat.com> References: <1375753243-19530-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pmatouse@redhat.com, jcody@redhat.com, armbru@redhat.com, stefanha@redhat.com, famz@redhat.com, asias@redhat.com, areis@redhat.com Subject: [Qemu-devel] [PATCH v3 04/10] qemu-iotests: add poke_file utility function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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