On 1/17/20 4:58 AM, Max Reitz wrote:
Add a test that all fields in "qemu-img snapshot -l"s output are
separated by spaces.
Signed-off-by: Max Reitz <[email protected]>
---
tests/qemu-iotests/284 | 76 ++++++++++++++++++++++++++++++++++++++
tests/qemu-iotests/284.out | 8 ++++
tests/qemu-iotests/group | 1 +
3 files changed, 85 insertions(+)
create mode 100755 tests/qemu-iotests/284
create mode 100644 tests/qemu-iotests/284.out
+# Check that all fields are separated by spaces.
+# We first collapse all space sequences into one space each;
+# then we turn every space-separated field into a '.';
+# and finally, we name the '.'s so the output is not just a confusing
+# sequence of dots.
+
+echo 'Output structure:'
+$QEMU_IMG snapshot -l "$TEST_IMG" | tail -n 1 | tr -s ' ' \
+ | sed -e 's/\S\+/./g' \
+ | sed -e 's/\./(snapshot ID)/' \
+ -e 's/\./(snapshot name)/' \
+ -e 's/\./(VM state size value)/' \
+ -e 's/\./(VM state size unit)/' \
+ -e 's/\./(snapshot date)/' \
+ -e 's/\./(snapshot time)/' \
+ -e 's/\./(VM clock)/'
Cute conversion. If you had picked some other character (like
s/\S\+/=/g), you wouldn't have to use \. everywhere in the second sed,
for less typing, but that's aesthetic, so no need to change if you don't
want.
Reviewed-by: Eric Blake <[email protected]>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org