[Libguestfs] [PATCH v4 15/17] builder: Rationalize the tests.

Richard W.M. Jones rjones at redhat.com
Thu Aug 6 15:05:57 UTC 2015


Instead of using a pre-built test-config/ subdirectory, just create
the required config on the fly when we need it in the tests.

Don't add *.xz files to check_data since that requires that we have a
working appliance in order to do a simple 'make', which doesn't work
on --disable-appliance builds.  Instead, create the disk images on
demand in the test scripts.

At the same time, remove the website override in ./run since that
always breaks 'make check-slow' during the release tests.
---
 builder/Makefile.am                                | 19 --------------
 .../virt-builder/repos.d/test-index.conf.in        |  2 --
 builder/test-virt-builder-list.sh                  | 15 ++++++++---
 builder/test-virt-builder-planner.sh               | 30 ++++++++++++++--------
 builder/test-virt-builder.sh                       | 17 ++++++++----
 .../virt-builder/repos.d/libguestfs.conf.in        |  3 ---
 builder/tests.mk                                   |  6 -----
 configure.ac                                       |  2 --
 generator/tests.ml                                 |  6 -----
 run.in                                             |  7 -----
 10 files changed, 44 insertions(+), 63 deletions(-)
 delete mode 100644 builder/test-config/virt-builder/repos.d/test-index.conf.in
 delete mode 100644 builder/test-website/virt-builder/repos.d/libguestfs.conf.in

diff --git a/builder/Makefile.am b/builder/Makefile.am
index aa74c3d..2e10d41 100644
--- a/builder/Makefile.am
+++ b/builder/Makefile.am
@@ -207,25 +207,6 @@ stamp-virt-builder.pod: virt-builder.pod $(top_srcdir)/customize/customize-synop
 
 CLEANFILES += stamp-virt-builder.pod
 
-# Disk images for tests.
-
-CLEANFILES += *.qcow2 *.xz
-
-fedora.qcow2: ../tests/guests/fedora.img
-	rm -f $@ $@-t
-	qemu-img convert -f raw -O qcow2 $< $@-t
-	mv $@-t $@
-
-fedora.qcow2.xz: fedora.qcow2
-	rm -f $@ $@-t
-	xz --best -c $< > $@-t
-	mv $@-t $@
-
-%.xz: ../tests/guests/%.img
-	rm -f $@ $@-t
-	xz --best -c $< > $@-t
-	mv $@-t $@
-
 # Dependencies.
 depend: .depend
 
diff --git a/builder/test-config/virt-builder/repos.d/test-index.conf.in b/builder/test-config/virt-builder/repos.d/test-index.conf.in
deleted file mode 100644
index 22e03c4..0000000
--- a/builder/test-config/virt-builder/repos.d/test-index.conf.in
+++ /dev/null
@@ -1,2 +0,0 @@
-[test-index]
-uri=file://@abs_top_builddir@/builder/test-index
diff --git a/builder/test-virt-builder-list.sh b/builder/test-virt-builder-list.sh
index e42e3ec..5a5d61c 100755
--- a/builder/test-virt-builder-list.sh
+++ b/builder/test-virt-builder-list.sh
@@ -21,8 +21,17 @@
 export LANG=C
 set -e
 
+# Create phony configuration.
+cp $srcdir/test-index .
+
+mkdir -p virt-builder/repos.d
+cat > virt-builder/repos.d/test-index.conf <<EOF
+[test-index]
+uri=file://$tmpdir/test-index
+EOF
+
 export XDG_CONFIG_HOME=
-export XDG_CONFIG_DIRS="$abs_builddir/test-config"
+export XDG_CONFIG_DIRS="$tmpdir"
 
 short_list=$($VG virt-builder --no-check-signature --no-cache --list)
 
@@ -40,7 +49,7 @@ fi
 
 long_list=$(virt-builder --no-check-signature --no-cache --list --long)
 
-if [ "$long_list" != "Source URI: file://$abs_builddir/test-index
+if [ "$long_list" != "Source URI: file://$tmpdir/test-index
 
 os-version:              phony-debian
 Full name:               Phony Debian
@@ -115,7 +124,7 @@ if [ "$json_list" != "{
   \"version\": 1,
   \"sources\": [
     {
-      \"uri\": \"file://$abs_builddir/test-index\"
+      \"uri\": \"file://$tmpdir/test-index\"
     }
   ],
   \"templates\": [
diff --git a/builder/test-virt-builder-planner.sh b/builder/test-virt-builder-planner.sh
index f974c27..40a3d7e 100755
--- a/builder/test-virt-builder-planner.sh
+++ b/builder/test-virt-builder-planner.sh
@@ -19,21 +19,31 @@
 export LANG=C
 set -e
 
-abs_builddir=$(pwd)
-
-export XDG_CONFIG_HOME=
-export XDG_CONFIG_DIRS="$abs_builddir/test-config"
-
-if [ ! -f fedora.xz -o ! -f fedora.qcow2 -o ! -f fedora.qcow2.xz ]; then
-    echo "$0: test skipped because there is no fedora.xz, fedora.qcow2 or fedora.qcow2.xz in the build directory"
-    exit 77
-fi
-
 if [ "$(guestfish get-backend)" = "uml" ]; then
     echo "$0: test skipped because backend is UML"
     exit 77
 fi
 
+# Create phony configuration.
+cp $srcdir/test-index .
+
+mkdir -p virt-builder/repos.d
+cat > virt-builder/repos.d/test-index.conf <<EOF
+[test-index]
+uri=file://$tmpdir/test-index
+EOF
+
+export XDG_CONFIG_HOME=
+export XDG_CONFIG_DIRS="$tmpdir"
+
+# Create test images.
+for f in debian fedora ubuntu windows; do
+    xz -c $phonydir/$f.img > $f.xz
+done
+
+qemu-img convert -f raw -O qcow2 $phonydir/fedora.img fedora.qcow2
+xz -c fedora.qcow2 > fedora.qcow2.xz
+
 rm -f planner-output
 
 for input in phony-fedora phony-fedora-qcow2 phony-fedora-qcow2-uncompressed phony-fedora-no-format; do
diff --git a/builder/test-virt-builder.sh b/builder/test-virt-builder.sh
index c6e99c4..0fe7bcc 100755
--- a/builder/test-virt-builder.sh
+++ b/builder/test-virt-builder.sh
@@ -19,13 +19,20 @@
 export LANG=C
 set -e
 
+# Create phony configuration.
+cp $srcdir/test-index .
+
+mkdir -p virt-builder/repos.d
+cat > virt-builder/repos.d/test-index.conf <<EOF
+[test-index]
+uri=file://$tmpdir/test-index
+EOF
+
 export XDG_CONFIG_HOME=
-export XDG_CONFIG_DIRS="$abs_builddir/test-config"
+export XDG_CONFIG_DIRS="$tmpdir"
 
-if [ ! -f $builddir/fedora.xz ]; then
-    echo "$0: test skipped because there is no fedora.xz in the build directory"
-    exit 77
-fi
+# Create one test image.
+xz -c $phonydir/fedora.img > fedora.xz
 
 output=phony-fedora.img
 
diff --git a/builder/test-website/virt-builder/repos.d/libguestfs.conf.in b/builder/test-website/virt-builder/repos.d/libguestfs.conf.in
deleted file mode 100644
index 7bbc28d..0000000
--- a/builder/test-website/virt-builder/repos.d/libguestfs.conf.in
+++ /dev/null
@@ -1,3 +0,0 @@
-[libguestfs.org]
-uri=file://@abs_top_srcdir@/builder/website/index.asc
-gpgkey=file://@abs_top_srcdir@/builder/libguestfs.gpg
diff --git a/builder/tests.mk b/builder/tests.mk
index d4efad0..c04a62a 100644
--- a/builder/tests.mk
+++ b/builder/tests.mk
@@ -22,12 +22,6 @@
 localtestsdir = $(alltestsdir)/builder
 
 localtests_DATA = \
-	debian.xz \
-	fedora.qcow2 \
-	fedora.qcow2.xz \
-	fedora.xz \
-	ubuntu.xz \
-	windows.xz \
 	test-index \
 	test-virt-index-validate-bad-1 \
 	test-virt-index-validate-good-1 \
diff --git a/configure.ac b/configure.ac
index de480e7..8ed6db8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1729,8 +1729,6 @@ AC_CONFIG_FILES([Makefile
                  bash/Makefile
                  builder/Makefile
                  builder/libguestfs.conf
-                 builder/test-config/virt-builder/repos.d/test-index.conf
-                 builder/test-website/virt-builder/repos.d/libguestfs.conf
                  builder/website/Makefile
                  cat/Makefile
                  csharp/Makefile
diff --git a/generator/tests.ml b/generator/tests.ml
index a88276d..ce04687 100644
--- a/generator/tests.ml
+++ b/generator/tests.ml
@@ -627,12 +627,6 @@ let tests = [
         "test-virt-builder-planner.sh"
       ];
       check_data = [
-        "debian.xz";
-        "fedora.xz";
-        "ubuntu.xz";
-        "windows.xz";
-        "fedora.qcow2";
-        "fedora.qcow2.xz";
 	"test-index";
 	"test-virt-index-validate-bad-1";
 	"test-virt-index-validate-good-1";
diff --git a/run.in b/run.in
index 42f8cc8..8949631 100755
--- a/run.in
+++ b/run.in
@@ -116,13 +116,6 @@ prepend DYLD_LIBRARY_PATH "$b/src/.libs"
 export LD_LIBRARY_PATH
 export DYLD_LIBRARY_PATH
 
-# Make virt-builder use the local website copy to avoid hitting
-# the network all the time.
-if [ -z "$XDG_CONFIG_DIRS" ]; then
-    prepend XDG_CONFIG_DIRS "$b/builder/test-website"
-    export XDG_CONFIG_DIRS
-fi
-
 # virt-p2v-make-* data directory.
 if [ -z "$VIRT_P2V_DATA_DIR" ]; then
     VIRT_P2V_DATA_DIR="$b/p2v"
-- 
2.5.0




More information about the Libguestfs mailing list