There is a chance that the current sed filtering used in
these new tests might fail in some machines due to the
repetition of the 'virsh #' prompt at the same line,
together with valid output that shouldn't be filtered.
This is output of virsh-snapshot test in my T480 dev box:
./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
There are 3 valid lines missing. This is the unfiltered output:
=== out ===
Welcome to lt-virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh # virsh #
virsh #
virsh # virsh # Domain snapshot s3 created from 's3.xml'
virsh # Domain snapshot s2 created from 's2.xml'
virsh # Name: s2
Domain: test
Current: yes
State: running
Location: internal
Parent: s3
Children: 0
Descendants: 0
Metadata: yes
virsh #
============
We can see that the 3 lines being erased are being followed
by the 'virsh #' prompt and the filtering is erasing those.
A similar situation happens with virsh-checkpoint as well.
This patch makes the 'sed' filtering less elegant and more crude
than the current version, but more reliable to these outputs
that may vary from each dev machine. We're also removing
the blank lines in the expected output to make it less
prone to errors as well.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
Eric, feel free to accept this patch, tweak it, discard it and
try something else or whatever. I was going to send the
commit msg as a reply to your query in the ML, then realized
that I might as well propose a fix for it.
tests/virsh-checkpoint | 6 +-----
tests/virsh-snapshot | 6 ++----
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/tests/virsh-checkpoint b/tests/virsh-checkpoint
index 75bdc293be..a3cad74f74 100755
--- a/tests/virsh-checkpoint
+++ b/tests/virsh-checkpoint
@@ -152,20 +152,16 @@ $abs_top_builddir/tools/virsh -c test:///default >out 2>err
<<EOF || fail=1
EOF
cat <<\EOF > exp || fail=1
-
-
Domain checkpoint c3 created from 'c3.xml'
Domain checkpoint c2 created from 'c2.xml'
c2
-
Name: c2
Domain: test
Parent: c3
Children: 0
Descendants: 0
-
EOF
-sed '1,/^virsh #/d; /virsh #/d' < out > out.cooked || fail=1
+sed '1,/^virsh #/d; s/virsh #\s//g; /^$/d' < out > out.cooked || fail=1
compare exp out.cooked || fail=1
cat <<EOF > exp || fail=1
diff --git a/tests/virsh-snapshot b/tests/virsh-snapshot
index 20ff966a51..874093ea3c 100755
--- a/tests/virsh-snapshot
+++ b/tests/virsh-snapshot
@@ -201,9 +201,8 @@ $abs_top_builddir/tools/virsh -c test:///default >out 2>err
<<EOF || fail=1
snapshot-info test --current
EOF
-cat <<\EOF > exp || fail=1
-
+cat <<\EOF > exp || fail=1
Domain snapshot s3 created from 's3.xml'
Domain snapshot s2 created from 's2.xml'
Name: s2
@@ -215,9 +214,8 @@ Parent: s3
Children: 0
Descendants: 0
Metadata: yes
-
EOF
-sed '1,/^virsh #/d; /virsh #/d' < out > out.cooked || fail=1
+sed '1,/^virsh #/d; s/virsh #\s//g; /^$/d' < out > out.cooked || fail=1
compare exp out.cooked || fail=1
cat <<EOF > exp || fail=1
--
2.21.0