!11 Fix the test error

Merge pull request !11 from yaokai13/master
This commit is contained in:
openeuler-ci-bot 2020-06-24 16:44:10 +08:00 committed by Gitee
commit 0f114d3f24
2 changed files with 101 additions and 1 deletions

96
Fix-the-test-error.patch Normal file
View File

@ -0,0 +1,96 @@
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

View File

@ -4,13 +4,14 @@
Name: nbdkit
Version: 1.6.2
Release: 5
Release: 6
Summary: NBD server
License: BSD
URL: https://github.com/libguestfs/nbdkit
Source0: http://libguestfs.org/download/nbdkit/1.6-stable/nbdkit-%{version}.tar.gz
Source1: http://libguestfs.org/download/nbdkit/1.6-stable/nbdkit-%{version}.tar.gz.sig
Source2: libguestfs.keyring
Patch0000: Fix-the-test-error.patch
%if 0%{patches_touch_autotools}
BuildRequires: autoconf, automake, libtool
%endif
@ -421,6 +422,9 @@ popd
%{_mandir}/man3/nbdkit-*.3*
%changelog
* Wed Jun 24 2020 yaokai13 <yaokai13@huawei.com> - 1.6.2-6
- Fix the test error
* Mon Jun 1 2020 Jeffery.Gao <gaojianxing@huawei.com> - 1.6.2-5
- Remove the special check for x86-64 architecture, consist with aarch64.