mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
builder: Add tests.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -59,8 +59,10 @@ Makefile.in
|
||||
/build-aux
|
||||
/builder/.depend
|
||||
/builder/stamp-virt-builder.pod
|
||||
/builder/test-index
|
||||
/builder/virt-builder
|
||||
/builder/virt-builder.1
|
||||
/builder/*.xz
|
||||
/cat/stamp-virt-*.pod
|
||||
/cat/virt-cat
|
||||
/cat/virt-cat.1
|
||||
|
||||
@@ -21,6 +21,7 @@ EXTRA_DIST = \
|
||||
$(SOURCES) \
|
||||
virt-builder.pod \
|
||||
test-virt-builder.sh \
|
||||
test-virt-builder-list.sh \
|
||||
website/.gitignore \
|
||||
website/README \
|
||||
website/index \
|
||||
@@ -133,8 +134,17 @@ CLEANFILES += stamp-virt-builder.pod
|
||||
|
||||
TESTS_ENVIRONMENT = $(top_builddir)/run --test
|
||||
|
||||
disk_images := $(shell for f in debian.xz fedora.xz ubuntu.xz windows.xz; do b=`basename $$f .xz`; if [ -f "../tests/guests/$$b.img" ]; then echo $$f; fi; done)
|
||||
|
||||
check_DATA = $(disk_images)
|
||||
|
||||
%.xz: ../tests/guests/%.img
|
||||
xz --best --block-size=16777216 -c $< > $@
|
||||
|
||||
TESTS = test-virt-builder-list.sh
|
||||
|
||||
if ENABLE_APPLIANCE
|
||||
TESTS = test-virt-builder.sh
|
||||
TESTS += test-virt-builder.sh
|
||||
endif ENABLE_APPLIANCE
|
||||
|
||||
check-valgrind:
|
||||
|
||||
33
builder/test-index.in
Normal file
33
builder/test-index.in
Normal file
@@ -0,0 +1,33 @@
|
||||
[phony-debian]
|
||||
name=Phony Debian
|
||||
file=debian.xz
|
||||
format=raw
|
||||
size=536870912
|
||||
expand=/dev/sda2
|
||||
lvexpand=/dev/debian/root
|
||||
notes=Phony Debian look-alike used for testing.
|
||||
|
||||
[phony-fedora]
|
||||
name=Phony Fedora
|
||||
file=fedora.xz
|
||||
format=raw
|
||||
size=1073741824
|
||||
expand=/dev/sda2
|
||||
lvexpand=/dev/VG/Root
|
||||
notes=Phony Fedora look-alike used for testing.
|
||||
|
||||
[phony-ubuntu]
|
||||
name=Phony Ubuntu
|
||||
file=ubuntu.xz
|
||||
format=raw
|
||||
size=536870912
|
||||
expand=/dev/sda2
|
||||
notes=Phony Ubuntu look-alike used for testing.
|
||||
|
||||
[phony-windows]
|
||||
name=Phony Windows
|
||||
file=windows.xz
|
||||
format=raw
|
||||
size=536870912
|
||||
expand=/dev/sda2
|
||||
notes=Phony Windows look-alike used for testing.
|
||||
73
builder/test-virt-builder-list.sh
Executable file
73
builder/test-virt-builder-list.sh
Executable file
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash -
|
||||
# libguestfs virt-builder test script
|
||||
# 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.
|
||||
|
||||
# Test the virt-builder --list [--long] options.
|
||||
|
||||
export LANG=C
|
||||
set -e
|
||||
|
||||
abs_srcdir=$(cd $srcdir && pwd)
|
||||
|
||||
export VIRT_BUILDER_SOURCE=file://$abs_srcdir/test-index
|
||||
|
||||
short_list=$(./virt-builder --no-check-signature --no-cache --list)
|
||||
|
||||
if [ "$short_list" != "phony-debian Phony Debian
|
||||
phony-fedora Phony Fedora
|
||||
phony-ubuntu Phony Ubuntu
|
||||
phony-windows Phony Windows" ]; then
|
||||
echo "$0: unexpected --list output:"
|
||||
echo "$short_list"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
long_list=$(./virt-builder --no-check-signature --no-cache --list --long)
|
||||
|
||||
if [ "$long_list" != "Source URI: $VIRT_BUILDER_SOURCE
|
||||
|
||||
os-version: phony-debian
|
||||
Full name: Phony Debian
|
||||
Minimum/default size: 512.0M
|
||||
|
||||
Notes:
|
||||
Phony Debian look-alike used for testing.
|
||||
|
||||
os-version: phony-fedora
|
||||
Full name: Phony Fedora
|
||||
Minimum/default size: 1.0G
|
||||
|
||||
Notes:
|
||||
Phony Fedora look-alike used for testing.
|
||||
|
||||
os-version: phony-ubuntu
|
||||
Full name: Phony Ubuntu
|
||||
Minimum/default size: 512.0M
|
||||
|
||||
Notes:
|
||||
Phony Ubuntu look-alike used for testing.
|
||||
|
||||
os-version: phony-windows
|
||||
Full name: Phony Windows
|
||||
Minimum/default size: 512.0M
|
||||
|
||||
Notes:
|
||||
Phony Windows look-alike used for testing." ]; then
|
||||
echo "$0: unexpected --list --long output:"
|
||||
echo "$long_list"
|
||||
exit 1
|
||||
fi
|
||||
@@ -18,3 +18,31 @@
|
||||
|
||||
export LANG=C
|
||||
set -e
|
||||
|
||||
abs_srcdir=$(cd $srcdir && pwd)
|
||||
|
||||
export VIRT_BUILDER_SOURCE=file://$abs_srcdir/test-index
|
||||
|
||||
if [ ! -f fedora.xz ]; then
|
||||
echo "$0: test skipped because there is no fedora.xz in the build directory"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
rm -f phony-fedora.qcow2
|
||||
|
||||
# Test as many options as we can!
|
||||
#
|
||||
# Note we cannot test --install, --run since the phony Fedora doesn't
|
||||
# have a real OS inside just some configuration files. Just about
|
||||
# every other option is fair game.
|
||||
./virt-builder phony-fedora \
|
||||
--no-cache --no-check-signature \
|
||||
--size 2G --format qcow2 \
|
||||
--root-password password:123456 \
|
||||
--upload Makefile:/Makefile \
|
||||
--firstboot Makefile --firstboot-command 'echo "hello"' \
|
||||
--firstboot-install "minicom,inkscape"
|
||||
|
||||
# XXX Test that the modifications were made.
|
||||
|
||||
rm phony-fedora.qcow2
|
||||
|
||||
@@ -1640,6 +1640,7 @@ AC_CONFIG_FILES([Makefile
|
||||
appliance/Makefile
|
||||
bash/Makefile
|
||||
builder/Makefile
|
||||
builder/test-index
|
||||
cat/Makefile
|
||||
csharp/Makefile
|
||||
daemon/Makefile
|
||||
|
||||
Reference in New Issue
Block a user