[Libguestfs] [PATCH 3/6] v2v:test:win: actually check the eventual layout
Pino Toscano
ptoscano at redhat.com
Mon Oct 5 12:50:52 UTC 2015
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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20151005/f43929f3/attachment.sig>
More information about the Libguestfs
mailing list