tests: Add tests that just including the header works.
[nbdkit/ericb.git] / tests / Makefile.am
blob601da5f4bfb0136f23d891497ddf1086f8f4482b
1 # nbdkit
2 # Copyright (C) 2013-2019 Red Hat Inc.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # * Neither the name of Red Hat nor the names of its contributors may be
16 # used to endorse or promote products derived from this software without
17 # specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
20 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
23 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 # SUCH DAMAGE.
32 include $(top_srcdir)/common-rules.mk
34 EXTRA_DIST = \
35         generate-file-data.sh \
36         generate-offset-data.sh \
37         make-pki.sh \
38         make-psk.sh \
39         python-exception.py \
40         README.tests \
41         shebang.pl \
42         shebang.py \
43         shebang.rb \
44         ssh/sshd_config.in \
45         test-ansi-c.sh \
46         test-blocksize.sh \
47         test-cache.sh \
48         test-cache-max-size.sh \
49         test-cache-on-read.sh \
50         test-captive.sh \
51         test-cow.sh \
52         test-cxx.sh \
53         test-data-7E.sh \
54         test-data-base64.sh \
55         test-data-extents.sh \
56         test-data-file.sh \
57         test-data-raw.sh \
58         test-debug-flags.sh \
59         test-dump-config.sh \
60         test-dump-plugin.sh \
61         test-dump-plugin-example4.sh \
62         test-eflags.sh \
63         test-error0.sh \
64         test-error10.sh \
65         test-error100.sh \
66         test-file-extents.sh \
67         test-floppy.sh \
68         test-foreground.sh \
69         test-fua.sh \
70         test-full.sh \
71         test-help.sh \
72         test-help-plugin.sh \
73         test-ip.sh \
74         test-iso.sh \
75         test-layers.sh \
76         test-linuxdisk.sh \
77         test-linuxdisk-copy-out.sh \
78         test-log.sh \
79         test.lua \
80         test-memory-largest.sh \
81         test-memory-largest-for-qemu.sh \
82         test-nozero.sh \
83         test-null-extents.sh \
84         test_ocaml_plugin.ml \
85         test-ocaml.c \
86         test-offset2.sh \
87         test-offset-extents.sh \
88         test-parallel-file.sh \
89         test-parallel-nbd.sh \
90         test-partition1.sh \
91         test-partition2.sh \
92         test-partitioning1.sh \
93         test-partitioning2.sh \
94         test-partitioning3.sh \
95         test-partitioning4.sh \
96         test-partitioning5.sh \
97         test-partitioning6.sh \
98         test-pattern.sh \
99         test-pattern-largest.sh \
100         test-pattern-largest-for-qemu.sh \
101         test-python-exception.sh \
102         test.pl \
103         test.py \
104         test-rate.sh \
105         test-rate-dynamic.sh \
106         test.rb \
107         test-readahead-copy.sh \
108         test-ssh.sh \
109         test.tcl \
110         test-shebang-perl.sh \
111         test-shebang-python.sh \
112         test-shebang-ruby.sh \
113         test-shell.sh \
114         test-sh-extents.sh \
115         test-single.sh \
116         test-single-from-file.sh \
117         test-start.sh \
118         test-random-sock.sh \
119         test-tls.sh \
120         test-tls-psk.sh \
121         test-truncate1.sh \
122         test-truncate2.sh \
123         test-truncate3.sh \
124         test-truncate-extents.sh \
125         test-vddk.sh \
126         test-vddk-real.sh \
127         test-version.sh \
128         test-version-filter.sh \
129         test-version-plugin.sh \
130         test-zero.sh
132 # Use 'make check' to run the ordinary tests.  To run all the tests
133 # under valgrind, use the following rule:
134 check-valgrind:
135         NBDKIT_VALGRIND=1 $(MAKE) check
137 # To run only tests which require root, use:
138 check-root:
139         $(MAKE) check TESTS="test-file-block"
141 # Run a basic check against a real copy of VDDK.  You must set
142 # vddkdir to point to the library location, eg:
144 #   make check-vddk vddkdir=vmware-vix-disklib-distrib
145 check-vddk:
146         $(MAKE) check TESTS=test-vddk-real.sh
148 #----------------------------------------------------------------------
149 # Basic server command line and start-up tests.
151 check_PROGRAMS =
152 check_DATA =
153 check_SCRIPTS =
154 check_LTLIBRARIES =
155 noinst_LTLIBRARIES =
157 # Ensure we're testing the local copy by running everything through
158 # the nbdkit helper script in the top build directory.
159 TESTS_ENVIRONMENT = PATH=$(abs_top_builddir):$(PATH) SRCDIR=$(srcdir)
161 TESTS = \
162         test-help.sh \
163         test-version.sh \
164         test-dump-config.sh
166 if HAVE_PLUGINS
168 TESTS += \
169         test-help-plugin.sh \
170         test-version-plugin.sh \
171         test-version-filter.sh \
172         test-dump-plugin.sh \
173         test-start.sh \
174         test-single.sh \
175         test-single-from-file.sh \
176         test-captive.sh \
177         test-random-sock.sh \
178         test-tls.sh \
179         test-tls-psk.sh \
180         test-ip.sh \
181         test-socket-activation \
182         test-foreground.sh \
183         test-debug-flags.sh
185 check_PROGRAMS += \
186         test-socket-activation
188 test_socket_activation_SOURCES = test-socket-activation.c
189 test_socket_activation_CFLAGS = $(WARNINGS_CFLAGS)
191 endif HAVE_PLUGINS
193 # Test the header files can be included on their own.
194 check_PROGRAMS += \
195         test-just-plugin-header \
196         test-just-filter-header
197 TESTS += \
198         test-just-plugin-header \
199         test-just-filter-header
201 test_just_plugin_header_SOURCES = \
202         test-just-plugin-header.c
203 test_just_plugin_header_CPPFLAGS = \
204         -I$(top_srcdir)/include
205 test_just_plugin_header_CFLAGS = \
206         $(WARNINGS_CFLAGS)
208 test_just_filter_header_SOURCES = \
209         test-just-filter-header.c
210 test_just_filter_header_CPPFLAGS = \
211         -I$(top_srcdir)/include
212 test_just_filter_header_CFLAGS = \
213         $(WARNINGS_CFLAGS)
215 if CAN_TEST_ANSI_C
216 # This builds a plugin using an ANSI (ISO C90) compiler to ensure that
217 # the header file is compatible.  The plugin does nothing very
218 # interesting, it's mainly a compile test.
219 TESTS += \
220         test-ansi-c.sh
221 # check_LTLIBRARIES won't build a shared library (see automake manual).
222 # So we have to do this and add a dependency.
223 noinst_LTLIBRARIES += test-ansi-c-plugin.la
224 test-ansi-c.sh: test-ansi-c-plugin.la
226 test_ansi_c_plugin_la_SOURCES = \
227         test-ansi-c-plugin.c \
228         $(top_srcdir)/include/nbdkit-plugin.h
229 test_ansi_c_plugin_la_CPPFLAGS = \
230         -std=c90 -pedantic \
231         -I$(top_srcdir)/include
232 test_ansi_c_plugin_la_CFLAGS = \
233         $(WARNINGS_CFLAGS)
234 # For use of the -rpath option, see:
235 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
236 test_ansi_c_plugin_la_LDFLAGS = \
237         -module -avoid-version -shared -rpath /nowhere
238 endif CAN_TEST_ANSI_C
240 if HAVE_CXX
241 # This builds a plugin and a filter using the C++ compiler.  They
242 # don't do anything interesting when run.
243 TESTS += \
244         test-cxx.sh
245 # check_LTLIBRARIES won't build a shared library (see automake manual).
246 # So we have to do this and add a dependency.
247 noinst_LTLIBRARIES += test-cxx-plugin.la test-cxx-filter.la
248 test-cxx.sh: test-cxx-plugin.la test-cxx-filter.la
250 test_cxx_plugin_la_SOURCES = \
251         test-cxx-plugin.cpp \
252         $(top_srcdir)/include/nbdkit-plugin.h
253 test_cxx_plugin_la_CPPFLAGS = \
254         -I$(top_srcdir)/include
255 test_cxx_plugin_la_CXXFLAGS = \
256         $(WARNINGS_CFLAGS)
257 # For use of the -rpath option, see:
258 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
259 test_cxx_plugin_la_LDFLAGS = \
260         -module -avoid-version -shared -rpath /nowhere
262 test_cxx_filter_la_SOURCES = \
263         test-cxx-filter.cpp \
264         $(top_srcdir)/include/nbdkit-filter.h
265 test_cxx_filter_la_CPPFLAGS = \
266         -I$(top_srcdir)/include
267 test_cxx_filter_la_CXXFLAGS = \
268         $(WARNINGS_CFLAGS)
269 # For use of the -rpath option, see:
270 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
271 test_cxx_filter_la_LDFLAGS = \
272         -module -avoid-version -shared -rpath /nowhere
273 endif HAVE_CXX
275 # Exit with parent test.
276 check_PROGRAMS += test-exit-with-parent
277 TESTS += test-exit-with-parent
279 test_exit_with_parent_SOURCES = \
280         test-exit-with-parent.c test.h
281 test_exit_with_parent_CPPFLAGS = \
282         -I$(top_srcdir)/common/include
283 test_exit_with_parent_CFLAGS = \
284         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
286 # PKI files for the TLS tests.
287 check_DATA += pki/.stamp
288 pki/.stamp: $(srcdir)/make-pki.sh
289         SRCDIR=$(srcdir) $(srcdir)/make-pki.sh
291 # PSK keys for the TLS-PSK tests.
292 check_DATA += keys.psk
293 keys.psk: $(srcdir)/make-psk.sh
294         SRCDIR=$(srcdir) $(srcdir)/make-psk.sh
296 # Keys are expensive to recreate so only delete them when we do
297 # â€˜make distclean’.
298 DISTCLEANFILES = keys.psk
299 distclean-local: distclean-local-tls
300 distclean-local-tls:
301         rm -rf pki
303 #----------------------------------------------------------------------
304 # Tests of C plugins or tests which require plugins.
306 if HAVE_PLUGINS
308 # Common data shared by multiple tests
309 check_DATA += file-data
310 CLEANFILES += file-data
311 file-data: generate-file-data.sh
312         $(srcdir)/generate-file-data.sh $@
314 # While most tests need libguestfs, testing parallel I/O is easier when
315 # using qemu-io to kick off asynchronous requests.
316 TESTS += \
317         test-parallel-file.sh \
318         test-parallel-nbd.sh
320 # Most in-depth tests need libguestfs, since that is a convenient way to
321 # drive qemu.
322 LIBGUESTFS_TESTS =
323 EXTRA_PROGRAMS =
324 if HAVE_LIBGUESTFS
325 check_PROGRAMS += $(LIBGUESTFS_TESTS)
326 TESTS += $(LIBGUESTFS_TESTS)
328 # Use the 'direct' backend, and ensure maximum libguestfs debugging is
329 # written to the *.log files in case there is a problem.
330 TESTS_ENVIRONMENT += \
331         LIBGUESTFS_ATTACH_METHOD=appliance \
332         LIBGUESTFS_DEBUG=1 \
333         LIBGUESTFS_TRACE=1 \
334         LD_LIBRARY_PATH=../plugins/ocaml/.libs:$(LD_LIBRARY_PATH) \
335         LIBRARY_PATH=../plugins/ocaml/.libs:$(LIBRARY_PATH)
337 # Common test library.
338 check_LTLIBRARIES += libtest.la
339 libtest_la_SOURCES = test.c test.h
340 libtest_la_CFLAGS = $(WARNINGS_CFLAGS)
342 # Basic connection test.
343 LIBGUESTFS_TESTS += test-connect
345 test_connect_SOURCES = test-connect.c test.h
346 test_connect_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
347 test_connect_LDADD = libtest.la $(LIBGUESTFS_LIBS)
349 # newstyle protocol test.
350 LIBGUESTFS_TESTS += test-newstyle
352 test_newstyle_SOURCES = test-newstyle.c test.h
353 test_newstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
354 test_newstyle_LDADD = libtest.la $(LIBGUESTFS_LIBS)
356 # oldstyle protocol test.
357 LIBGUESTFS_TESTS += test-oldstyle
359 test_oldstyle_SOURCES = test-oldstyle.c test.h
360 test_oldstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
361 test_oldstyle_LDADD = libtest.la $(LIBGUESTFS_LIBS)
363 endif HAVE_LIBGUESTFS
365 # Test export flags.
366 TESTS += test-eflags.sh
368 # common disk image shared with several tests
369 if HAVE_GUESTFISH
370 check_DATA += disk
371 CLEANFILES += disk
373 disk:
374         rm -f $@ $@-t
375         guestfish -N $@-t=fs:ext4:100M -m /dev/sda1 \
376             write /hello.txt "hello,world"
377         mv $@-t $@
379 endif HAVE_GUESTFISH
381 # curl plugin test.
383 if HAVE_CURL
384 if HAVE_GUESTFISH
386 # curl plugin test.
387 LIBGUESTFS_TESTS += test-curl
389 test_curl_SOURCES = \
390         test-curl.c \
391         web-server.c \
392         web-server.h \
393         test.h
394 test_curl_CFLAGS = \
395         $(WARNINGS_CFLAGS) \
396         $(LIBGUESTFS_CFLAGS) \
397         $(PTHREAD_CFLAGS)
398 test_curl_LDFLAGS = \
399         $(PTHREAD_LIBS)
400 test_curl_LDADD = \
401         libtest.la \
402         $(LIBGUESTFS_LIBS)
404 endif HAVE_GUESTFISH
405 endif HAVE_CURL
407 # data plugin test.
408 LIBGUESTFS_TESTS += test-data
409 TESTS += \
410         test-data-7E.sh \
411         test-data-base64.sh \
412         test-data-extents.sh \
413         test-data-file.sh \
414         test-data-raw.sh
416 test_data_SOURCES = test-data.c test.h
417 test_data_CPPFLAGS = -I$(top_srcdir)/common/include
418 test_data_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
419 test_data_LDADD = libtest.la $(LIBGUESTFS_LIBS)
421 # ext2 plugin test.
422 if HAVE_EXT2
423 if HAVE_GUESTFISH
425 LIBGUESTFS_TESTS += test-ext2
426 check_DATA += ext2.img
427 CLEANFILES += ext2.img
429 ext2.img: disk
430         rm -f $@ $@-t
431         guestfish \
432             sparse $@-t 2G : \
433             run : \
434             mkfs ext4 /dev/sda : \
435             mount /dev/sda / : \
436             mkdir /disks : \
437             upload $< /disks/disk.img
438         mv $@-t $@
440 test_ext2_SOURCES = test-ext2.c test.h
441 test_ext2_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
442 test_ext2_LDADD = libtest.la $(LIBGUESTFS_LIBS)
444 endif HAVE_GUESTFISH
445 endif HAVE_EXT2
447 # file plugin test.
448 LIBGUESTFS_TESTS += test-file test-file-block
450 test_file_SOURCES = test-file.c test.h
451 test_file_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
452 test_file_LDADD = libtest.la $(LIBGUESTFS_LIBS)
454 test_file_block_SOURCES = test-file-block.c test.h
455 test_file_block_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
456 test_file_block_LDADD = libtest.la $(LIBGUESTFS_LIBS)
458 if HAVE_GUESTFISH
459 TESTS += test-file-extents.sh
460 endif HAVE_GUESTFISH
462 # floppy plugin test.
463 if HAVE_GUESTFISH
464 TESTS += test-floppy.sh
465 endif HAVE_GUESTFISH
467 # full plugin test.
468 TESTS += test-full.sh
470 # gzip plugin test.
471 if HAVE_ZLIB
472 if HAVE_GUESTFISH
474 LIBGUESTFS_TESTS += test-gzip
475 check_DATA += disk.gz
476 CLEANFILES += disk.gz
478 test_gzip_SOURCES = test-gzip.c test.h
479 test_gzip_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
480 test_gzip_LDADD = libtest.la $(LIBGUESTFS_LIBS)
482 disk.gz: disk
483         rm -f $@
484         gzip -9 -c disk > $@
486 endif HAVE_GUESTFISH
487 endif HAVE_ZLIB
489 # iso plugin test.
490 if HAVE_ISO
491 if HAVE_GUESTFISH
493 TESTS += test-iso.sh
495 endif HAVE_GUESTFISH
496 endif HAVE_ISO
498 # linuxdisk plugin test.
499 if HAVE_GUESTFISH
500 TESTS += \
501         test-linuxdisk.sh \
502         test-linuxdisk-copy-out.sh
503 endif HAVE_GUESTFISH
505 # memory plugin test.
506 LIBGUESTFS_TESTS += test-memory
507 TESTS += test-memory-largest.sh test-memory-largest-for-qemu.sh
509 test_memory_SOURCES = test-memory.c test.h
510 test_memory_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
511 test_memory_LDADD = libtest.la $(LIBGUESTFS_LIBS)
513 # partitioning plugin test.
514 TESTS += \
515         test-partitioning1.sh \
516         test-partitioning4.sh \
517         test-partitioning6.sh
518 if HAVE_GUESTFISH
519 TESTS += \
520         test-partitioning2.sh \
521         test-partitioning3.sh \
522         test-partitioning5.sh
523 endif HAVE_GUESTFISH
525 # pattern plugin test.
526 TESTS += \
527         test-pattern.sh \
528         test-pattern-largest.sh \
529         test-pattern-largest-for-qemu.sh
531 # nbd plugin test.
532 LIBGUESTFS_TESTS += test-nbd
534 test_nbd_SOURCES = test-nbd.c test.h
535 test_nbd_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
536 test_nbd_LDADD = libtest.la $(LIBGUESTFS_LIBS)
538 # null plugin test.
539 LIBGUESTFS_TESTS += test-null
540 TESTS += test-null-extents.sh
542 test_null_SOURCES = test-null.c test.h
543 test_null_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
544 test_null_LDADD = libtest.la $(LIBGUESTFS_LIBS)
546 # random plugin test.
547 LIBGUESTFS_TESTS += test-random
549 test_random_SOURCES = test-random.c test.h
550 test_random_CPPFLAGS = -I $(top_srcdir)/common/include
551 test_random_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
552 test_random_LDADD = libtest.la $(LIBGUESTFS_LIBS)
554 # split files plugin test.
555 check_DATA += split1 split2 split3
556 CLEANFILES += split1 split2 split3
557 split1: file-data
558         rm -f $@ $@-t
559         dd if=$< of=$@-t bs=1 count=100
560         mv $@-t $@
561 split2: file-data
562         rm -f $@ $@-t
563         dd if=$< of=$@-t bs=1 count=100 skip=100
564         mv $@-t $@
565 split3: file-data
566         rm -f $@ $@-t
567         dd if=$< of=$@-t bs=1 skip=200
568         mv $@-t $@
569 LIBGUESTFS_TESTS += test-split
571 test_split_SOURCES = test-split.c test.h
572 test_split_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
573 test_split_LDADD = libtest.la $(LIBGUESTFS_LIBS)
575 # ssh plugin test.
576 if HAVE_SSH
577 # Uses â€˜disk’ so we have to make it conditional on guestfish.
578 if HAVE_GUESTFISH
579 TESTS += test-ssh.sh
580 endif HAVE_GUESTFISH
581 check_DATA += \
582         ssh/sshd_config \
583         ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub \
584         ssh/authorized_keys
585 SSH_RANDOM_PORT := $(shell bash -c 'echo $$(( 10000 + $$RANDOM ))')
586 CLEANFILES += \
587         ssh/*~ \
588         ssh/sshd_config \
589         ssh/authorized_keys
590 DISTCLEANFILES += \
591         ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub \
592         ssh/id_rsa ssh/id_rsa.pub \
593         stamp-ssh-host-key stamp-ssh-user-key
595 ssh/sshd_config: ssh/sshd_config.in Makefile
596         rm -f $@ $@-t
597         $(SED) \
598             -e 's,__abs_builddir__,$(abs_builddir),g' \
599             -e 's,__RANDOM_PORT__,$(SSH_RANDOM_PORT),g' \
600             < $< > $@-t
601         mv $@-t $@
603 ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub: stamp-ssh-host-key
604 stamp-ssh-host-key:
605         rm -f $@
606         rm -f ssh/ssh_host_rsa_key
607         rm -f ssh/ssh_host_rsa_key.pub
608         ssh-keygen -t rsa -f ssh/ssh_host_rsa_key -N ''
609         touch $@
611 ssh/authorized_keys: ssh/id_rsa.pub
612         rm -f $@ $@-t
613         cp $< $@-t
614         mv $@-t $@
616 ssh/id_rsa ssh/id_rsa.pub: stamp-ssh-user-key
617 stamp-ssh-user-key:
618         rm -f $@
619         rm -f ssh/id_rsa
620         rm -f ssh/id_rsa.pub
621         ssh-keygen -t rsa -f ssh/id_rsa -N ''
622         touch $@
623 endif HAVE_SSH
625 # streaming plugin test.
626 # Doesn't work:
627 #LIBGUESTFS_TESTS += test-streaming
628 EXTRA_PROGRAMS += test-streaming
630 test_streaming_SOURCES = test-streaming.c test.h
631 test_streaming_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
632 test_streaming_LDADD = libtest.la $(LIBGUESTFS_LIBS)
634 # VDDK plugin test.
635 # This only tests that the plugin can be loaded against a
636 # dummy VDDK library, it is not a detailed test.
638 # check_LTLIBRARIES won't build a shared library (see automake manual).
639 # So we have to do this and add a dependency.
640 noinst_LTLIBRARIES += libvixDiskLib.la
641 TESTS += \
642         test-vddk.sh \
643         test-vddk-real.sh
645 libvixDiskLib_la_SOURCES = \
646         dummy-vddk.c
647 libvixDiskLib_la_CPPFLAGS = \
648         -I$(top_srcdir)/plugins/vddk
649 libvixDiskLib_la_CXXFLAGS = \
650         $(WARNINGS_CFLAGS)
651 # For use of the -rpath option, see:
652 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
653 libvixDiskLib_la_LDFLAGS = \
654         -shared -version-number 6:0:0 -rpath /nowhere
656 # zero plugin test.
657 TESTS += test-zero.sh
659 #----------------------------------------------------------------------
660 # Tests of language plugins.
662 # OCaml plugin test.
663 if HAVE_OCAML
665 LIBGUESTFS_TESTS += test-ocaml
667 # This is somewhat different from the other tests because we have
668 # to build an actual plugin here.
669 test_ocaml_SOURCES = test-ocaml.c test.h
670 test_ocaml_CFLAGS = \
671         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
672 test_ocaml_LDADD = libtest.la $(LIBGUESTFS_LIBS)
674 check_SCRIPTS += test-ocaml-plugin.so
675 test-ocaml-plugin.so: test_ocaml_plugin.cmx ../plugins/ocaml/libnbdkitocaml.la ../plugins/ocaml/NBDKit.cmi ../plugins/ocaml/NBDKit.cmx
676         $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../plugins/ocaml \
677           -output-obj -runtime-variant _pic -o $@ \
678           NBDKit.cmx $< \
679           -cclib -L../plugins/ocaml/.libs -cclib -lnbdkitocaml
680 test_ocaml_plugin.cmx: test_ocaml_plugin.ml ../plugins/ocaml/NBDKit.cmi
681         $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../plugins/ocaml -c $< -o $@
683 endif HAVE_OCAML
685 # perl plugin test.
686 if HAVE_PERL
688 TESTS += \
689         test-dump-plugin-example4.sh \
690         test-shebang-perl.sh
691 LIBGUESTFS_TESTS += test-perl
693 test_perl_SOURCES = test-lang-plugins.c test.h
694 test_perl_CFLAGS = \
695         -DLANG='"perl"' -DSCRIPT='"$(srcdir)/test.pl"' \
696         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
697 test_perl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
699 endif HAVE_PERL
701 # python plugin test.
702 if HAVE_PYTHON
704 TESTS += \
705         test-python-exception.sh \
706         test-shebang-python.sh
707 LIBGUESTFS_TESTS += test-python
709 test_python_SOURCES = test-lang-plugins.c test.h
710 test_python_CFLAGS = \
711         -DLANG='"python"' -DSCRIPT='"$(srcdir)/test.py"' \
712         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
713 test_python_LDADD = libtest.la $(LIBGUESTFS_LIBS)
715 endif HAVE_PYTHON
717 # Ruby plugin test.
718 if HAVE_RUBY
720 # Ruby tests are disabled.  See "WARNING" section in
721 # plugins/ruby/nbdkit-ruby-plugin.pod
723 #LIBGUESTFS_TESTS += \
724 #       test-ruby
725 #TESTS += test-shebang-ruby.sh
726 EXTRA_PROGRAMS += test-ruby
728 test_ruby_SOURCES = test-lang-plugins.c test.h
729 test_ruby_CFLAGS = \
730         -DLANG='"ruby"' -DSCRIPT='"$(srcdir)/test.rb"' \
731         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
732 test_ruby_LDADD = libtest.la $(LIBGUESTFS_LIBS)
734 endif HAVE_RUBY
736 # Shell (sh) plugin test.
737 LIBGUESTFS_TESTS += test-shell
738 check_DATA += test-shell.img
739 CLEANFILES += test-shell.img
741 test_shell_SOURCES = test-lang-plugins.c test.h
742 test_shell_CFLAGS = \
743         -DLANG='"sh"' -DSCRIPT='"$(srcdir)/test-shell.sh"' \
744         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
745 test_shell_LDADD = libtest.la $(LIBGUESTFS_LIBS)
747 test-shell.img:
748         truncate -s 1048576 $@
750 TESTS += test-sh-extents.sh
752 # Tcl plugin test.
753 if HAVE_TCL
755 LIBGUESTFS_TESTS += test-tcl
757 test_tcl_SOURCES = test-lang-plugins.c test.h
758 test_tcl_CFLAGS = \
759         -DLANG='"tcl"' -DSCRIPT='"$(srcdir)/test.tcl"' \
760         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
761 test_tcl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
763 endif HAVE_TCL
765 # Lua plugin test.
766 if HAVE_LUA
768 LIBGUESTFS_TESTS += test-lua
770 test_lua_SOURCES = test-lang-plugins.c test.h
771 test_lua_CFLAGS = \
772         -DLANG='"lua"' -DSCRIPT='"$(srcdir)/test.lua"' \
773         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
774 test_lua_LDADD = libtest.la $(LIBGUESTFS_LIBS)
776 endif HAVE_LUA
778 #----------------------------------------------------------------------
779 # Tests of filters.
781 # Generic test of filter layers.
782 check_PROGRAMS += test-layers
783 TESTS += test-layers.sh test-layers
785 test_layers_SOURCES = \
786         test-layers.c
787 test_layers_CPPFLAGS = \
788         -I$(top_srcdir)/common/include \
789         -I$(top_srcdir)/common/protocol \
790         -I$(top_srcdir)/server
791 test_layers_CFLAGS = \
792         $(WARNINGS_CFLAGS) \
793         $(PTHREAD_CFLAGS)
794 test_layers_LDFLAGS = \
795         $(PTHREAD_LIBS)
796 test_layers_DEPENDENCIES = \
797         test-layers-plugin.la \
798         test-layers-filter1.la \
799         test-layers-filter2.la \
800         test-layers-filter3.la
802 # check_LTLIBRARIES won't build a shared library (see automake manual).
803 # So we have to do this and add a dependency.
804 noinst_LTLIBRARIES += \
805         test-layers-plugin.la \
806         test-layers-filter1.la \
807         test-layers-filter2.la \
808         test-layers-filter3.la
810 test_layers_plugin_la_SOURCES = \
811         test-layers-plugin.c \
812         $(top_srcdir)/include/nbdkit-plugin.h
813 test_layers_plugin_la_CPPFLAGS = -I$(top_srcdir)/include
814 test_layers_plugin_la_CFLAGS = $(WARNINGS_CFLAGS)
815 # For use of the -rpath option, see:
816 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
817 test_layers_plugin_la_LDFLAGS = \
818         -module -avoid-version -shared -rpath /nowhere
820 test_layers_filter1_la_SOURCES = \
821         test-layers-filter.c \
822         $(top_srcdir)/include/nbdkit-filter.h
823 test_layers_filter1_la_CPPFLAGS = -I$(top_srcdir)/include
824 test_layers_filter1_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter1"'
825 # For use of the -rpath option, see:
826 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
827 test_layers_filter1_la_LDFLAGS = \
828         -module -avoid-version -shared -rpath /nowhere
830 test_layers_filter2_la_SOURCES = \
831         test-layers-filter.c \
832         $(top_srcdir)/include/nbdkit-filter.h
833 test_layers_filter2_la_CPPFLAGS = -I$(top_srcdir)/include
834 test_layers_filter2_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter2"'
835 # For use of the -rpath option, see:
836 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
837 test_layers_filter2_la_LDFLAGS = \
838         -module -avoid-version -shared -rpath /nowhere
840 test_layers_filter3_la_SOURCES = \
841         test-layers-filter.c \
842         $(top_srcdir)/include/nbdkit-filter.h
843 test_layers_filter3_la_CPPFLAGS = -I$(top_srcdir)/include
844 test_layers_filter3_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter3"'
845 # For use of the -rpath option, see:
846 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
847 test_layers_filter3_la_LDFLAGS = \
848         -module -avoid-version -shared -rpath /nowhere
850 # blocksize filter test.
851 TESTS += test-blocksize.sh
853 # cache filter test.
854 if HAVE_GUESTFISH
855 TESTS += \
856         test-cache.sh \
857         test-cache-on-read.sh
858 endif HAVE_GUESTFISH
859 TESTS += test-cache-max-size.sh
861 # cow filter test.
862 if HAVE_GUESTFISH
863 TESTS += test-cow.sh
864 endif HAVE_GUESTFISH
866 # delay filter test.
867 LIBGUESTFS_TESTS += test-delay
869 test_delay_SOURCES = test-delay.c test.h
870 test_delay_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
871 test_delay_LDADD = libtest.la $(LIBGUESTFS_LIBS)
873 # error filter test.
874 LIBGUESTFS_TESTS += test-error
876 test_error_SOURCES = test-error.c test.h
877 test_error_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
878 test_error_LDADD = libtest.la $(LIBGUESTFS_LIBS)
880 TESTS += \
881         test-error0.sh \
882         test-error10.sh \
883         test-error100.sh
885 # fua filter test.
886 TESTS += test-fua.sh
888 # log filter test.
889 TESTS += test-log.sh
891 # nozero filter test.
892 TESTS += test-nozero.sh
894 # offset filter test.
895 check_DATA += offset-data
896 CLEANFILES += offset-data
897 LIBGUESTFS_TESTS += test-offset
899 offset-data: generate-offset-data.sh
900         $(srcdir)/generate-offset-data.sh $@
902 test_offset_SOURCES = test-offset.c test.h
903 test_offset_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
904 test_offset_LDADD = libtest.la $(LIBGUESTFS_LIBS)
906 TESTS += \
907         test-offset2.sh \
908         test-offset-extents.sh
910 # partition filter test.
911 TESTS += test-partition1.sh
912 if HAVE_GUESTFISH
913 TESTS += test-partition2.sh
914 endif HAVE_GUESTFISH
916 # rate filter test.
917 TESTS += \
918         test-rate.sh \
919         test-rate-dynamic.sh
921 # readahead filter test.
922 LIBGUESTFS_TESTS += test-readahead
923 TESTS += test-readahead-copy.sh
925 test_readahead_SOURCES = test-readahead.c test.h
926 test_readahead_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
927 test_readahead_LDADD = libtest.la $(LIBGUESTFS_LIBS)
929 # truncate filter tests.
930 TESTS += \
931         test-truncate1.sh \
932         test-truncate2.sh \
933         test-truncate3.sh \
934         test-truncate-extents.sh
936 # xz filter test.
937 if HAVE_LIBLZMA
938 if HAVE_GUESTFISH
940 LIBGUESTFS_TESTS += test-xz
941 check_DATA += disk.xz
942 CLEANFILES += disk.xz
944 test_xz_SOURCES = test-xz.c test.h
945 test_xz_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
946 test_xz_LDADD = libtest.la $(LIBGUESTFS_LIBS)
948 disk.xz: disk
949         rm -f $@
950 # We choose a very small block size here only for testing.  Normally
951 # you should choose a 16M block size.
952         xz --best --block-size=32768 -c disk > $@
954 if HAVE_CURL
956 # xz filter + curl.
957 LIBGUESTFS_TESTS += test-xz-curl
959 test_xz_curl_SOURCES = \
960         test-xz-curl.c \
961         web-server.c \
962         web-server.h \
963         test.h
964 test_xz_curl_CFLAGS = \
965         $(WARNINGS_CFLAGS) \
966         $(LIBGUESTFS_CFLAGS) \
967         $(PTHREAD_CFLAGS)
968 test_xz_curl_LDFLAGS = \
969         $(PTHREAD_LIBS)
970 test_xz_curl_LDADD = \
971         libtest.la \
972         $(LIBGUESTFS_LIBS)
974 endif HAVE_CURL
976 endif HAVE_GUESTFISH
977 endif HAVE_LIBLZMA
979 endif HAVE_PLUGINS