aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2019-10-11 17:28:13 +0200
committerMichael Roth <mdroth@linux.vnet.ibm.com>2019-11-12 11:59:33 -0600
commitb156178553341ab24dcc14efdb7b681375099462 (patch)
tree0066ebb5a55d6317a8fd4fc71742b51c8f4b421f
parent15f5e8c3675b9eb16e2413d56017c047533407bb (diff)
downloadqemu-b156178553341ab24dcc14efdb7b681375099462.zip
qemu-b156178553341ab24dcc14efdb7b681375099462.tar.gz
qemu-b156178553341ab24dcc14efdb7b681375099462.tar.bz2
iotests: Add peek_file* functions
Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 20191011152814.14791-16-mreitz@redhat.com Signed-off-by: Max Reitz <mreitz@redhat.com> (cherry picked from commit fc8ba423ca6b37bee56ec9dc339b44043c39553d) *prereq for 570542ec Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r--tests/qemu-iotests/common.rc20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index 5502c3d..78decfd 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -53,6 +53,26 @@ poke_file()
printf "$3" | dd "of=$1" bs=1 "seek=$2" conv=notrunc &>/dev/null
}
+# peek_file_le 'test.img' 512 2 => 65534
+peek_file_le()
+{
+ # Wrap in echo $() to strip spaces
+ echo $(od -j"$2" -N"$3" --endian=little -An -vtu"$3" "$1")
+}
+
+# peek_file_be 'test.img' 512 2 => 65279
+peek_file_be()
+{
+ # Wrap in echo $() to strip spaces
+ echo $(od -j"$2" -N"$3" --endian=big -An -vtu"$3" "$1")
+}
+
+# peek_file_raw 'test.img' 512 2 => '\xff\xfe'
+peek_file_raw()
+{
+ dd if="$1" bs=1 skip="$2" count="$3" status=none
+}
+
if ! . ./common.config
then