On 3/24/20 12:27 PM, Max Reitz wrote:
Test that qemu-img check reports the number of leaks and corruptions
fixed in its JSON report (after a successful run).
While touching the _unsupported_imgopts line, adjust the note on why
data_file does not work with this test: The current comment sounds a bit
like it is a mistake for qemu-img check not to check external data
files' refcounts. But there are no such refcounts, so it is no mistake.
Just say that qemu-img check does not do much for external data files,
and this is why this test does not work with them.
Signed-off-by: Max Reitz <mre...@redhat.com>
---
tests/qemu-iotests/138 | 41 ++++++++++++++++++++++++++++++++++++--
tests/qemu-iotests/138.out | 14 +++++++++++++
2 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/tests/qemu-iotests/138 b/tests/qemu-iotests/138
index 54b01046ad..1d5b0bed6d 100755
--- a/tests/qemu-iotests/138
+++ b/tests/qemu-iotests/138
@@ -41,8 +41,10 @@ _supported_fmt qcow2
_supported_proto file
_supported_os Linux
# With an external data file, data clusters are not refcounted
-# (and so qemu-img check does not check their refcount)
-_unsupported_imgopts data_file
+# (so qemu-img check would not do much);
Works for me.
+echo
+# Should print the number of corruptions and leaks fixed
+# (Filter out all JSON fields (recognizable by their four-space
+# indentation), but keep the "-fixed" fields (by removing two spaces
+# from their indentation))
+# (Also filter out the L1 entry, because why not)
+_check_test_img -r all --output=json \
+ | sed -e 's/^ \(.*\)-fixed"/\1-fixed"/' \
+ -e '/^ /d' \
+ -e "s/\\([^0-9a-f]\\)$(printf %x
$l1_entry)\\([^0-9a-f]\\)/\1L1_ENTRY_VALUE\2/"
It's fun to see the post-review results. Given the limited times where
the third -e fires in the output,
+++ b/tests/qemu-iotests/138.out
+Leaked cluster 0 refcount=2 reference=1
+Repairing cluster 0 refcount=2 reference=1
+Repairing OFLAG_COPIED L2 cluster: l1_index=0 l1_entry=L1_ENTRY_VALUE
refcount=1
it could be written with less typing as:
-e "s/=$(printf %x $l1_entry) /=L1_ENTRY_VALUE /"
but that's not essential. So either way,
Reviewed-by: Eric Blake <ebl...@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org