nbd: Add TLS client support
[nbdkit/ericb.git] / tests / Makefile.am
blob26ca2a12d9604825b346b73a49bd3e6b0498f914
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-cacheextents.sh \
51         test-captive.sh \
52         test-cow.sh \
53         test-cxx.sh \
54         test-data-7E.sh \
55         test-data-base64.sh \
56         test-data-extents.sh \
57         test-data-file.sh \
58         test-data-raw.sh \
59         test-debug-flags.sh \
60         test-dump-config.sh \
61         test-dump-plugin.sh \
62         test-dump-plugin-example4.sh \
63         test-eflags.sh \
64         test-error0.sh \
65         test-error10.sh \
66         test-error100.sh \
67         test-file-extents.sh \
68         test-floppy.sh \
69         test-foreground.sh \
70         test-fua.sh \
71         test-full.sh \
72         test-help.sh \
73         test-help-plugin.sh \
74         test-ip.sh \
75         test-iso.sh \
76         test-layers.sh \
77         test-linuxdisk.sh \
78         test-linuxdisk-copy-out.sh \
79         test-log.sh \
80         test.lua \
81         test-memory-largest.sh \
82         test-memory-largest-for-qemu.sh \
83         test-nbd-extents.sh \
84         test-nbd-tls.sh \
85         test-nbd-tls-psk.sh \
86         test-nozero.sh \
87         test-null-extents.sh \
88         test_ocaml_plugin.ml \
89         test-ocaml.c \
90         test-offset2.sh \
91         test-offset-extents.sh \
92         test-parallel-file.sh \
93         test-parallel-nbd.sh \
94         test-partition1.sh \
95         test-partition2.sh \
96         test-partitioning1.sh \
97         test-partitioning2.sh \
98         test-partitioning3.sh \
99         test-partitioning4.sh \
100         test-partitioning5.sh \
101         test-partitioning6.sh \
102         test-pattern.sh \
103         test-pattern-largest.sh \
104         test-pattern-largest-for-qemu.sh \
105         test-python-exception.sh \
106         test.pl \
107         test.py \
108         test-rate.sh \
109         test-rate-dynamic.sh \
110         test.rb \
111         test-readahead-copy.sh \
112         test-ssh.sh \
113         test.tcl \
114         test-shebang-perl.sh \
115         test-shebang-python.sh \
116         test-shebang-ruby.sh \
117         test-shell.sh \
118         test-sh-extents.sh \
119         test-single.sh \
120         test-single-from-file.sh \
121         test-start.sh \
122         test-random-sock.sh \
123         test-tls.sh \
124         test-tls-psk.sh \
125         test-truncate1.sh \
126         test-truncate2.sh \
127         test-truncate3.sh \
128         test-truncate4.sh \
129         test-truncate-extents.sh \
130         test-vddk.sh \
131         test-vddk-real.sh \
132         test-version.sh \
133         test-version-filter.sh \
134         test-version-plugin.sh \
135         test-zero.sh
137 # Use 'make check' to run the ordinary tests.  To run all the tests
138 # under valgrind, use the following rule:
139 check-valgrind:
140         NBDKIT_VALGRIND=1 $(MAKE) check
142 # To run only tests which require root, use:
143 check-root:
144         $(MAKE) check TESTS="test-file-block"
146 # Run a basic check against a real copy of VDDK.  You must set
147 # vddkdir to point to the library location, eg:
149 #   make check-vddk vddkdir=vmware-vix-disklib-distrib
150 check-vddk:
151         $(MAKE) check TESTS=test-vddk-real.sh
153 #----------------------------------------------------------------------
154 # Basic server command line and start-up tests.
156 check_PROGRAMS =
157 check_DATA =
158 check_SCRIPTS =
159 check_LTLIBRARIES =
160 noinst_LTLIBRARIES =
162 # Ensure we're testing the local copy by running everything through
163 # the nbdkit helper script in the top build directory.
164 TESTS_ENVIRONMENT = PATH=$(abs_top_builddir):$(PATH) SRCDIR=$(srcdir)
166 TESTS = \
167         test-help.sh \
168         test-version.sh \
169         test-dump-config.sh
171 if HAVE_PLUGINS
173 TESTS += \
174         test-help-plugin.sh \
175         test-version-plugin.sh \
176         test-version-filter.sh \
177         test-dump-plugin.sh \
178         test-start.sh \
179         test-single.sh \
180         test-single-from-file.sh \
181         test-captive.sh \
182         test-random-sock.sh \
183         test-tls.sh \
184         test-tls-psk.sh \
185         test-ip.sh \
186         test-socket-activation \
187         test-foreground.sh \
188         test-debug-flags.sh
190 check_PROGRAMS += \
191         test-socket-activation
193 test_socket_activation_SOURCES = test-socket-activation.c
194 test_socket_activation_CFLAGS = $(WARNINGS_CFLAGS)
196 endif HAVE_PLUGINS
198 # Test the header files can be included on their own.
199 check_PROGRAMS += \
200         test-just-plugin-header \
201         test-just-filter-header
202 TESTS += \
203         test-just-plugin-header \
204         test-just-filter-header
206 test_just_plugin_header_SOURCES = \
207         test-just-plugin-header.c
208 test_just_plugin_header_CPPFLAGS = \
209         -I$(top_srcdir)/include
210 test_just_plugin_header_CFLAGS = \
211         $(WARNINGS_CFLAGS)
213 test_just_filter_header_SOURCES = \
214         test-just-filter-header.c
215 test_just_filter_header_CPPFLAGS = \
216         -I$(top_srcdir)/include
217 test_just_filter_header_CFLAGS = \
218         $(WARNINGS_CFLAGS)
220 if CAN_TEST_ANSI_C
221 # This builds a plugin using an ANSI (ISO C90) compiler to ensure that
222 # the header file is compatible.  The plugin does nothing very
223 # interesting, it's mainly a compile test.
224 TESTS += \
225         test-ansi-c.sh
226 # check_LTLIBRARIES won't build a shared library (see automake manual).
227 # So we have to do this and add a dependency.
228 noinst_LTLIBRARIES += test-ansi-c-plugin.la
229 test-ansi-c.sh: test-ansi-c-plugin.la
231 test_ansi_c_plugin_la_SOURCES = \
232         test-ansi-c-plugin.c \
233         $(top_srcdir)/include/nbdkit-plugin.h
234 test_ansi_c_plugin_la_CPPFLAGS = \
235         -std=c90 -pedantic \
236         -I$(top_srcdir)/include
237 test_ansi_c_plugin_la_CFLAGS = \
238         $(WARNINGS_CFLAGS)
239 # For use of the -rpath option, see:
240 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
241 test_ansi_c_plugin_la_LDFLAGS = \
242         -module -avoid-version -shared -rpath /nowhere
243 endif CAN_TEST_ANSI_C
245 if HAVE_CXX
246 # This builds a plugin and a filter using the C++ compiler.  They
247 # don't do anything interesting when run.
248 TESTS += \
249         test-cxx.sh
250 # check_LTLIBRARIES won't build a shared library (see automake manual).
251 # So we have to do this and add a dependency.
252 noinst_LTLIBRARIES += test-cxx-plugin.la test-cxx-filter.la
253 test-cxx.sh: test-cxx-plugin.la test-cxx-filter.la
255 test_cxx_plugin_la_SOURCES = \
256         test-cxx-plugin.cpp \
257         $(top_srcdir)/include/nbdkit-plugin.h
258 test_cxx_plugin_la_CPPFLAGS = \
259         -I$(top_srcdir)/include
260 test_cxx_plugin_la_CXXFLAGS = \
261         $(WARNINGS_CFLAGS)
262 # For use of the -rpath option, see:
263 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
264 test_cxx_plugin_la_LDFLAGS = \
265         -module -avoid-version -shared -rpath /nowhere
267 test_cxx_filter_la_SOURCES = \
268         test-cxx-filter.cpp \
269         $(top_srcdir)/include/nbdkit-filter.h
270 test_cxx_filter_la_CPPFLAGS = \
271         -I$(top_srcdir)/include
272 test_cxx_filter_la_CXXFLAGS = \
273         $(WARNINGS_CFLAGS)
274 # For use of the -rpath option, see:
275 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
276 test_cxx_filter_la_LDFLAGS = \
277         -module -avoid-version -shared -rpath /nowhere
278 endif HAVE_CXX
280 # Exit with parent test.
281 check_PROGRAMS += test-exit-with-parent
282 TESTS += test-exit-with-parent
284 test_exit_with_parent_SOURCES = \
285         test-exit-with-parent.c test.h
286 test_exit_with_parent_CPPFLAGS = \
287         -I$(top_srcdir)/common/include
288 test_exit_with_parent_CFLAGS = \
289         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
291 # PKI files for the TLS tests.
292 check_DATA += pki/.stamp
293 pki/.stamp: $(srcdir)/make-pki.sh
294         SRCDIR=$(srcdir) $(srcdir)/make-pki.sh
296 # PSK keys for the TLS-PSK tests.
297 check_DATA += keys.psk
298 keys.psk: $(srcdir)/make-psk.sh
299         SRCDIR=$(srcdir) $(srcdir)/make-psk.sh
301 # Keys are expensive to recreate so only delete them when we do
302 # â€˜make distclean’.
303 DISTCLEANFILES = keys.psk
304 distclean-local: distclean-local-tls
305 distclean-local-tls:
306         rm -rf pki
308 #----------------------------------------------------------------------
309 # Tests of C plugins or tests which require plugins.
311 if HAVE_PLUGINS
313 # Common data shared by multiple tests
314 check_DATA += file-data
315 CLEANFILES += file-data
316 file-data: generate-file-data.sh
317         $(srcdir)/generate-file-data.sh $@
319 # While most tests need libguestfs, testing parallel I/O is easier when
320 # using qemu-io to kick off asynchronous requests.
321 TESTS += \
322         test-parallel-file.sh \
323         test-parallel-nbd.sh
325 # Most in-depth tests need libguestfs, since that is a convenient way to
326 # drive qemu.
327 LIBGUESTFS_TESTS =
328 EXTRA_PROGRAMS =
329 if HAVE_LIBGUESTFS
330 check_PROGRAMS += $(LIBGUESTFS_TESTS)
331 TESTS += $(LIBGUESTFS_TESTS)
333 # Use the 'direct' backend, and ensure maximum libguestfs debugging is
334 # written to the *.log files in case there is a problem.
335 TESTS_ENVIRONMENT += \
336         LIBGUESTFS_ATTACH_METHOD=appliance \
337         LIBGUESTFS_DEBUG=1 \
338         LIBGUESTFS_TRACE=1 \
339         LD_LIBRARY_PATH=../plugins/ocaml/.libs:$(LD_LIBRARY_PATH) \
340         LIBRARY_PATH=../plugins/ocaml/.libs:$(LIBRARY_PATH)
342 # Common test library.
343 check_LTLIBRARIES += libtest.la
344 libtest_la_SOURCES = test.c test.h
345 libtest_la_CFLAGS = $(WARNINGS_CFLAGS)
347 # Basic connection test.
348 LIBGUESTFS_TESTS += test-connect
350 test_connect_SOURCES = test-connect.c test.h
351 test_connect_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
352 test_connect_LDADD = libtest.la $(LIBGUESTFS_LIBS)
354 # newstyle protocol test.
355 LIBGUESTFS_TESTS += test-newstyle
357 test_newstyle_SOURCES = test-newstyle.c test.h
358 test_newstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
359 test_newstyle_LDADD = libtest.la $(LIBGUESTFS_LIBS)
361 # oldstyle protocol test.
362 LIBGUESTFS_TESTS += test-oldstyle
364 test_oldstyle_SOURCES = test-oldstyle.c test.h
365 test_oldstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
366 test_oldstyle_LDADD = libtest.la $(LIBGUESTFS_LIBS)
368 endif HAVE_LIBGUESTFS
370 # Test export flags.
371 TESTS += test-eflags.sh
373 # common disk image shared with several tests
374 if HAVE_GUESTFISH
375 check_DATA += disk
376 CLEANFILES += disk
378 disk:
379         rm -f $@ $@-t
380         guestfish -N $@-t=fs:ext4:100M -m /dev/sda1 \
381             write /hello.txt "hello,world"
382         mv $@-t $@
384 endif HAVE_GUESTFISH
386 # curl plugin test.
388 if HAVE_CURL
389 if HAVE_GUESTFISH
391 # curl plugin test.
392 LIBGUESTFS_TESTS += test-curl
394 test_curl_SOURCES = \
395         test-curl.c \
396         web-server.c \
397         web-server.h \
398         test.h
399 test_curl_CFLAGS = \
400         $(WARNINGS_CFLAGS) \
401         $(LIBGUESTFS_CFLAGS) \
402         $(PTHREAD_CFLAGS)
403 test_curl_LDFLAGS = \
404         $(PTHREAD_LIBS)
405 test_curl_LDADD = \
406         libtest.la \
407         $(LIBGUESTFS_LIBS)
409 endif HAVE_GUESTFISH
410 endif HAVE_CURL
412 # data plugin test.
413 LIBGUESTFS_TESTS += test-data
414 TESTS += \
415         test-data-7E.sh \
416         test-data-base64.sh \
417         test-data-extents.sh \
418         test-data-file.sh \
419         test-data-raw.sh
421 test_data_SOURCES = test-data.c test.h
422 test_data_CPPFLAGS = -I$(top_srcdir)/common/include
423 test_data_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
424 test_data_LDADD = libtest.la $(LIBGUESTFS_LIBS)
426 # ext2 plugin test.
427 if HAVE_EXT2
428 if HAVE_GUESTFISH
430 LIBGUESTFS_TESTS += test-ext2
431 check_DATA += ext2.img
432 CLEANFILES += ext2.img
434 ext2.img: disk
435         rm -f $@ $@-t
436         guestfish \
437             sparse $@-t 2G : \
438             run : \
439             mkfs ext4 /dev/sda : \
440             mount /dev/sda / : \
441             mkdir /disks : \
442             upload $< /disks/disk.img
443         mv $@-t $@
445 test_ext2_SOURCES = test-ext2.c test.h
446 test_ext2_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
447 test_ext2_LDADD = libtest.la $(LIBGUESTFS_LIBS)
449 endif HAVE_GUESTFISH
450 endif HAVE_EXT2
452 # file plugin test.
453 LIBGUESTFS_TESTS += test-file test-file-block
455 test_file_SOURCES = test-file.c test.h
456 test_file_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
457 test_file_LDADD = libtest.la $(LIBGUESTFS_LIBS)
459 test_file_block_SOURCES = test-file-block.c test.h
460 test_file_block_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
461 test_file_block_LDADD = libtest.la $(LIBGUESTFS_LIBS)
463 if HAVE_GUESTFISH
464 TESTS += test-file-extents.sh
465 endif HAVE_GUESTFISH
467 # floppy plugin test.
468 if HAVE_GUESTFISH
469 TESTS += test-floppy.sh
470 endif HAVE_GUESTFISH
472 # full plugin test.
473 TESTS += test-full.sh
475 # gzip plugin test.
476 if HAVE_ZLIB
477 if HAVE_GUESTFISH
479 LIBGUESTFS_TESTS += test-gzip
480 check_DATA += disk.gz
481 CLEANFILES += disk.gz
483 test_gzip_SOURCES = test-gzip.c test.h
484 test_gzip_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
485 test_gzip_LDADD = libtest.la $(LIBGUESTFS_LIBS)
487 disk.gz: disk
488         rm -f $@
489         gzip -9 -c disk > $@
491 endif HAVE_GUESTFISH
492 endif HAVE_ZLIB
494 # iso plugin test.
495 if HAVE_ISO
496 if HAVE_GUESTFISH
498 TESTS += test-iso.sh
500 endif HAVE_GUESTFISH
501 endif HAVE_ISO
503 # linuxdisk plugin test.
504 if HAVE_GUESTFISH
505 TESTS += \
506         test-linuxdisk.sh \
507         test-linuxdisk-copy-out.sh
508 endif HAVE_GUESTFISH
510 # memory plugin test.
511 LIBGUESTFS_TESTS += test-memory
512 TESTS += test-memory-largest.sh test-memory-largest-for-qemu.sh
514 test_memory_SOURCES = test-memory.c test.h
515 test_memory_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
516 test_memory_LDADD = libtest.la $(LIBGUESTFS_LIBS)
518 # partitioning plugin test.
519 TESTS += \
520         test-partitioning1.sh \
521         test-partitioning4.sh \
522         test-partitioning6.sh
523 if HAVE_GUESTFISH
524 TESTS += \
525         test-partitioning2.sh \
526         test-partitioning3.sh \
527         test-partitioning5.sh
528 endif HAVE_GUESTFISH
530 # pattern plugin test.
531 TESTS += \
532         test-pattern.sh \
533         test-pattern-largest.sh \
534         test-pattern-largest-for-qemu.sh
536 # nbd plugin test.
537 LIBGUESTFS_TESTS += test-nbd
538 TESTS += \
539         test-nbd-extents.sh \
540         test-nbd-tls.sh \
541         test-nbd-tls-psk.sh
543 test_nbd_SOURCES = test-nbd.c test.h
544 test_nbd_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
545 test_nbd_LDADD = libtest.la $(LIBGUESTFS_LIBS)
547 # null plugin test.
548 LIBGUESTFS_TESTS += test-null
549 TESTS += test-null-extents.sh
551 test_null_SOURCES = test-null.c test.h
552 test_null_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
553 test_null_LDADD = libtest.la $(LIBGUESTFS_LIBS)
555 # random plugin test.
556 LIBGUESTFS_TESTS += test-random
558 test_random_SOURCES = test-random.c test.h
559 test_random_CPPFLAGS = -I $(top_srcdir)/common/include
560 test_random_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
561 test_random_LDADD = libtest.la $(LIBGUESTFS_LIBS)
563 # split files plugin test.
564 check_DATA += split1 split2 split3
565 CLEANFILES += split1 split2 split3
566 split1: file-data
567         rm -f $@ $@-t
568         dd if=$< of=$@-t bs=1 count=100
569         mv $@-t $@
570 split2: file-data
571         rm -f $@ $@-t
572         dd if=$< of=$@-t bs=1 count=100 skip=100
573         mv $@-t $@
574 split3: file-data
575         rm -f $@ $@-t
576         dd if=$< of=$@-t bs=1 skip=200
577         mv $@-t $@
578 LIBGUESTFS_TESTS += test-split
580 test_split_SOURCES = test-split.c test.h
581 test_split_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
582 test_split_LDADD = libtest.la $(LIBGUESTFS_LIBS)
584 # ssh plugin test.
585 if HAVE_SSH
586 # Uses â€˜disk’ so we have to make it conditional on guestfish.
587 if HAVE_GUESTFISH
588 TESTS += test-ssh.sh
589 endif HAVE_GUESTFISH
590 check_DATA += \
591         ssh/sshd_config \
592         ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub \
593         ssh/authorized_keys
594 SSH_RANDOM_PORT := $(shell bash -c 'echo $$(( 10000 + $$RANDOM ))')
595 CLEANFILES += \
596         ssh/*~ \
597         ssh/sshd_config \
598         ssh/authorized_keys
599 DISTCLEANFILES += \
600         ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub \
601         ssh/id_rsa ssh/id_rsa.pub \
602         stamp-ssh-host-key stamp-ssh-user-key
604 ssh/sshd_config: ssh/sshd_config.in Makefile
605         rm -f $@ $@-t
606         $(SED) \
607             -e 's,__abs_builddir__,$(abs_builddir),g' \
608             -e 's,__RANDOM_PORT__,$(SSH_RANDOM_PORT),g' \
609             < $< > $@-t
610         mv $@-t $@
612 ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub: stamp-ssh-host-key
613 stamp-ssh-host-key:
614         rm -f $@
615         rm -f ssh/ssh_host_rsa_key
616         rm -f ssh/ssh_host_rsa_key.pub
617         ssh-keygen -t rsa -f ssh/ssh_host_rsa_key -N ''
618         touch $@
620 ssh/authorized_keys: ssh/id_rsa.pub
621         rm -f $@ $@-t
622         cp $< $@-t
623         mv $@-t $@
625 ssh/id_rsa ssh/id_rsa.pub: stamp-ssh-user-key
626 stamp-ssh-user-key:
627         rm -f $@
628         rm -f ssh/id_rsa
629         rm -f ssh/id_rsa.pub
630         ssh-keygen -t rsa -f ssh/id_rsa -N ''
631         touch $@
632 endif HAVE_SSH
634 # streaming plugin test.
635 # Doesn't work:
636 #LIBGUESTFS_TESTS += test-streaming
637 EXTRA_PROGRAMS += test-streaming
639 test_streaming_SOURCES = test-streaming.c test.h
640 test_streaming_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
641 test_streaming_LDADD = libtest.la $(LIBGUESTFS_LIBS)
643 # VDDK plugin test.
644 # This only tests that the plugin can be loaded against a
645 # dummy VDDK library, it is not a detailed test.
647 # check_LTLIBRARIES won't build a shared library (see automake manual).
648 # So we have to do this and add a dependency.
649 noinst_LTLIBRARIES += libvixDiskLib.la
650 TESTS += \
651         test-vddk.sh \
652         test-vddk-real.sh
654 libvixDiskLib_la_SOURCES = \
655         dummy-vddk.c
656 libvixDiskLib_la_CPPFLAGS = \
657         -I$(top_srcdir)/plugins/vddk
658 libvixDiskLib_la_CXXFLAGS = \
659         $(WARNINGS_CFLAGS)
660 # For use of the -rpath option, see:
661 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
662 libvixDiskLib_la_LDFLAGS = \
663         -shared -version-number 6:0:0 -rpath /nowhere
665 # zero plugin test.
666 TESTS += test-zero.sh
668 #----------------------------------------------------------------------
669 # Tests of language plugins.
671 # OCaml plugin test.
672 if HAVE_OCAML
674 LIBGUESTFS_TESTS += test-ocaml
676 # This is somewhat different from the other tests because we have
677 # to build an actual plugin here.
678 test_ocaml_SOURCES = test-ocaml.c test.h
679 test_ocaml_CFLAGS = \
680         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
681 test_ocaml_LDADD = libtest.la $(LIBGUESTFS_LIBS)
683 check_SCRIPTS += test-ocaml-plugin.so
684 test-ocaml-plugin.so: test_ocaml_plugin.cmx ../plugins/ocaml/libnbdkitocaml.la ../plugins/ocaml/NBDKit.cmi ../plugins/ocaml/NBDKit.cmx
685         $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../plugins/ocaml \
686           -output-obj -runtime-variant _pic -o $@ \
687           NBDKit.cmx $< \
688           -cclib -L../plugins/ocaml/.libs -cclib -lnbdkitocaml
689 test_ocaml_plugin.cmx: test_ocaml_plugin.ml ../plugins/ocaml/NBDKit.cmi
690         $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../plugins/ocaml -c $< -o $@
692 endif HAVE_OCAML
694 # perl plugin test.
695 if HAVE_PERL
697 TESTS += \
698         test-dump-plugin-example4.sh \
699         test-shebang-perl.sh
700 LIBGUESTFS_TESTS += test-perl
702 test_perl_SOURCES = test-lang-plugins.c test.h
703 test_perl_CFLAGS = \
704         -DLANG='"perl"' -DSCRIPT='"$(srcdir)/test.pl"' \
705         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
706 test_perl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
708 endif HAVE_PERL
710 # python plugin test.
711 if HAVE_PYTHON
713 TESTS += \
714         test-python-exception.sh \
715         test-shebang-python.sh
716 LIBGUESTFS_TESTS += test-python
718 test_python_SOURCES = test-lang-plugins.c test.h
719 test_python_CFLAGS = \
720         -DLANG='"python"' -DSCRIPT='"$(srcdir)/test.py"' \
721         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
722 test_python_LDADD = libtest.la $(LIBGUESTFS_LIBS)
724 endif HAVE_PYTHON
726 # Ruby plugin test.
727 if HAVE_RUBY
729 # Ruby tests are disabled.  See "WARNING" section in
730 # plugins/ruby/nbdkit-ruby-plugin.pod
732 #LIBGUESTFS_TESTS += \
733 #       test-ruby
734 #TESTS += test-shebang-ruby.sh
735 EXTRA_PROGRAMS += test-ruby
737 test_ruby_SOURCES = test-lang-plugins.c test.h
738 test_ruby_CFLAGS = \
739         -DLANG='"ruby"' -DSCRIPT='"$(srcdir)/test.rb"' \
740         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
741 test_ruby_LDADD = libtest.la $(LIBGUESTFS_LIBS)
743 endif HAVE_RUBY
745 # Shell (sh) plugin test.
746 LIBGUESTFS_TESTS += test-shell
747 check_DATA += test-shell.img
748 CLEANFILES += test-shell.img
750 test_shell_SOURCES = test-lang-plugins.c test.h
751 test_shell_CFLAGS = \
752         -DLANG='"sh"' -DSCRIPT='"$(srcdir)/test-shell.sh"' \
753         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
754 test_shell_LDADD = libtest.la $(LIBGUESTFS_LIBS)
756 test-shell.img:
757         truncate -s 1048576 $@
759 TESTS += test-sh-extents.sh
761 # Tcl plugin test.
762 if HAVE_TCL
764 LIBGUESTFS_TESTS += test-tcl
766 test_tcl_SOURCES = test-lang-plugins.c test.h
767 test_tcl_CFLAGS = \
768         -DLANG='"tcl"' -DSCRIPT='"$(srcdir)/test.tcl"' \
769         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
770 test_tcl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
772 endif HAVE_TCL
774 # Lua plugin test.
775 if HAVE_LUA
777 LIBGUESTFS_TESTS += test-lua
779 test_lua_SOURCES = test-lang-plugins.c test.h
780 test_lua_CFLAGS = \
781         -DLANG='"lua"' -DSCRIPT='"$(srcdir)/test.lua"' \
782         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
783 test_lua_LDADD = libtest.la $(LIBGUESTFS_LIBS)
785 endif HAVE_LUA
787 #----------------------------------------------------------------------
788 # Tests of filters.
790 # Generic test of filter layers.
791 check_PROGRAMS += test-layers
792 TESTS += test-layers.sh test-layers
794 test_layers_SOURCES = \
795         test-layers.c
796 test_layers_CPPFLAGS = \
797         -I$(top_srcdir)/common/include \
798         -I$(top_srcdir)/common/protocol \
799         -I$(top_srcdir)/common/utils \
800         -I$(top_srcdir)/server
801 test_layers_CFLAGS = \
802         $(WARNINGS_CFLAGS) \
803         $(PTHREAD_CFLAGS)
804 test_layers_LDFLAGS = \
805         $(PTHREAD_LIBS)
806 test_layers_LDADD = \
807         $(top_builddir)/common/utils/libutils.la
808 test_layers_DEPENDENCIES = \
809         test-layers-plugin.la \
810         test-layers-filter1.la \
811         test-layers-filter2.la \
812         test-layers-filter3.la
814 # check_LTLIBRARIES won't build a shared library (see automake manual).
815 # So we have to do this and add a dependency.
816 noinst_LTLIBRARIES += \
817         test-layers-plugin.la \
818         test-layers-filter1.la \
819         test-layers-filter2.la \
820         test-layers-filter3.la
822 test_layers_plugin_la_SOURCES = \
823         test-layers-plugin.c \
824         $(top_srcdir)/include/nbdkit-plugin.h
825 test_layers_plugin_la_CPPFLAGS = -I$(top_srcdir)/include
826 test_layers_plugin_la_CFLAGS = $(WARNINGS_CFLAGS)
827 # For use of the -rpath option, see:
828 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
829 test_layers_plugin_la_LDFLAGS = \
830         -module -avoid-version -shared -rpath /nowhere
832 test_layers_filter1_la_SOURCES = \
833         test-layers-filter.c \
834         $(top_srcdir)/include/nbdkit-filter.h
835 test_layers_filter1_la_CPPFLAGS = -I$(top_srcdir)/include
836 test_layers_filter1_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter1"'
837 # For use of the -rpath option, see:
838 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
839 test_layers_filter1_la_LDFLAGS = \
840         -module -avoid-version -shared -rpath /nowhere
842 test_layers_filter2_la_SOURCES = \
843         test-layers-filter.c \
844         $(top_srcdir)/include/nbdkit-filter.h
845 test_layers_filter2_la_CPPFLAGS = -I$(top_srcdir)/include
846 test_layers_filter2_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter2"'
847 # For use of the -rpath option, see:
848 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
849 test_layers_filter2_la_LDFLAGS = \
850         -module -avoid-version -shared -rpath /nowhere
852 test_layers_filter3_la_SOURCES = \
853         test-layers-filter.c \
854         $(top_srcdir)/include/nbdkit-filter.h
855 test_layers_filter3_la_CPPFLAGS = -I$(top_srcdir)/include
856 test_layers_filter3_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter3"'
857 # For use of the -rpath option, see:
858 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
859 test_layers_filter3_la_LDFLAGS = \
860         -module -avoid-version -shared -rpath /nowhere
862 # blocksize filter test.
863 TESTS += test-blocksize.sh
865 # cache filter test.
866 if HAVE_GUESTFISH
867 TESTS += \
868         test-cache.sh \
869         test-cache-on-read.sh
870 endif HAVE_GUESTFISH
871 TESTS += test-cache-max-size.sh
873 # cacheextents filter test.
874 TESTS += test-cacheextents.sh
876 # cow filter test.
877 if HAVE_GUESTFISH
878 TESTS += test-cow.sh
879 endif HAVE_GUESTFISH
881 # delay filter test.
882 LIBGUESTFS_TESTS += test-delay
884 test_delay_SOURCES = test-delay.c test.h
885 test_delay_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
886 test_delay_LDADD = libtest.la $(LIBGUESTFS_LIBS)
888 # error filter test.
889 LIBGUESTFS_TESTS += test-error
891 test_error_SOURCES = test-error.c test.h
892 test_error_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
893 test_error_LDADD = libtest.la $(LIBGUESTFS_LIBS)
895 TESTS += \
896         test-error0.sh \
897         test-error10.sh \
898         test-error100.sh
900 # fua filter test.
901 TESTS += test-fua.sh
903 # log filter test.
904 TESTS += test-log.sh
906 # nozero filter test.
907 TESTS += test-nozero.sh
909 # offset filter test.
910 check_DATA += offset-data
911 CLEANFILES += offset-data
912 LIBGUESTFS_TESTS += test-offset
914 offset-data: generate-offset-data.sh
915         $(srcdir)/generate-offset-data.sh $@
917 test_offset_SOURCES = test-offset.c test.h
918 test_offset_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
919 test_offset_LDADD = libtest.la $(LIBGUESTFS_LIBS)
921 TESTS += \
922         test-offset2.sh \
923         test-offset-extents.sh
925 # partition filter test.
926 TESTS += test-partition1.sh
927 if HAVE_GUESTFISH
928 TESTS += test-partition2.sh
929 endif HAVE_GUESTFISH
931 # rate filter test.
932 TESTS += \
933         test-rate.sh \
934         test-rate-dynamic.sh
936 # readahead filter test.
937 LIBGUESTFS_TESTS += test-readahead
938 TESTS += test-readahead-copy.sh
940 test_readahead_SOURCES = test-readahead.c test.h
941 test_readahead_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
942 test_readahead_LDADD = libtest.la $(LIBGUESTFS_LIBS)
944 # truncate filter tests.
945 TESTS += \
946         test-truncate1.sh \
947         test-truncate2.sh \
948         test-truncate3.sh \
949         test-truncate4.sh \
950         test-truncate-extents.sh
952 # xz filter test.
953 if HAVE_LIBLZMA
954 if HAVE_GUESTFISH
956 LIBGUESTFS_TESTS += test-xz
957 check_DATA += disk.xz
958 CLEANFILES += disk.xz
960 test_xz_SOURCES = test-xz.c test.h
961 test_xz_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
962 test_xz_LDADD = libtest.la $(LIBGUESTFS_LIBS)
964 disk.xz: disk
965         rm -f $@
966 # We choose a very small block size here only for testing.  Normally
967 # you should choose a 16M block size.
968         xz --best --block-size=32768 -c disk > $@
970 if HAVE_CURL
972 # xz filter + curl.
973 LIBGUESTFS_TESTS += test-xz-curl
975 test_xz_curl_SOURCES = \
976         test-xz-curl.c \
977         web-server.c \
978         web-server.h \
979         test.h
980 test_xz_curl_CFLAGS = \
981         $(WARNINGS_CFLAGS) \
982         $(LIBGUESTFS_CFLAGS) \
983         $(PTHREAD_CFLAGS)
984 test_xz_curl_LDFLAGS = \
985         $(PTHREAD_LIBS)
986 test_xz_curl_LDADD = \
987         libtest.la \
988         $(LIBGUESTFS_LIBS)
990 endif HAVE_CURL
992 endif HAVE_GUESTFISH
993 endif HAVE_LIBLZMA
995 endif HAVE_PLUGINS