[Libguestfs] [PATCH] builder: test-virt-builder: check some results

Richard W.M. Jones rjones at redhat.com
Tue Jan 14 13:58:30 UTC 2014


On Tue, Jan 14, 2014 at 02:44:03PM +0100, Pino Toscano wrote:
> Check at least some basic modifications in the image created with
> virt-builder.
> ---
>  builder/test-virt-builder.sh | 47 +++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 46 insertions(+), 1 deletion(-)
> 
> diff --git a/builder/test-virt-builder.sh b/builder/test-virt-builder.sh
> index 47d20a4..3c8eb60 100755
> --- a/builder/test-virt-builder.sh
> +++ b/builder/test-virt-builder.sh
> @@ -65,6 +65,51 @@ $VG ./virt-builder phony-fedora \
>      --firstboot Makefile --firstboot-command 'echo "hello"' \
>      --firstboot-install "minicom,inkscape"
>  
> -# XXX Test that the modifications were made.
> +# Check that some modifications were made.
> +$VG ../fish/guestfish --ro -i -a $output > test.out <<EOF
> +# Uploaded files
> +is-file /etc/foo/bar/baz/Makefile
> +cat /etc/foo/bar/baz/foo
> +is-symlink /foo
> +is-symlink /foo1
> +is-symlink /foo2
> +is-symlink /foo3
> +
> +echo -----
> +# Hostname
> +cat /etc/sysconfig/network | grep HOSTNAME=
> +
> +echo -----
> +# Timezone
> +is-file /usr/share/zoneinfo/Europe/London
> +is-symlink /etc/localtime
> +readlink /etc/localtime
> +
> +echo -----
> +# Password
> +is-file /etc/shadow
> +cat /etc/shadow | sed -r '/^root:/!d;s,^(root:\\\$6\\\$).*,\\1,g'
> +EOF
> +
> +if [ "$(cat test.out)" != "true
> +Hello World
> +true
> +true
> +true
> +true
> +-----
> +HOSTNAME=test.example.com
> +-----
> +true
> +true
> +/usr/share/zoneinfo/Europe/London
> +-----
> +true
> +root:\$6\$" ]; then
> +    echo "$0: unexpected output:"
> +    cat test.out
> +    exit 1
> +fi
>  
>  rm $output
> +rm test.out

ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top




More information about the Libguestfs mailing list