97 lines
3.5 KiB
Diff
97 lines
3.5 KiB
Diff
|
|
From 902f2203f0bc38de25dffd885ca837fe59e4a3fb Mon Sep 17 00:00:00 2001
|
||
|
|
From: Eric Blake <eblake@redhat.com>
|
||
|
|
Date: Tue, 30 Jul 2019 15:58:06 -0500
|
||
|
|
Subject: [PATCH] tests: Accommodate qemu-img 4.1 output change
|
||
|
|
|
||
|
|
Where qemu-img 4.0 used to say 'virtual size: 100M', the 4.1 release
|
||
|
|
now says 'virtual size: 100 MiB'. Similarly, '5.0G' turned into '5
|
||
|
|
GiB'. But rather than worry about potential future changes to the
|
||
|
|
human-readable output, we can just use --output=json (at which point
|
||
|
|
we no longer even have to force qemu-img to the C locale, which we
|
||
|
|
were not even doing consistently). It might be slightly more robust
|
||
|
|
to find our specific information using jq, but for now a grep of the
|
||
|
|
output json is still reliable enough for our needs.
|
||
|
|
|
||
|
|
If the '\b' is a problem on BSD, we could use '([, ]|$)' instead. Or
|
||
|
|
that's where jq would make it easier to parse off a given number
|
||
|
|
without worrying about what comes after the number.
|
||
|
|
|
||
|
|
Signed-off-by: Eric Blake <eblake@redhat.com>
|
||
|
|
---
|
||
|
|
tests/test-ip.sh | 10 ++++++----
|
||
|
|
tests/test-tls-psk.sh | 7 +++----
|
||
|
|
tests/test-tls.sh | 7 +++----
|
||
|
|
3 files changed, 12 insertions(+), 12 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/tests/test-ip.sh b/tests/test-ip.sh
|
||
|
|
index 12448c4..1ecf700 100755
|
||
|
|
--- a/tests/test-ip.sh
|
||
|
|
+++ b/tests/test-ip.sh
|
||
|
|
@@ -87,17 +87,19 @@ kill -s 0 $pid
|
||
|
|
# Check we can connect over the IPv4 loopback interface.
|
||
|
|
ipv4_lo="$(ip -o -4 addr show scope host)"
|
||
|
|
if test -n "$ipv4_lo"; then
|
||
|
|
- qemu-img info --image-opts "file.driver=nbd,file.host=127.0.0.1,file.port=$port" > ipv4.out
|
||
|
|
+ qemu-img info --output=json \
|
||
|
|
+ --image-opts "file.driver=nbd,file.host=127.0.0.1,file.port=$port" > ipv4.out
|
||
|
|
cat ipv4.out
|
||
|
|
- grep -sq "^virtual size: 100M" ipv4.out
|
||
|
|
+ grep -sq '"virtual-size": *104857600\b' ipv4.out
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Check we can connect over the IPv6 loopback interface.
|
||
|
|
ipv6_lo="$(ip -o -6 addr show scope host)"
|
||
|
|
if test -n "$ipv6_lo"; then
|
||
|
|
- qemu-img info --image-opts "file.driver=nbd,file.host=::1,file.port=$port" > ipv6.out
|
||
|
|
+ qemu-img info --output=json \
|
||
|
|
+ --image-opts "file.driver=nbd,file.host=::1,file.port=$port" > ipv6.out
|
||
|
|
cat ipv6.out
|
||
|
|
- grep -sq "^virtual size: 100M" ipv6.out
|
||
|
|
+ grep -sq '"virtual-size": *104857600\b' ipv6.out
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Kill the process.
|
||
|
|
diff --git a/tests/test-tls-psk.sh b/tests/test-tls-psk.sh
|
||
|
|
index 99c5945..ea64919 100755
|
||
|
|
--- a/tests/test-tls-psk.sh
|
||
|
|
+++ b/tests/test-tls-psk.sh
|
||
|
|
@@ -109,12 +109,11 @@ cleanup ()
|
||
|
|
trap cleanup INT QUIT TERM EXIT ERR
|
||
|
|
|
||
|
|
# Run qemu-img against the server.
|
||
|
|
-LANG=C \
|
||
|
|
-qemu-img info \
|
||
|
|
+qemu-img info --output=json \
|
||
|
|
--object "tls-creds-psk,id=tls0,endpoint=client,dir=$PWD" \
|
||
|
|
--image-opts "file.driver=nbd,file.host=localhost,file.port=$port,file.tls-creds=tls0" > tls-psk.out
|
||
|
|
|
||
|
|
cat tls-psk.out
|
||
|
|
|
||
|
|
-grep -sq "^file format: raw" tls-psk.out
|
||
|
|
-grep -sq "^virtual size: 100M" tls-psk.out
|
||
|
|
+grep -sq '"format": *"raw"' tls-psk.out
|
||
|
|
+grep -sq '"virtual-size": *104857600\b' tls-psk.out
|
||
|
|
diff --git a/tests/test-tls.sh b/tests/test-tls.sh
|
||
|
|
index 71bd8a4..9e91deb 100755
|
||
|
|
--- a/tests/test-tls.sh
|
||
|
|
+++ b/tests/test-tls.sh
|
||
|
|
@@ -103,12 +103,11 @@ cleanup ()
|
||
|
|
trap cleanup INT QUIT TERM EXIT ERR
|
||
|
|
|
||
|
|
# Run qemu-img against the server.
|
||
|
|
-LANG=C \
|
||
|
|
-qemu-img info \
|
||
|
|
+qemu-img info --output=json \
|
||
|
|
--object "tls-creds-x509,id=tls0,endpoint=client,dir=$pkidir" \
|
||
|
|
--image-opts "file.driver=nbd,file.host=localhost,file.port=$port,file.tls-creds=tls0" > tls.out
|
||
|
|
|
||
|
|
cat tls.out
|
||
|
|
|
||
|
|
-grep -sq "^file format: raw" tls.out
|
||
|
|
-grep -sq "^virtual size: 100M" tls.out
|
||
|
|
+grep -sq '"format": *"raw"' tls.out
|
||
|
|
+grep -sq '"virtual-size": *104857600\b' tls.out
|
||
|
|
--
|
||
|
|
2.23.0
|
||
|
|
|