Pino Toscano
2013-Dec-19 15:29 UTC
Re: [Libguestfs] [PATCH] drives: add CD-ROM disk images as read-only drives (RHBZ#563450).
On Wednesday 18 December 2013 20:44:33 Richard W.M. Jones wrote:> On Fri, Dec 13, 2013 at 04:32:49PM +0100, Pino Toscano wrote: > > diff --git a/tests/regressions/rhbz563450.sh > > b/tests/regressions/rhbz563450.sh new file mode 100755 > > index 0000000..6fa6f2b > > --- /dev/null > > +++ b/tests/regressions/rhbz563450.sh > > @@ -0,0 +1,54 @@ > > +#!/bin/bash - > > +# libguestfs > > +# Copyright (C) 2013 Red Hat Inc. > > +# > > +# This program is free software; you can redistribute it and/or > > modify +# it under the terms of the GNU General Public License as > > published by +# the Free Software Foundation; either version 2 of > > the License, or +# (at your option) any later version. > > +# > > +# This program is distributed in the hope that it will be useful, > > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > +# GNU General Public License for more details. > > +# > > +# You should have received a copy of the GNU General Public License > > +# along with this program; if not, write to the Free Software > > +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > > 02110-1301 USA. + > > +# https://bugzilla.redhat.com/show_bug.cgi?id=563450 > > +# Test the order of added images > > + > > +set -e > > +export LANG=C > > + > > +rm -f test.out > > + > > +../../fish/guestfish --ro > test.out <<EOF > > +add-drive-ro ../guests/fedora.img > > +add-cdrom ../data/test.iso > > +add-drive-ro ../guests/debian.img > > + > > +run > > + > > +list-devices > > +echo ---- > > +list-partitions > > + > > +ping-daemon > > +EOF > > + > > +if [ "$(cat test.out)" != "/dev/sda > > +/dev/sdb > > +/dev/sdc > > +---- > > +/dev/sda1 > > +/dev/sda2 > > +/dev/sdc1 > > +/dev/sdc2" ]; then > > There's a bug in both of these tests, so I had to remove them in order > to get a release out today. > > 'list-devices' doesn't canonicalize disk names (perhaps it should, but > it doesn't). Therefore if the appliance is using old virtio-blk it > will return disk names such as /dev/vda, and if the appliance is > running under UML it will return /dev/ubda (which was what failed in > 'make check-release').You are right, it slipped in my checks.> If you look at other tests such as: > > - df/test-virt-df.sh > - tests/luks/test-luks-list.sh > > they get around this by canonicalizing the device names (in different > ways) before comparing them.I've taken this approach, although IMHO replacing the whole output just once at the end would be a cleaner approach than spreading sed+regexp all over the guestfish invocations.> If you correct the bug then we can put the tests back.Sending updated patch. -- Pino Toscano
Pino Toscano
2013-Dec-19 15:30 UTC
[Libguestfs] [PATCH] Re-add regression tests for rh#563450
Added in 2392fae6803b9de4a4761509007c160339d57f50 and removed in be025369ad622867ecf08d5c9170e8e59d2d6294; now they should work with any backend, as the device names are normalised and not change the guestfish output depending on the used backend. Thanks Richard for the hints. --- tests/regressions/Makefile.am | 2 ++ tests/regressions/rhbz563450.sh | 59 ++++++++++++++++++++++++++++++++++++++++ tests/regressions/rhbz563450b.sh | 48 ++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100755 tests/regressions/rhbz563450.sh create mode 100755 tests/regressions/rhbz563450b.sh diff --git a/tests/regressions/Makefile.am b/tests/regressions/Makefile.am index 5b0d1c3..741f45f 100644 --- a/tests/regressions/Makefile.am +++ b/tests/regressions/Makefile.am @@ -21,6 +21,8 @@ TESTS = \ rhbz501893 \ rhbz503169c13.sh \ rhbz557655.sh \ + rhbz563450.sh \ + rhbz563450b.sh \ rhbz576879.sh \ rhbz578407.sh \ rhbz580246.sh \ diff --git a/tests/regressions/rhbz563450.sh b/tests/regressions/rhbz563450.sh new file mode 100755 index 0000000..96fca8c --- /dev/null +++ b/tests/regressions/rhbz563450.sh @@ -0,0 +1,59 @@ +#!/bin/bash - +# libguestfs +# Copyright (C) 2013 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# https://bugzilla.redhat.com/show_bug.cgi?id=563450 +# Test the order of added images + +set -e +export LANG=C + +if [ ! -s ../guests/fedora.img -o ! -s ../data/test.iso -o ! -s ../guests/debian.img ]; then + echo "$0: test skipped because there is no fedora.img nor test.iso nor debian.img" + exit 77 +fi + +rm -f test.out + +../../fish/guestfish --ro > test.out <<EOF +add-drive-ro ../guests/fedora.img +add-cdrom ../data/test.iso +add-drive-ro ../guests/debian.img + +run + +list-devices | sed -r 's,^/dev/[abce-ln-z]+d,/dev/sd,' +echo ---- +list-partitions | sed -r 's,^/dev/[abce-ln-z]+d,/dev/sd,' + +ping-daemon +EOF + +if [ "$(cat test.out)" != "/dev/sda +/dev/sdb +/dev/sdc +---- +/dev/sda1 +/dev/sda2 +/dev/sdc1 +/dev/sdc2" ]; then + echo "$0: unexpected output:" + cat test.out + exit 1 +fi + +rm -f test.out diff --git a/tests/regressions/rhbz563450b.sh b/tests/regressions/rhbz563450b.sh new file mode 100755 index 0000000..7b890b1 --- /dev/null +++ b/tests/regressions/rhbz563450b.sh @@ -0,0 +1,48 @@ +#!/bin/bash - +# libguestfs +# Copyright (C) 2013 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# https://bugzilla.redhat.com/show_bug.cgi?id=563450 +# Test only CD-ROM disk images can be added + +set -e +export LANG=C + +if [ ! -s ../data/test.iso ]; then + echo "$0: test skipped because there is no test.iso" + exit 77 +fi + +rm -f test.out + +../../fish/guestfish --ro > test.out <<EOF +add-cdrom ../data/test.iso + +run + +list-devices | sed -r 's,^/dev/[abce-ln-z]+d,/dev/sd,' + +ping-daemon +EOF + +if [ "$(cat test.out)" != "/dev/sda" ]; then + echo "$0: unexpected output:" + cat test.out + exit 1 +fi + +rm -f test.out -- 1.8.3.1
Richard W.M. Jones
2013-Dec-19 18:36 UTC
Re: [Libguestfs] [PATCH] Re-add regression tests for rh#563450
On Thu, Dec 19, 2013 at 04:30:57PM +0100, Pino Toscano wrote:> Added in 2392fae6803b9de4a4761509007c160339d57f50 and removed in > be025369ad622867ecf08d5c9170e8e59d2d6294; now they should work with any > backend, as the device names are normalised and not change the guestfish > output depending on the used backend. > > Thanks Richard for the hints.ACK.> +../../fish/guestfish --ro > test.out <<EOFIt could also be done as: ../../fish/guestfish --ro | sed ... > test.out which would be one sed invocation. However I think that would hide any errors / segfaults in guestfish, so the way you've got it now seems more robust. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
Seemingly Similar Threads
- [PATCH] drives: add CD-ROM disk images as read-only drives (RHBZ#563450).
- Re: [PATCH] drives: add CD-ROM disk images as read-only drives (RHBZ#563450).
- [PATCH] drives: add CD-ROM disk images as read-only drives (RHBZ#563450).
- Re: [PATCH] drives: add CD-ROM disk images as read-only drives (RHBZ#563450).
- Re: [PATCH] drives: add CD-ROM disk images as read-only drives (RHBZ#563450).