diff --git a/.gitignore b/.gitignore index 0ea250831..a7964e816 100644 --- a/.gitignore +++ b/.gitignore @@ -492,6 +492,7 @@ Makefile.in /python/__pycache__ /python/setup.py /python/stamp-extra-files +/python/t/tests_helper.py /python/utils.c /qemu-wrapper.sh /rescue/stamp-virt-rescue.pod diff --git a/align/Makefile.am b/align/Makefile.am index e949e2a80..8d4fce11b 100644 --- a/align/Makefile.am +++ b/align/Makefile.am @@ -78,9 +78,13 @@ TESTS = \ if ENABLE_APPLIANCE TESTS += \ - test-virt-alignment-scan.sh \ + test-virt-alignment-scan.sh + +if HAVE_LIBVIRT +TESTS += \ test-virt-alignment-scan-guests.sh endif +endif check-valgrind: $(MAKE) VG="@VG@" check diff --git a/configure.ac b/configure.ac index 1601a42ea..18c8d5617 100644 --- a/configure.ac +++ b/configure.ac @@ -240,6 +240,7 @@ AC_CONFIG_FILES([Makefile python/Makefile python/examples/Makefile python/setup.py + python/t/tests_helper.py rescue/Makefile resize/Makefile ruby/Makefile diff --git a/df/Makefile.am b/df/Makefile.am index 616e587c9..8725402bc 100644 --- a/df/Makefile.am +++ b/df/Makefile.am @@ -82,8 +82,12 @@ TESTS = \ if ENABLE_APPLIANCE TESTS += \ - test-virt-df.sh \ + test-virt-df.sh + +if HAVE_LIBVIRT +TESTS += \ test-virt-df-guests.sh +endif endif ENABLE_APPLIANCE check-valgrind: diff --git a/fish/Makefile.am b/fish/Makefile.am index d806ebf8b..44c6ccd4f 100644 --- a/fish/Makefile.am +++ b/fish/Makefile.am @@ -277,15 +277,19 @@ TESTS_ENVIRONMENT = $(top_builddir)/run --test TESTS = \ test-a.sh \ - test-add-domain.sh \ test-add-uri.sh \ - test-d.sh \ test-docs.sh \ test-escapes.sh \ test-events.sh \ test-invalid-params.sh \ test-tilde.sh +if HAVE_LIBVIRT +TESTS += \ + test-add-domain.sh \ + test-d.sh +endif + if ENABLE_APPLIANCE TESTS += \ test-copy.sh \ diff --git a/python/t/test910Libvirt.py b/python/t/test910Libvirt.py index 3f8f31774..b605b15be 100644 --- a/python/t/test910Libvirt.py +++ b/python/t/test910Libvirt.py @@ -29,6 +29,7 @@ from .tests_helper import * guestsdir = os.environ['guestsdir'] +@skipUnlessConfiguredWithLibvirt() @skipUnlessLibvirtHasCPointer() class Test910Libvirt(unittest.TestCase): def test_libvirt(self): diff --git a/python/t/tests_helper.py b/python/t/tests_helper.py.in similarity index 88% rename from python/t/tests_helper.py rename to python/t/tests_helper.py.in index 4ae1375ae..28c9c8f57 100644 --- a/python/t/tests_helper.py +++ b/python/t/tests_helper.py.in @@ -1,5 +1,6 @@ # libguestfs Python bindings -# Copyright (C) 2016 Red Hat Inc. +# Copyright (C) 2016-2017 Red Hat Inc. +# @configure_input@ # # 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 @@ -27,6 +28,14 @@ else: int_type = long +def skipUnlessConfiguredWithLibvirt(): + """ + Skip the current class/method if ./configure --without-libvirt + """ + if "@LIBVIRT_LIBS@" == "": + return unittest.skip("configured --without-libvirt") + return lambda func: func + def skipUnlessLibvirtHasCPointer(): """ Skip the current class/method if: diff --git a/tests/disks/Makefile.am b/tests/disks/Makefile.am index 477cec88d..8cc5bdcb0 100644 --- a/tests/disks/Makefile.am +++ b/tests/disks/Makefile.am @@ -19,9 +19,13 @@ include $(top_srcdir)/subdir-rules.mk TESTS = \ test-max-disks.pl \ - test-qemu-drive-libvirt.sh \ test-qemu-drive.sh +if HAVE_LIBVIRT +TESTS += \ + test-qemu-drive-libvirt.sh +endif + TESTS_ENVIRONMENT = \ $(top_builddir)/run --test diff --git a/v2v/Makefile.am b/v2v/Makefile.am index ffd514426..c458833c4 100644 --- a/v2v/Makefile.am +++ b/v2v/Makefile.am @@ -255,21 +255,30 @@ TESTS = \ test-v2v-i-ova-gz.sh \ test-v2v-i-ova-subfolders.sh \ test-v2v-i-ova-two-disks.sh \ - test-v2v-copy-to-local.sh \ test-v2v-bad-networks-and-bridges.sh +if HAVE_LIBVIRT +TESTS += \ + test-v2v-copy-to-local.sh +endif + if HAVE_OCAML_PKG_OUNIT TESTS += v2v_unit_tests endif if ENABLE_APPLIANCE TESTS += \ - test-v2v-cdrom.sh \ - test-v2v-floppy.sh \ test-v2v-i-ova.sh \ test-v2v-i-disk.sh \ - test-v2v-in-place.sh \ test-v2v-machine-readable.sh \ + test-v2v-virtio-win-iso.sh \ + test-v2v-windows-conversion.sh + +if HAVE_LIBVIRT +TESTS += \ + test-v2v-cdrom.sh \ + test-v2v-floppy.sh \ + test-v2v-in-place.sh \ test-v2v-networks-and-bridges.sh \ test-v2v-no-copy.sh \ test-v2v-o-glance.sh \ @@ -283,9 +292,8 @@ TESTS += \ test-v2v-on-option.sh \ test-v2v-print-source.sh \ test-v2v-sound.sh \ - test-v2v-virtio-win-iso.sh \ - test-v2v-windows-conversion.sh \ $(SLOW_TESTS) +endif endif ENABLE_APPLIANCE check-valgrind: