diff mbox series

[3/3] iotests: Use stat -c %b in 125

Message ID 20190925183231.11196-4-mreitz@redhat.com
State New
Headers show
Series [1/3] iotests: Fix 125 for growth_mode = metadata | expand

Commit Message

Max Reitz Sept. 25, 2019, 6:32 p.m. UTC
125 should not use qemu-img to get the on-disk image size, because that
reports it in a human-readable format that is useless to us.  Just use
stat instead (like we do to get the image file length).

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/125 | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Eric Blake Sept. 25, 2019, 9:31 p.m. UTC | #1
On 9/25/19 1:32 PM, Max Reitz wrote:
> 125 should not use qemu-img to get the on-disk image size, because that
> reports it in a human-readable format that is useless to us.  Just use
> stat instead (like we do to get the image file length).
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>   tests/qemu-iotests/125 | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/tests/qemu-iotests/125 b/tests/qemu-iotests/125
> index 0ef51f1e21..4e31aa4e5f 100755
> --- a/tests/qemu-iotests/125
> +++ b/tests/qemu-iotests/125
> @@ -34,8 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>   
>   get_image_size_on_host()
>   {
> -    $QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep "disk size" \
> -        | sed -e 's/^[^0-9]*\([0-9]\+\).*$/\1/'
> +    echo $(($(stat -c '%b * %B' "$TEST_IMG_FILE")))

Cute use of $(()) around $().

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox series

Patch

diff --git a/tests/qemu-iotests/125 b/tests/qemu-iotests/125
index 0ef51f1e21..4e31aa4e5f 100755
--- a/tests/qemu-iotests/125
+++ b/tests/qemu-iotests/125
@@ -34,8 +34,7 @@  trap "_cleanup; exit \$status" 0 1 2 3 15
 
 get_image_size_on_host()
 {
-    $QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep "disk size" \
-        | sed -e 's/^[^0-9]*\([0-9]\+\).*$/\1/'
+    echo $(($(stat -c '%b * %B' "$TEST_IMG_FILE")))
 }
 
 # get standard environment and filters