[libvirt] [PATCH] tests: Fix virsh-snapshot/checkpoint without libreadline-devel

Eric Blake posted 1 patch 4 years, 8 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20190802132733.17761-1-eblake@redhat.com
tests/virsh-checkpoint | 7 +++----
tests/virsh-snapshot   | 7 +++----
2 files changed, 6 insertions(+), 8 deletions(-)
[libvirt] [PATCH] tests: Fix virsh-snapshot/checkpoint without libreadline-devel
Posted by Eric Blake 4 years, 8 months ago
libreadline-devel is an optional build dependency; when it is not
present, the output of 'virsh <<EOF ... EOF' is different in that the
input provided by the user is not echoed, and prompts become
interleaved on the same line as actual output, which in turn causes
the sed doing prompt filtering to mess up:

| ./virsh-snapshot
| --- exp	2019-07-31 18:42:31.107399428 -0300
| +++ out.cooked	2019-07-31 18:42:31.108399437 -0300
| @@ -1,8 +1,3 @@
| -
| -
| -Domain snapshot s3 created from 's3.xml'
| -Domain snapshot s2 created from 's2.xml'
| -Name:           s2
|  Domain:         test
|  Current:        yes
|  State:          running

Maybe we should fix virsh in interactive mode to echo regardless of
whether libreadline-devel was used, but the quicker fix is to make the
test use 'virsh "..."' rather than reading its input from stdin.

Reported-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---

I'm tempted to push this as a fix to a build-breaker, but as I did not
actually build without libreadline-devel, I'd appreciate an ACK from
Daniel that this fixes the problem on his setup.

 tests/virsh-checkpoint | 7 +++----
 tests/virsh-snapshot   | 7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/tests/virsh-checkpoint b/tests/virsh-checkpoint
index 75bdc293be..92962d2205 100755
--- a/tests/virsh-checkpoint
+++ b/tests/virsh-checkpoint
@@ -140,7 +140,7 @@ EOF
 compare exp err || fail=1

 # Restore state with redefine
-$abs_top_builddir/tools/virsh -c test:///default >out 2>err <<EOF || fail=1
+$abs_top_builddir/tools/virsh -c test:///default >out 2>err '
   # Redefine must be in topological order; this will fail
   checkpoint-create test --redefine c2.xml
   echo --err marker
@@ -149,7 +149,7 @@ $abs_top_builddir/tools/virsh -c test:///default >out 2>err <<EOF || fail=1
   checkpoint-create test --redefine c2.xml
   checkpoint-list test --leaves --name
   checkpoint-info test c2
-EOF
+' || fail=1

 cat <<\EOF > exp || fail=1

@@ -165,8 +165,7 @@ Children:       0
 Descendants:    0

 EOF
-sed '1,/^virsh #/d; /virsh #/d' < out > out.cooked || fail=1
-compare exp out.cooked || fail=1
+compare exp out || fail=1

 cat <<EOF > exp || fail=1
 error: invalid argument: parent c3 for moment c2 not found
diff --git a/tests/virsh-snapshot b/tests/virsh-snapshot
index 20ff966a51..473e3b3f2d 100755
--- a/tests/virsh-snapshot
+++ b/tests/virsh-snapshot
@@ -191,7 +191,7 @@ EOF
 compare exp err || fail=1

 # Restore state with redefine
-$abs_top_builddir/tools/virsh -c test:///default >out 2>err <<EOF || fail=1
+$abs_top_builddir/tools/virsh -c test:///default >out 2>err '
   # Redefine must be in topological order; this will fail
   snapshot-create test --redefine s2.xml --validate
   echo --err marker
@@ -199,7 +199,7 @@ $abs_top_builddir/tools/virsh -c test:///default >out 2>err <<EOF || fail=1
   snapshot-create test --redefine s3.xml --validate
   snapshot-create test --redefine s2.xml --current --validate
   snapshot-info test --current
-EOF
+' || fail=1

 cat <<\EOF > exp || fail=1

@@ -217,8 +217,7 @@ Descendants:    0
 Metadata:       yes

 EOF
-sed '1,/^virsh #/d; /virsh #/d' < out > out.cooked || fail=1
-compare exp out.cooked || fail=1
+compare exp out || fail=1

 cat <<EOF > exp || fail=1
 error: invalid argument: parent s3 for moment s2 not found
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] tests: Fix virsh-snapshot/checkpoint without libreadline-devel
Posted by Daniel Henrique Barboza 4 years, 8 months ago
Tested this patch in a Power 8 host that doesn't have readline-devel
installed. Both tests passed, all tests are green with make check.

Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>




Thanks,


DHB


On 8/2/19 10:27 AM, Eric Blake wrote:
> libreadline-devel is an optional build dependency; when it is not
> present, the output of 'virsh <<EOF ... EOF' is different in that the
> input provided by the user is not echoed, and prompts become
> interleaved on the same line as actual output, which in turn causes
> the sed doing prompt filtering to mess up:
>
> | ./virsh-snapshot
> | --- exp	2019-07-31 18:42:31.107399428 -0300
> | +++ out.cooked	2019-07-31 18:42:31.108399437 -0300
> | @@ -1,8 +1,3 @@
> | -
> | -
> | -Domain snapshot s3 created from 's3.xml'
> | -Domain snapshot s2 created from 's2.xml'
> | -Name:           s2
> |  Domain:         test
> |  Current:        yes
> |  State:          running
>
> Maybe we should fix virsh in interactive mode to echo regardless of
> whether libreadline-devel was used, but the quicker fix is to make the
> test use 'virsh "..."' rather than reading its input from stdin.
>
> Reported-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>
> I'm tempted to push this as a fix to a build-breaker, but as I did not
> actually build without libreadline-devel, I'd appreciate an ACK from
> Daniel that this fixes the problem on his setup.
>
>   tests/virsh-checkpoint | 7 +++----
>   tests/virsh-snapshot   | 7 +++----
>   2 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/tests/virsh-checkpoint b/tests/virsh-checkpoint
> index 75bdc293be..92962d2205 100755
> --- a/tests/virsh-checkpoint
> +++ b/tests/virsh-checkpoint
> @@ -140,7 +140,7 @@ EOF
>   compare exp err || fail=1
>
>   # Restore state with redefine
> -$abs_top_builddir/tools/virsh -c test:///default >out 2>err <<EOF || fail=1
> +$abs_top_builddir/tools/virsh -c test:///default >out 2>err '
>     # Redefine must be in topological order; this will fail
>     checkpoint-create test --redefine c2.xml
>     echo --err marker
> @@ -149,7 +149,7 @@ $abs_top_builddir/tools/virsh -c test:///default >out 2>err <<EOF || fail=1
>     checkpoint-create test --redefine c2.xml
>     checkpoint-list test --leaves --name
>     checkpoint-info test c2
> -EOF
> +' || fail=1
>
>   cat <<\EOF > exp || fail=1
>
> @@ -165,8 +165,7 @@ Children:       0
>   Descendants:    0
>
>   EOF
> -sed '1,/^virsh #/d; /virsh #/d' < out > out.cooked || fail=1
> -compare exp out.cooked || fail=1
> +compare exp out || fail=1
>
>   cat <<EOF > exp || fail=1
>   error: invalid argument: parent c3 for moment c2 not found
> diff --git a/tests/virsh-snapshot b/tests/virsh-snapshot
> index 20ff966a51..473e3b3f2d 100755
> --- a/tests/virsh-snapshot
> +++ b/tests/virsh-snapshot
> @@ -191,7 +191,7 @@ EOF
>   compare exp err || fail=1
>
>   # Restore state with redefine
> -$abs_top_builddir/tools/virsh -c test:///default >out 2>err <<EOF || fail=1
> +$abs_top_builddir/tools/virsh -c test:///default >out 2>err '
>     # Redefine must be in topological order; this will fail
>     snapshot-create test --redefine s2.xml --validate
>     echo --err marker
> @@ -199,7 +199,7 @@ $abs_top_builddir/tools/virsh -c test:///default >out 2>err <<EOF || fail=1
>     snapshot-create test --redefine s3.xml --validate
>     snapshot-create test --redefine s2.xml --current --validate
>     snapshot-info test --current
> -EOF
> +' || fail=1
>
>   cat <<\EOF > exp || fail=1
>
> @@ -217,8 +217,7 @@ Descendants:    0
>   Metadata:       yes
>
>   EOF
> -sed '1,/^virsh #/d; /virsh #/d' < out > out.cooked || fail=1
> -compare exp out.cooked || fail=1
> +compare exp out || fail=1
>
>   cat <<EOF > exp || fail=1
>   error: invalid argument: parent s3 for moment s2 not found

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list