Pino Toscano
2015-Oct-05 12:50 UTC
Re: [Libguestfs] [PATCH 3/6] v2v:test:win: actually check the eventual layout
On Monday 05 October 2015 15:40:03 Roman Kagan wrote:> v2v/test-v2v-windows-conversion.sh used to query if the expected > directories and filed were present in the VM upon conversion; however it > would ignore the results of that query. > > That lead to the test passing even though the checks failed. > > To fix it, parse the output of guestfish and verify that all is-file and > is-dir commands return the expected "true". > > While doing so, keep in mind that the exit status of a pipeline is that > of the last command, so make sure to check the exit status of guestfish > too via $PIPESTATUS (yes it's bash-specific but the scripts are run with > bash only anyway). > > Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> > --- > v2v/test-v2v-windows-conversion.sh | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/v2v/test-v2v-windows-conversion.sh b/v2v/test-v2v-windows-conversion.sh > index eef6f57..916699d 100755 > --- a/v2v/test-v2v-windows-conversion.sh > +++ b/v2v/test-v2v-windows-conversion.sh > @@ -67,12 +67,23 @@ test -f $d/windows.xml > test -f $d/windows-sda > > # Test some aspects of the target disk image. > +{ > guestfish --ro -a $d/windows-sda -i <<EOF > + trace 1 > is-dir "/Program Files/Red Hat/Firstboot" > is-file "/Program Files/Red Hat/Firstboot/firstboot.bat" > is-dir "/Program Files/Red Hat/Firstboot/scripts" > is-dir "/Windows/Drivers/VirtIO" > + trace 0 > EOF > +} | { > + ret=0 > + while read r; do > + [ "$r" = "true" ] || ret=1 > + done > + exit $ret > +}Note we have tests that check the output of guestfish -- for example, fish/test-edit.sh (it is not the only one). I guess you could turn this test to do the same, which could be also easier to expand if there will be added more commands that output things different than "true".> +(( PIPESTATUS[0] == 0 ))set -o pipefail (which is bash-specific) -- Pino Toscano
Roman Kagan
2015-Oct-05 13:05 UTC
Re: [Libguestfs] [PATCH 3/6] v2v:test:win: actually check the eventual layout
On Mon, Oct 05, 2015 at 02:50:52PM +0200, Pino Toscano wrote:> On Monday 05 October 2015 15:40:03 Roman Kagan wrote: > > +{ > > guestfish --ro -a $d/windows-sda -i <<EOF > > + trace 1 > > is-dir "/Program Files/Red Hat/Firstboot" > > is-file "/Program Files/Red Hat/Firstboot/firstboot.bat" > > is-dir "/Program Files/Red Hat/Firstboot/scripts" > > is-dir "/Windows/Drivers/VirtIO" > > + trace 0 > > EOF > > +} | { > > + ret=0 > > + while read r; do > > + [ "$r" = "true" ] || ret=1 > > + done > > + exit $ret > > +} > > Note we have tests that check the output of guestfish -- for example, > fish/test-edit.sh (it is not the only one). I guess you could turn this > test to do the same, which could be also easier to expand if there will > be added more commands that output things different than "true".Yes I have seen it but exactly because I foresee nothing but "true" in guestfish's output I want to avoid tedious beancounting when maintaining the expected result string.> > +(( PIPESTATUS[0] == 0 )) > > set -o pipefail (which is bash-specific)I don't mind this change; want me to resubmit with it? Roman.
Pino Toscano
2015-Oct-05 13:19 UTC
Re: [Libguestfs] [PATCH 3/6] v2v:test:win: actually check the eventual layout
On Monday 05 October 2015 16:05:54 Roman Kagan wrote:> On Mon, Oct 05, 2015 at 02:50:52PM +0200, Pino Toscano wrote: > > On Monday 05 October 2015 15:40:03 Roman Kagan wrote: > > > +{ > > > guestfish --ro -a $d/windows-sda -i <<EOF > > > + trace 1 > > > is-dir "/Program Files/Red Hat/Firstboot" > > > is-file "/Program Files/Red Hat/Firstboot/firstboot.bat" > > > is-dir "/Program Files/Red Hat/Firstboot/scripts" > > > is-dir "/Windows/Drivers/VirtIO" > > > + trace 0 > > > EOF > > > +} | { > > > + ret=0 > > > + while read r; do > > > + [ "$r" = "true" ] || ret=1 > > > + done > > > + exit $ret > > > +} > > > > Note we have tests that check the output of guestfish -- for example, > > fish/test-edit.sh (it is not the only one). I guess you could turn this > > test to do the same, which could be also easier to expand if there will > > be added more commands that output things different than "true". > > Yes I have seen it but exactly because I foresee nothing but "true" in > guestfish's output I want to avoid tedious beancounting when maintaining > the expected result string.Never say never... really, better make it slightly more generic, so expanding it later is no hassle. Also, comparing to the exact output expected is a check more that we got the number of lines expected.> > > +(( PIPESTATUS[0] == 0 )) > > > > set -o pipefail (which is bash-specific) > > I don't mind this change; want me to resubmit with it?Yes, with the aforementioned change of the output check, which could make checking for the pipe status no more needed. Thanks, -- Pino Toscano
Apparently Analagous Threads
- Re: [PATCH 3/6] v2v:test:win: actually check the eventual layout
- Re: [PATCH 3/6] v2v:test:win: actually check the eventual layout
- Re: [PATCH 3/6] v2v:test:win: actually check the eventual layout
- Re: [PATCH 3/6] v2v:test:win: actually check the eventual layout
- Re: [PATCH 3/6] v2v:test:win: actually check the eventual layout