cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
218e99
From 43e2ea9a31c301e162507a3f656b8719454df086 Mon Sep 17 00:00:00 2001
218e99
From: Stefan Hajnoczi <stefanha@redhat.com>
218e99
Date: Tue, 6 Aug 2013 15:44:49 +0800
218e99
Subject: [PATCH 03/13] qemu-iotests: add poke_file utility function
218e99
218e99
Message-id: <1377573001-27070-4-git-send-email-famz@redhat.com>
218e99
Patchwork-id: 53783
218e99
O-Subject: [RHEL-7 qemu-kvm PATCH 03/13] qemu-iotests: add poke_file utility function
218e99
Bugzilla: 995866
218e99
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
218e99
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
218e99
218e99
The new poke_file function sets bytes at an offset in a file given a
218e99
printf-style format string.  It can be used to corrupt an image file for
218e99
test coverage of error paths.
218e99
218e99
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
(cherry picked from commit 23ea2ecc2a43d850bc9482068201ece5da36a448)
218e99
Signed-off-by: Fam Zheng <famz@redhat.com>
218e99
---
218e99
 tests/qemu-iotests/common.rc |    6 ++++++
218e99
 1 files changed, 6 insertions(+), 0 deletions(-)
218e99
218e99
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
218e99
index 1e9b2f4..1187b86 100644
218e99
--- a/tests/qemu-iotests/common.rc
218e99
+++ b/tests/qemu-iotests/common.rc
218e99
@@ -34,6 +34,12 @@ dd()
218e99
    fi
218e99
 }
218e99
 
218e99
+# poke_file 'test.img' 512 '\xff\xfe'
218e99
+poke_file()
218e99
+{
218e99
+    printf "$3" | dd "of=$1" bs=1 "seek=$2" conv=notrunc &>/dev/null
218e99
+}
218e99
+
218e99
 # we need common.config
218e99
 if [ "$iam" != "check" ]
218e99
 then
218e99
-- 
218e99
1.7.1
218e99