[Libguestfs] [nbdkit PATCH 2/1] RFC: tests: Run tests that don't require libguestfs

Eric Blake eblake at redhat.com
Mon Apr 9 20:44:12 UTC 2018


A bit of refactoring to the HAVE_LIBGUESTFS conditional,
coupled with the addition of a LIBGUESTFS_TESTS intermediate
list, allows us to run a few more tests on CentOS 6 (adding
some tests of command-line behavior and filters that was
previously completely skipped).

For the two tests that we can't run, using check_PROGRAMS
still causes those programs to try to compile (which leads to
compile errors); but using EXTRA_PROGRAMS keeps automake
silent without getting those sources in the way, while still
distributing the sources for someone motivated to fix the
tests.

Compared to the previous patch (14/14 pass and 5 skip), I now
have 15/18 pass and 9 skip.

Signed-off-by: Eric Blake <eblake at redhat.com>
---

This one was more invasive than the previous, but may still be
worth having on top of the configure change that disables
HAVE_LIBGUESTFS on CentOS 7.  The three test failures are now:

./test-dump-plugin-example4.sh: unexpected output from nbdkit example4 --dump-plugin
path=/home/dummy/nbdkit/plugins/perl/.libs/nbdkit-perl-plugin.so
name=perl
version=1.3.0
...
has__zero_old=1
FAIL: test-dump-plugin-example4.sh


nbd://?socket=cache.sock: No such file or directory
./test-cache.sh: line 64: kill: (32161) - No such process
FAIL: test-cache.sh
guestfish: -N parameter 'cow-base.img=fs': no such prepared disk image known.
Use 'guestfish -N help' to list possible values for the -N parameter.
FAIL: test-cow.sh

(hmm, so my attempt to guard test-cache.sh and test-cow.sh by
HAVE_GUESTFISH didn't really help)

 tests/Makefile.am | 71 +++++++++++++++++++++++++------------------------------
 1 file changed, 32 insertions(+), 39 deletions(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2cc2344..4582120 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -190,7 +190,11 @@ TESTS += \

 # Most in-depth tests need libguestfs, since that is a convenient way to
 # drive qemu.
+LIBGUESTFS_TESTS =
+EXTRA_PROGRAMS =
 if HAVE_LIBGUESTFS
+check_PROGRAMS += $(LIBGUESTFS_TESTS)
+TESTS += $(LIBGUESTFS_TESTS)

 # Use the 'direct' backend, and ensure maximum libguestfs debugging is
 # written to the *.log files in case there is a problem.
@@ -206,32 +210,30 @@ libtest_la_SOURCES = test.c test.h
 libtest_la_CFLAGS = $(WARNINGS_CFLAGS)

 # Basic connection test.
-check_PROGRAMS += test-connect
-TESTS += test-connect
+LIBGUESTFS_TESTS += test-connect

 test_connect_SOURCES = test-connect.c test.h
 test_connect_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
 test_connect_LDADD = libtest.la $(LIBGUESTFS_LIBS)

 # newstyle protocol test.
-check_PROGRAMS += test-newstyle
-TESTS += test-newstyle
+LIBGUESTFS_TESTS += test-newstyle

 test_newstyle_SOURCES = test-newstyle.c test.h
 test_newstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
 test_newstyle_LDADD = libtest.la $(LIBGUESTFS_LIBS)

 # oldstyle protocol test.
-check_PROGRAMS += test-oldstyle
-TESTS += test-oldstyle
+LIBGUESTFS_TESTS += test-oldstyle

 test_oldstyle_SOURCES = test-oldstyle.c test.h
 test_oldstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
 test_oldstyle_LDADD = libtest.la $(LIBGUESTFS_LIBS)

+endif HAVE_LIBGUESTFS
+
 # file plugin test.
-check_PROGRAMS += test-file
-TESTS += test-file
+LIBGUESTFS_TESTS += test-file

 test_file_SOURCES = test-file.c test.h
 test_file_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
@@ -241,8 +243,7 @@ test_file_LDADD = libtest.la $(LIBGUESTFS_LIBS)
 if HAVE_ZLIB
 if HAVE_GUESTFISH

-check_PROGRAMS += test-gzip
-TESTS += test-gzip
+LIBGUESTFS_TESTS += test-gzip
 check_DATA += disk disk.gz
 MAINTAINERCLEANFILES += disk disk.gz

@@ -263,24 +264,21 @@ endif HAVE_GUESTFISH
 endif HAVE_ZLIB

 # memory plugin test.
-check_PROGRAMS += test-memory
-TESTS += test-memory
+LIBGUESTFS_TESTS += test-memory

 test_memory_SOURCES = test-memory.c test.h
 test_memory_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
 test_memory_LDADD = libtest.la $(LIBGUESTFS_LIBS)

 # nbd plugin test.
-check_PROGRAMS += test-nbd
-TESTS += test-nbd
+LIBGUESTFS_TESTS += test-nbd

 test_nbd_SOURCES = test-nbd.c test.h
 test_nbd_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
 test_nbd_LDADD = libtest.la $(LIBGUESTFS_LIBS)

 # null plugin test.
-check_PROGRAMS += test-null
-TESTS += test-null
+LIBGUESTFS_TESTS += test-null

 test_null_SOURCES = test-null.c test.h
 test_null_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
@@ -301,17 +299,16 @@ split3: file-data
 	rm -f $@ $@-t
 	dd if=$< of=$@-t bs=1 skip=200
 	mv $@-t $@
-check_PROGRAMS += test-split
-TESTS += test-split
+LIBGUESTFS_TESTS += test-split

 test_split_SOURCES = test-split.c test.h
 test_split_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
 test_split_LDADD = libtest.la $(LIBGUESTFS_LIBS)

 # streaming plugin test.
-check_PROGRAMS += test-streaming
 # Doesn't work:
-#TESTS += test-streaming
+#LIBGUESTFS_TESTS += test-streaming
+EXTRA_PROGRAMS += test-streaming

 test_streaming_SOURCES = test-streaming.c test.h
 test_streaming_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
@@ -321,8 +318,7 @@ test_streaming_LDADD = libtest.la $(LIBGUESTFS_LIBS)
 if HAVE_LIBLZMA
 if HAVE_GUESTFISH

-check_PROGRAMS += test-xz
-TESTS += test-xz
+LIBGUESTFS_TESTS += test-xz
 check_DATA += disk.xz
 MAINTAINERCLEANFILES += disk.xz

@@ -343,8 +339,7 @@ endif HAVE_LIBLZMA
 # OCaml plugin test.
 if HAVE_OCAML

-check_PROGRAMS += test-ocaml
-TESTS += test-ocaml
+LIBGUESTFS_TESTS += test-ocaml

 # This is somewhat different from the other tests because we have
 # to build an actual plugin here.
@@ -365,11 +360,10 @@ endif HAVE_OCAML
 # perl plugin test.
 if HAVE_PERL

-check_PROGRAMS += test-perl
 TESTS += \
 	test-dump-plugin-example4.sh \
-	test-perl \
 	test-shebang-perl.sh
+LIBGUESTFS_TESTS += test-perl

 test_perl_SOURCES = test-lang-plugins.c test.h
 test_perl_CFLAGS = \
@@ -382,11 +376,10 @@ endif HAVE_PERL
 # python plugin test.
 if HAVE_PYTHON

-check_PROGRAMS += test-python
 TESTS += \
-	test-python \
 	test-python-exception.sh \
 	test-shebang-python.sh
+LIBGUESTFS_TESTS += test-python

 test_python_SOURCES = test-lang-plugins.c test.h
 test_python_CFLAGS = \
@@ -402,10 +395,10 @@ if HAVE_RUBY
 # Ruby tests are disabled.  See "WARNING" section in
 # plugins/ruby/nbdkit-ruby-plugin.pod

-check_PROGRAMS += test-ruby
-#TESTS += \
-#	test-ruby \
-#	test-shebang-ruby.sh
+#LIBGUESTFS_TESTS += \
+#	test-ruby
+#TESTS += test-shebang-ruby.sh
+EXTRA_PROGRAMS += test-ruby

 test_ruby_SOURCES = test-lang-plugins.c test.h
 test_ruby_CFLAGS = \
@@ -422,14 +415,17 @@ endif HAVE_RUBY
 TESTS += test-blocksize.sh

 # cache filter test.
+if HAVE_GUESTFISH
 TESTS += test-cache.sh
+endif HAVE_GUESTFISH

 # cow filter test.
+if HAVE_GUESTFISH
 TESTS += test-cow.sh
+endif HAVE_GUESTFISH

 # delay filter test.
-check_PROGRAMS += test-delay
-TESTS += test-delay
+LIBGUESTFS_TESTS += test-delay

 test_delay_SOURCES = test-delay.c test.h
 test_delay_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
@@ -447,8 +443,7 @@ TESTS += test-nozero.sh
 # offset filter test.
 check_DATA += offset-data
 MAINTAINERCLEANFILES += offset-data
-check_PROGRAMS += test-offset
-TESTS += test-offset
+LIBGUESTFS_TESTS += test-offset

 offset-data:
 	rm -f $@ $@-t
@@ -460,12 +455,10 @@ test_offset_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
 test_offset_LDADD = libtest.la $(LIBGUESTFS_LIBS)

 # partition filter test.
-check_PROGRAMS += test-partition
-TESTS += test-partition
+LIBGUESTFS_TESTS += test-partition

 test_partition_SOURCES = test-partition.c test.h
 test_partition_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
 test_partition_LDADD = libtest.la $(LIBGUESTFS_LIBS)

-endif HAVE_LIBGUESTFS
 endif HAVE_PLUGINS
-- 
2.14.3




More information about the Libguestfs mailing list