[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] iotests: Test snapshot -l field separation

From: Eric Blake
Subject: Re: [PATCH 2/2] iotests: Test snapshot -l field separation
Date: Fri, 17 Jan 2020 07:54:45 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1

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 <address@hidden>
  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 <address@hidden>

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

reply via email to

[Prev in Thread] Current Thread [Next in Thread]