Hi,

Am Mo, 4. Jun, 2018 um 5:38 schrieb Michael Tremer <michael.tremer@ipfire.org>:
This patch lets make automatically download all required images and extracts them. Signed-off-by: Michael Tremer <michael.tremer@ipfire.org> --- Makefile.am | 40 +++++++++++++++++-- configure.ac | 1 + test/nitsi/virtual-environment/.gitignore | 1 + .../basic/machines/.gitignore | 1 + .../alice/{machine.xml => machine.xml.in} | 2 +- .../snapshot.xml => alice/snapshot.xml.in} | 2 +- .../bob/{machine.xml => machine.xml.in} | 2 +- .../snapshot.xml => bob/snapshot.xml.in} | 2 +- 8 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 test/nitsi/virtual-environment/.gitignore create mode 100644 test/nitsi/virtual-environment/basic/machines/.gitignore rename test/nitsi/virtual-environment/basic/machines/alice/{machine.xml => machine.xml.in} (98%) rename test/nitsi/virtual-environment/basic/machines/{bob/snapshot.xml => alice/snapshot.xml.in} (69%) rename test/nitsi/virtual-environment/basic/machines/bob/{machine.xml => machine.xml.in} (98%) rename test/nitsi/virtual-environment/basic/machines/{alice/snapshot.xml => bob/snapshot.xml.in} (70%) diff --git a/Makefile.am b/Makefile.am index 06b6cddd2b74..f4b8ba13dbea 100644 --- a/Makefile.am +++ b/Makefile.am @@ -89,6 +89,10 @@ INSTALL_EXEC_HOOKS += \ # ------------------------------------------------------------------------------ +AM_V_DOWNLOAD = $(AM_V_DOWNLOAD_$(V)) +AM_V_DOWNLOAD_ = $(AM_V_DOWNLOAD_$(AM_DEFAULT_VERBOSITY)) +AM_V_DOWNLOAD_0 = @echo " LOAD " $@; + AM_V_NITSI = $(AM_V_NITSI_$(V)) AM_V_NITSI_ = $(AM_V_NITSI_$(AM_DEFAULT_VERBOSITY)) AM_V_NITSI_0 = @echo " NITSI " $@; @@ -496,7 +500,8 @@ substitutions = \ '|sbindir=$(sbindir)|' \ '|networkdir=$(networkdir)|' \ '|helpersdir=$(helpersdir)|' \ - '|utildir=$(utildir)|' + '|utildir=$(utildir)|' \ + '|VIRTUAL_ENVIRONMENT_IMAGES_DIR=$(VIRTUAL_ENVIRONMENT_IMAGES_DIR)|' SED_PROCESS = \ $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \ @@ -543,7 +548,7 @@ TESTS = \ # - NITSI tests ---------------------------------------------------------------- # Files for the virtual environment -EXTRA_DIST += \ +VIRTUAL_ENVIRONMENT_FILES = \ test/nitsi/virtual-environment/basic/machines/alice/machine.xml \ test/nitsi/virtual-environment/basic/machines/alice/snapshot.xml \ test/nitsi/virtual-environment/basic/machines/bob/machine.xml \ @@ -555,6 +560,30 @@ EXTRA_DIST += \ test/nitsi/virtual-environment/basic/README \ test/nitsi/virtual-environment/basic/settings
Here we need a "settings.in"
+EXTRA_DIST += \ + test/nitsi/virtual-environment/basic/machines/alice/machine.xml.in \ + test/nitsi/virtual-environment/basic/machines/alice/snapshot.xml.in \ + test/nitsi/virtual-environment/basic/machines/bob/machine.xml.in \ + test/nitsi/virtual-environment/basic/machines/bob/snapshot.xml.in + +CLEANFILES += \ + test/nitsi/virtual-environment/basic/machines/alice/machine.xml \ + test/nitsi/virtual-environment/basic/machines/alice/snapshot.xml \ + test/nitsi/virtual-environment/basic/machines/bob/machine.xml \ + test/nitsi/virtual-environment/basic/machines/bob/snapshot.xml + +# Virtual Machine Images +VIRTUAL_ENVIRONMENT_IMAGES = \ + $(VIRTUAL_ENVIRONMENT_IMAGES_DIR)/ipfire-alice-2.qcow2 \ + $(VIRTUAL_ENVIRONMENT_IMAGES_DIR)/ipfire-bob.qcow2 + +DISTCLEANFILES += \ + $(VIRTUAL_ENVIRONMENT_IMAGES) + +VIRTUAL_ENVIRONMENT_IMAGES_DIR = $(abs_builddir)/test/nitsi/virtual-environment/.images +VIRTUAL_ENVIRONMENT_IMAGES_DOWNLOAD_URL = \ + https://people.ipfire.org/~jschlag/nitsi-ipfire/virtual-environment/basic/ + NITSI_TESTS = \ test/nitsi/test/hello-world \ test/nitsi/test/make-check @@ -572,8 +601,13 @@ CLEANFILES += \ NITSI_ENVIRONMENT = .PHONY: $(NITSI_TESTS) -$(NITSI_TESTS): % : %/recipe %/settings +$(NITSI_TESTS): % : %/recipe %/settings $(VIRTUAL_ENVIRONMENT_FILES) $(VIRTUAL_ENVIRONMENT_IMAGES) $(AM_V_NITSI) $(NITSI_ENVIRONMENT) $(NITSI) --log-level error -d $@ .PHONY: nitsi nitsi: dist $(NITSI_TESTS) + +# Downloads a virtual image file and extracts it +$(VIRTUAL_ENVIRONMENT_IMAGES): + $(AM_V_DOWNLOAD)$(MKDIR_P) $(dir $@) && \ + $(WGET) -qO - $(VIRTUAL_ENVIRONMENT_IMAGES_DOWNLOAD_URL)/$(notdir $@).xz | xz -qd > $@

xz is not a variable here like $(WGET) but it should be
diff --git a/configure.ac b/configure.ac index 515941451aba..e84bec7d284a 100644 --- a/configure.ac +++ b/configure.ac @@ -51,6 +51,7 @@ AC_PROG_MKDIR_P AC_PROG_SED AC_PATH_PROG([NITSI], [nitsi]) +AC_PATH_PROG([WGET], [wget]) AC_PATH_PROG([XSLTPROC], [xsltproc]) # pkg-config diff --git a/test/nitsi/virtual-environment/.gitignore b/test/nitsi/virtual-environment/.gitignore new file mode 100644 index 000000000000..5a345eca37b4 --- /dev/null +++ b/test/nitsi/virtual-environment/.gitignore @@ -0,0 +1 @@ +/.images diff --git a/test/nitsi/virtual-environment/basic/machines/.gitignore b/test/nitsi/virtual-environment/basic/machines/.gitignore new file mode 100644 index 000000000000..89b260551efd --- /dev/null +++ b/test/nitsi/virtual-environment/basic/machines/.gitignore @@ -0,0 +1 @@ +*/*.xml diff --git a/test/nitsi/virtual-environment/basic/machines/alice/machine.xml b/test/nitsi/virtual-environment/basic/machines/alice/machine.xml.in similarity index 98% rename from test/nitsi/virtual-environment/basic/machines/alice/machine.xml rename to test/nitsi/virtual-environment/basic/machines/alice/machine.xml.in index 5f5b4aca5017..be8da3886021 100644 --- a/test/nitsi/virtual-environment/basic/machines/alice/machine.xml +++ b/test/nitsi/virtual-environment/basic/machines/alice/machine.xml.in @@ -28,7 +28,7 @@ <devices> <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> - <source file='/var/lib/libvirt/images/ipfire-alice.qcow2'/> + <source file='@VIRTUAL_ENVIRONMENT_IMAGES_DIR@/ipfire-alice-2.qcow2'/>

The path to the image needs to be changed also in the settings file otherwise the copy in feature will not work.
<target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/> </disk> diff --git a/test/nitsi/virtual-environment/basic/machines/bob/snapshot.xml b/test/nitsi/virtual-environment/basic/machines/alice/snapshot.xml.in similarity index 69% rename from test/nitsi/virtual-environment/basic/machines/bob/snapshot.xml rename to test/nitsi/virtual-environment/basic/machines/alice/snapshot.xml.in index a8311a261fea..8d2d1c05f5ad 100644 --- a/test/nitsi/virtual-environment/basic/machines/bob/snapshot.xml +++ b/test/nitsi/virtual-environment/basic/machines/alice/snapshot.xml.in @@ -2,7 +2,7 @@ <description>Snapshot to undo all changes from this test</description> <memory>no</memory> <disks> - <disk name='/var/lib/libvirt/images/ipfire-bob.qcow2'> + <disk name='@VIRTUAL_ENVIRONMENT_IMAGES_DIR@/ipfire-alice-2.qcow2'> </disk> </disks> </domainsnapshot> diff --git a/test/nitsi/virtual-environment/basic/machines/bob/machine.xml b/test/nitsi/virtual-environment/basic/machines/bob/machine.xml.in similarity index 98% rename from test/nitsi/virtual-environment/basic/machines/bob/machine.xml rename to test/nitsi/virtual-environment/basic/machines/bob/machine.xml.in index 60682112db17..f314e8edc5aa 100644 --- a/test/nitsi/virtual-environment/basic/machines/bob/machine.xml +++ b/test/nitsi/virtual-environment/basic/machines/bob/machine.xml.in @@ -28,7 +28,7 @@ <devices> <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> - <source file='/var/lib/libvirt/images/ipfire-bob.qcow2'/> + <source file='@VIRTUAL_ENVIRONMENT_IMAGES_DIR@/ipfire-bob.qcow2'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/> </disk> diff --git a/test/nitsi/virtual-environment/basic/machines/alice/snapshot.xml b/test/nitsi/virtual-environment/basic/machines/bob/snapshot.xml.in similarity index 70% rename from test/nitsi/virtual-environment/basic/machines/alice/snapshot.xml rename to test/nitsi/virtual-environment/basic/machines/bob/snapshot.xml.in index fff9b97752e0..f15d19adc5d2 100644 --- a/test/nitsi/virtual-environment/basic/machines/alice/snapshot.xml +++ b/test/nitsi/virtual-environment/basic/machines/bob/snapshot.xml.in @@ -2,7 +2,7 @@ <description>Snapshot to undo all changes from this test</description> <memory>no</memory> <disks> - <disk name='/var/lib/libvirt/images/ipfire-alice.qcow2'> + <disk name='@VIRTUAL_ENVIRONMENT_IMAGES_DIR@/ipfire-bob.qcow2'> </disk> </disks> </domainsnapshot>
--
2.17.0