tests: vsock: Use VMADDR_CID_LOCAL for loopback testing.
[nbdkit/ericb.git] / tests / Makefile.am
blob60583a03529e7ec9a6e39a958d46246e11f488de
1 # nbdkit
2 # Copyright (C) 2013-2020 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 #----------------------------------------------------------------------
35 # This directory contains most of the nbdkit tests.
37 # Test variables:
39 #   TESTS            Tests that don't have any special requirements.
41 #   LIBNBD_TESTS     Tests that link to the libnbd C library should be
42 #                    added to this variable.
44 #   LIBGUESTFS_TESTS Tests that link to libguestfs C library should be
45 #                    added to this variable.
47 # check_*, noinst_*, EXTRA_PROGRAMS: These are the usual automake
48 # variables.  Consult the automake manual for the meaning of these.
50 TESTS =
51 LIBNBD_TESTS =
52 LIBGUESTFS_TESTS =
54 check_PROGRAMS =
55 check_DATA =
56 check_SCRIPTS =
57 check_LTLIBRARIES =
58 noinst_LTLIBRARIES =
59 EXTRA_PROGRAMS =
61 # Ensure we're testing the local copy by running everything through
62 # the nbdkit helper script in the top build directory.
64 # Use the 'direct' backend, and ensure maximum libguestfs debugging.
66 # Enable libnbd debugging.
67 TESTS_ENVIRONMENT = \
68         PATH=$(abs_top_builddir):$(PATH) \
69         SRCDIR=$(srcdir) \
70         PYTHON=$(PYTHON) \
71         LIBGUESTFS_ATTACH_METHOD=appliance \
72         LIBGUESTFS_DEBUG=1 \
73         LIBGUESTFS_TRACE=1 \
74         LIBNBD_DEBUG=1 \
75         $(NULL)
77 # All files that need to go into the tarball must be added here.
78 EXTRA_DIST = \
79         generate-file-data.sh \
80         make-pki.sh \
81         make-psk.sh \
82         python-exception.py \
83         README.tests \
84         shebang.pl \
85         shebang.py \
86         shebang.rb \
87         ssh/sshd_config.in \
88         test-ansi-c.sh \
89         test-blocksize.sh \
90         test-cache.sh \
91         test-cache-max-size.sh \
92         test-cache-on-read.sh \
93         test-cacheextents.sh \
94         test-captive.sh \
95         test-cow.sh \
96         test-cow-null.sh \
97         test-cxx.sh \
98         test-data-7E.sh \
99         test-data-base64.sh \
100         test-data-extents.sh \
101         test-data-file.sh \
102         test-data-raw.sh \
103         test-debug-flags.sh \
104         test-dump-config.sh \
105         test-dump-plugin.sh \
106         test-dump-plugin-example4.sh \
107         test-eflags.sh \
108         test-error0.sh \
109         test-error10.sh \
110         test-error100.sh \
111         test-error-triggered.sh \
112         test-eval.sh \
113         test-export-name.sh \
114         test-extentlist.sh \
115         test-file-extents.sh \
116         test-floppy.sh \
117         test-foreground.sh \
118         test-fua.sh \
119         test-full.sh \
120         test-help.sh \
121         test-help-plugin.sh \
122         test-info-address.sh \
123         test-info-base64.sh \
124         test-info-raw.sh \
125         test-info-time.sh \
126         test-info-uptime.sh \
127         test-info-conntime.sh \
128         test-ip.sh \
129         test-ip-filter.sh \
130         test-iso.sh \
131         test-layers.sh \
132         test-linuxdisk.sh \
133         test-linuxdisk-copy-out.sh \
134         test-log.sh \
135         test-long-name.sh \
136         test.lua \
137         test-memory-largest.sh \
138         test-memory-largest-for-qemu.sh \
139         test-nbd-extents.sh \
140         test-nbd-tls.sh \
141         test-nbd-tls-psk.sh \
142         test-nbdkit-backend-debug.sh \
143         test-nofilter.sh \
144         test-nozero.sh \
145         test-null-extents.sh \
146         test_ocaml_plugin.ml \
147         test-ocaml.c \
148         test-offset2.sh \
149         test-offset-extents.sh \
150         test-parallel-file.sh \
151         test-parallel-nbd.sh \
152         test-parallel-sh.sh \
153         test-partition1.sh \
154         test-partition2.sh \
155         test-partitioning1.sh \
156         test-partitioning2.sh \
157         test-partitioning3.sh \
158         test-partitioning4.sh \
159         test-partitioning5.sh \
160         test-partitioning6.sh \
161         test-pattern.sh \
162         test-pattern-largest.sh \
163         test-pattern-largest-for-qemu.sh \
164         test-probe-filter.sh \
165         test-probe-plugin.sh \
166         test-python-exception.sh \
167         test.pl \
168         test_python.py \
169         test-python-plugin.py \
170         test-python.sh \
171         test-rate.sh \
172         test-rate-dynamic.sh \
173         test.rb \
174         test-readahead.sh \
175         test-readahead-copy.sh \
176         test-readahead-test-plugin.sh \
177         test-readahead-test-request.py \
178         test-retry.sh \
179         test-retry-extents.sh \
180         test-retry-size.sh \
181         test-retry-readonly.sh \
182         test-retry-reopen-fail.sh \
183         test-retry-zero-flags.sh \
184         test-shutdown.sh \
185         test-ssh.sh \
186         test-swap.sh \
187         test.tcl \
188         test-shebang-perl.sh \
189         test-shebang-python.sh \
190         test-shebang-ruby.sh \
191         test-shell.sh \
192         test-sh-errors.sh \
193         test-sh-extents.sh \
194         test-single.sh \
195         test-single-from-file.sh \
196         test-start.sh \
197         test-random-sock.sh \
198         test-tls.sh \
199         test-tls-psk.sh \
200         test-truncate1.sh \
201         test-truncate2.sh \
202         test-truncate3.sh \
203         test-truncate4.sh \
204         test-truncate-extents.sh \
205         test-vddk.sh \
206         test-vddk-real.sh \
207         test-version.sh \
208         test-version-filter.sh \
209         test-version-plugin.sh \
210         test-vsock.sh \
211         test-zero.sh \
212         $(NULL)
214 #----------------------------------------------------------------------
215 # Use 'make check' to run the ordinary tests as non-root.  The
216 # following are special commands for particular scenarios:
218 # To run all the tests under valgrind, use the following rule:
219 check-valgrind:
220         NBDKIT_VALGRIND=1 $(MAKE) check
222 # To run only tests which require root, use:
223 check-root:
224         $(MAKE) check TESTS="test-file-block test-swap.sh"
226 if HAVE_VDDK
227 # Run a basic check against a real copy of VDDK.  You must set
228 # vddkdir to point to the library location, eg:
230 #   make check-vddk vddkdir=vmware-vix-disklib-distrib
231 check-vddk:
232         $(MAKE) check TESTS=test-vddk-real.sh
233 endif HAVE_VDDK
235 #----------------------------------------------------------------------
236 # Basic server command line and start-up tests.
238 TESTS += \
239         test-help.sh \
240         test-version.sh \
241         test-dump-config.sh \
242         $(NULL)
244 if HAVE_PLUGINS
246 TESTS += \
247         test-help-plugin.sh \
248         test-version-plugin.sh \
249         test-version-filter.sh \
250         test-probe-filter.sh \
251         test-probe-plugin.sh \
252         test-dump-plugin.sh \
253         test-start.sh \
254         test-single.sh \
255         test-single-from-file.sh \
256         test-captive.sh \
257         test-random-sock.sh \
258         test-tls.sh \
259         test-tls-psk.sh \
260         test-ip.sh \
261         test-vsock.sh \
262         test-socket-activation \
263         test-foreground.sh \
264         test-debug-flags.sh \
265         test-long-name.sh \
266         test-swap.sh \
267         $(NULL)
269 check_PROGRAMS += \
270         test-socket-activation \
271         $(NULL)
273 test_socket_activation_SOURCES = test-socket-activation.c
274 test_socket_activation_CPPFLAGS = \
275         -I$(top_srcdir)/common/include \
276         -I$(top_srcdir)/common/protocol \
277         $(NULL)
278 test_socket_activation_CFLAGS = $(WARNINGS_CFLAGS)
280 endif HAVE_PLUGINS
282 # Test the header files can be included on their own.
283 check_PROGRAMS += \
284         test-just-plugin-header \
285         test-just-filter-header
286         $(NULL)
287 TESTS += \
288         test-just-plugin-header \
289         test-just-filter-header
290         $(NULL)
292 test_just_plugin_header_SOURCES = \
293         test-just-plugin-header.c \
294         $(NULL)
295 test_just_plugin_header_CPPFLAGS = \
296         -I$(top_srcdir)/include \
297         $(NULL)
298 test_just_plugin_header_CFLAGS = $(WARNINGS_CFLAGS)
300 test_just_filter_header_SOURCES = \
301         test-just-filter-header.c \
302         $(NULL)
303 test_just_filter_header_CPPFLAGS = \
304         -I$(top_srcdir)/include \
305         $(NULL)
306 test_just_filter_header_CFLAGS = $(WARNINGS_CFLAGS)
308 if CAN_TEST_ANSI_C
309 # This builds a plugin using an ANSI (ISO C90) compiler to ensure that
310 # the header file is compatible.  The plugin does nothing very
311 # interesting, it's mainly a compile test.
312 TESTS += \
313         test-ansi-c.sh \
314         $(NULL)
315 # check_LTLIBRARIES won't build a shared library (see automake manual).
316 # So we have to do this and add a dependency.
317 noinst_LTLIBRARIES += test-ansi-c-plugin.la
318 test-ansi-c.sh: test-ansi-c-plugin.la
320 test_ansi_c_plugin_la_SOURCES = \
321         test-ansi-c-plugin.c \
322         $(top_srcdir)/include/nbdkit-plugin.h \
323         $(NULL)
324 test_ansi_c_plugin_la_CPPFLAGS = \
325         -std=c90 -pedantic \
326         -I$(top_srcdir)/include \
327         $(NULL)
328 test_ansi_c_plugin_la_CFLAGS = $(WARNINGS_CFLAGS)
329 # For use of the -rpath option, see:
330 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
331 test_ansi_c_plugin_la_LDFLAGS = \
332         -module -avoid-version -shared -rpath /nowhere \
333         $(NULL)
334 endif CAN_TEST_ANSI_C
336 if HAVE_CXX
337 # This builds a plugin and a filter using the C++ compiler.  They
338 # don't do anything interesting when run.
339 TESTS += \
340         test-cxx.sh \
341         $(NULL)
342 # check_LTLIBRARIES won't build a shared library (see automake manual).
343 # So we have to do this and add a dependency.
344 noinst_LTLIBRARIES += test-cxx-plugin.la test-cxx-filter.la
345 test-cxx.sh: test-cxx-plugin.la test-cxx-filter.la
347 test_cxx_plugin_la_SOURCES = \
348         test-cxx-plugin.cpp \
349         $(top_srcdir)/include/nbdkit-plugin.h \
350         $(NULL)
351 test_cxx_plugin_la_CPPFLAGS = \
352         -I$(top_srcdir)/include \
353         $(NULL)
354 test_cxx_plugin_la_CXXFLAGS = $(WARNINGS_CFLAGS)
355 # For use of the -rpath option, see:
356 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
357 test_cxx_plugin_la_LDFLAGS = \
358         -module -avoid-version -shared -rpath /nowhere \
359         $(NULL)
361 test_cxx_filter_la_SOURCES = \
362         test-cxx-filter.cpp \
363         $(top_srcdir)/include/nbdkit-filter.h \
364         $(NULL)
365 test_cxx_filter_la_CPPFLAGS = \
366         -I$(top_srcdir)/include \
367         $(NULL)
368 test_cxx_filter_la_CXXFLAGS = $(WARNINGS_CFLAGS)
369 # For use of the -rpath option, see:
370 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
371 test_cxx_filter_la_LDFLAGS = \
372         -module -avoid-version -shared -rpath /nowhere \
373         $(NULL)
374 endif HAVE_CXX
376 # Exit with parent test.
377 check_PROGRAMS += test-exit-with-parent
378 TESTS += test-exit-with-parent
380 test_exit_with_parent_SOURCES = \
381         test-exit-with-parent.c test.h \
382         $(NULL)
383 test_exit_with_parent_CPPFLAGS = \
384         -I$(top_srcdir)/common/include \
385         $(NULL)
386 test_exit_with_parent_CFLAGS = \
387         $(WARNINGS_CFLAGS) \
388         $(LIBGUESTFS_CFLAGS) \
389         $(NULL)
391 # PKI files for the TLS tests.
392 check_DATA += pki/.stamp
393 pki/.stamp: $(srcdir)/make-pki.sh
394         SRCDIR=$(srcdir) $(srcdir)/make-pki.sh
396 # PSK keys for the TLS-PSK tests.
397 check_DATA += keys.psk
398 keys.psk: $(srcdir)/make-psk.sh
399         SRCDIR=$(srcdir) $(srcdir)/make-psk.sh
401 # Keys are expensive to recreate so only delete them when we do
402 # â€˜make distclean’.
403 DISTCLEANFILES = keys.psk
404 distclean-local: distclean-local-tls
405 distclean-local-tls:
406         rm -rf pki
408 #----------------------------------------------------------------------
409 # Tests of C plugins or tests which require plugins.
411 if HAVE_PLUGINS
413 # Common data shared by multiple tests
414 check_DATA += file-data
415 CLEANFILES += file-data
416 file-data: generate-file-data.sh
417         $(srcdir)/generate-file-data.sh $@
419 # While most tests need libguestfs, testing parallel I/O is easier when
420 # using qemu-io to kick off asynchronous requests.
421 TESTS += \
422         test-parallel-file.sh \
423         test-parallel-nbd.sh \
424         test-parallel-sh.sh \
425         $(NULL)
427 # Common test library.
428 check_LTLIBRARIES += libtest.la
429 libtest_la_SOURCES = test.c test.h
430 libtest_la_CFLAGS = $(WARNINGS_CFLAGS)
432 # Basic connection test.
433 LIBNBD_TESTS += test-connect
435 test_connect_SOURCES = test-connect.c
436 test_connect_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
437 test_connect_LDADD = $(LIBNBD_LIBS)
439 # newstyle protocol test.
440 LIBNBD_TESTS += test-newstyle
442 test_newstyle_SOURCES = test-newstyle.c
443 test_newstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
444 test_newstyle_LDADD = $(LIBNBD_LIBS)
446 # oldstyle protocol test.
447 LIBNBD_TESTS += test-oldstyle
449 test_oldstyle_SOURCES = test-oldstyle.c
450 test_oldstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
451 test_oldstyle_LDADD = $(LIBNBD_LIBS)
453 # Test export flags.
454 TESTS += test-eflags.sh
456 # Test export name.
457 TESTS += test-export-name.sh
459 # common disk image shared with several tests
460 check_DATA += disk
461 CLEANFILES += disk
463 disk:
464         rm -rf disk.tmp $@ $@-t
465         mkdir disk.tmp
466         echo -n "hello,world" > disk.tmp/hello.txt
467         $(top_builddir)/nbdkit -fv -U - linuxdisk disk.tmp size=100M \
468             --run 'qemu-img convert $$nbd $@-t'
469         rm -rf disk.tmp
470         mv $@-t $@
472 # curl plugin test.
473 if HAVE_CURL
474 LIBGUESTFS_TESTS += test-curl
476 test_curl_SOURCES = \
477         test-curl.c \
478         web-server.c \
479         web-server.h \
480         test.h \
481         $(NULL)
482 test_curl_CPPFLAGS = \
483         -I$(top_srcdir)/common/utils
484 test_curl_CFLAGS = \
485         $(WARNINGS_CFLAGS) \
486         $(LIBGUESTFS_CFLAGS) \
487         $(PTHREAD_CFLAGS) \
488         $(NULL)
489 test_curl_LDFLAGS = \
490         $(top_builddir)/common/utils/libutils.la \
491         $(PTHREAD_LIBS) \
492         $(NULL)
493 test_curl_LDADD = \
494         libtest.la \
495         $(LIBGUESTFS_LIBS) \
496         $(NULL)
497 endif HAVE_CURL
499 # data plugin test.
500 LIBGUESTFS_TESTS += test-data
501 TESTS += \
502         test-data-7E.sh \
503         test-data-base64.sh \
504         test-data-extents.sh \
505         test-data-file.sh \
506         test-data-raw.sh \
507         $(NULL)
509 test_data_SOURCES = test-data.c test.h
510 test_data_CPPFLAGS = -I$(top_srcdir)/common/include
511 test_data_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
512 test_data_LDADD = libtest.la $(LIBGUESTFS_LIBS)
514 # eval plugin test.
515 TESTS += test-eval.sh
517 # ext2 plugin test.
518 if HAVE_EXT2
519 if HAVE_GUESTFISH
521 LIBGUESTFS_TESTS += test-ext2
522 check_DATA += ext2.img
523 CLEANFILES += ext2.img
525 ext2.img: disk
526         rm -f $@ $@-t
527         guestfish \
528             sparse $@-t 2G : \
529             run : \
530             mkfs ext4 /dev/sda : \
531             mount /dev/sda / : \
532             mkdir /disks : \
533             upload $< /disks/disk.img
534         mv $@-t $@
536 test_ext2_SOURCES = test-ext2.c test.h
537 test_ext2_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
538 test_ext2_LDADD = libtest.la $(LIBGUESTFS_LIBS)
540 endif HAVE_GUESTFISH
541 endif HAVE_EXT2
543 # file plugin test.
544 LIBNBD_TESTS += test-file
545 LIBGUESTFS_TESTS += test-file-block
547 test_file_SOURCES = test-file.c
548 test_file_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
549 test_file_LDADD = $(LIBNBD_LIBS)
551 test_file_block_SOURCES = test-file-block.c test.h
552 test_file_block_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
553 test_file_block_LDADD = libtest.la $(LIBGUESTFS_LIBS)
555 TESTS += test-file-extents.sh
557 # floppy plugin test.
558 TESTS += test-floppy.sh
560 # full plugin test.
561 TESTS += test-full.sh
563 # gzip plugin test.
564 if HAVE_ZLIB
565 LIBGUESTFS_TESTS += test-gzip
566 check_DATA += disk.gz
567 CLEANFILES += disk.gz
569 test_gzip_SOURCES = test-gzip.c test.h
570 test_gzip_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
571 test_gzip_LDADD = libtest.la $(LIBGUESTFS_LIBS)
573 disk.gz: disk
574         rm -f $@
575         gzip -9 -c disk > $@
576 endif HAVE_ZLIB
578 # info plugin test.
579 TESTS += \
580         test-info-address.sh \
581         test-info-base64.sh \
582         test-info-raw.sh \
583         test-info-time.sh \
584         test-info-uptime.sh \
585         test-info-conntime.sh \
586         $(NULL)
588 # iso plugin test.
589 if HAVE_ISO
590 TESTS += test-iso.sh
591 endif HAVE_ISO
593 # linuxdisk plugin test.
594 TESTS += \
595         test-linuxdisk.sh \
596         test-linuxdisk-copy-out.sh \
597         $(NULL)
599 # memory plugin test.
600 LIBGUESTFS_TESTS += test-memory
601 TESTS += test-memory-largest.sh test-memory-largest-for-qemu.sh
603 test_memory_SOURCES = test-memory.c test.h
604 test_memory_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
605 test_memory_LDADD = libtest.la $(LIBGUESTFS_LIBS)
607 # partitioning plugin test.
608 TESTS += \
609         test-partitioning1.sh \
610         test-partitioning2.sh \
611         test-partitioning3.sh \
612         test-partitioning4.sh \
613         test-partitioning5.sh \
614         test-partitioning6.sh \
615         $(NULL)
617 # pattern plugin test.
618 TESTS += \
619         test-pattern.sh \
620         test-pattern-largest.sh \
621         test-pattern-largest-for-qemu.sh \
622         $(NULL)
624 if HAVE_NBD_PLUGIN
625 # nbd plugin test.
626 LIBGUESTFS_TESTS += test-nbd
627 TESTS += \
628         test-nbd-extents.sh \
629         test-nbd-tls.sh \
630         test-nbd-tls-psk.sh \
631         $(NULL)
633 test_nbd_SOURCES = test-nbd.c test.h
634 test_nbd_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
635 test_nbd_LDADD = libtest.la $(LIBGUESTFS_LIBS)
636 endif HAVE_NBD_PLUGIN
638 # null plugin test.
639 LIBNBD_TESTS += test-null
640 TESTS += test-null-extents.sh
642 test_null_SOURCES = test-null.c
643 test_null_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
644 test_null_LDADD = $(LIBNBD_LIBS)
646 # random plugin test.
647 LIBNBD_TESTS += test-random
649 test_random_SOURCES = test-random.c
650 test_random_CPPFLAGS = -I $(top_srcdir)/common/include
651 test_random_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
652 test_random_LDADD = $(LIBNBD_LIBS)
654 # split files plugin test.
655 check_DATA += split1 split2 split3
656 CLEANFILES += split1 split2 split3
657 split1: file-data
658         rm -f $@ $@-t
659         dd if=$< of=$@-t bs=1 count=100
660         mv $@-t $@
661 split2: file-data
662         rm -f $@ $@-t
663         dd if=$< of=$@-t bs=1 count=100 skip=100
664         mv $@-t $@
665 split3: file-data
666         rm -f $@ $@-t
667         dd if=$< of=$@-t bs=1 skip=200
668         mv $@-t $@
669 LIBNBD_TESTS += test-split
671 test_split_SOURCES = test-split.c
672 test_split_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
673 test_split_LDADD = $(LIBNBD_LIBS)
675 # ssh plugin test.
676 if HAVE_SSH
677 # Uses â€˜disk’ so we have to make it conditional on guestfish.
678 TESTS += test-ssh.sh
679 check_DATA += \
680         ssh/sshd_config \
681         ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub \
682         ssh/authorized_keys \
683         $(NULL)
684 SSH_RANDOM_PORT := $(shell bash -c 'echo $$(( 10000 + $$RANDOM ))')
685 CLEANFILES += \
686         ssh/*~ \
687         ssh/sshd_config \
688         ssh/authorized_keys \
689         $(NULL)
690 DISTCLEANFILES += \
691         ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub \
692         ssh/id_rsa ssh/id_rsa.pub \
693         stamp-ssh-host-key stamp-ssh-user-key \
694         $(NULL)
696 ssh/sshd_config: ssh/sshd_config.in Makefile
697         rm -f $@ $@-t
698         $(SED) \
699             -e 's,__abs_builddir__,$(abs_builddir),g' \
700             -e 's,__RANDOM_PORT__,$(SSH_RANDOM_PORT),g' \
701             < $< > $@-t
702         mv $@-t $@
704 ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub: stamp-ssh-host-key
705 stamp-ssh-host-key:
706         rm -f $@
707         rm -f ssh/ssh_host_rsa_key
708         rm -f ssh/ssh_host_rsa_key.pub
709         ssh-keygen -t rsa -f ssh/ssh_host_rsa_key -N ''
710         touch $@
712 ssh/authorized_keys: ssh/id_rsa.pub
713         rm -f $@ $@-t
714         cp $< $@-t
715         mv $@-t $@
717 ssh/id_rsa ssh/id_rsa.pub: stamp-ssh-user-key
718 stamp-ssh-user-key:
719         rm -f $@
720         rm -f ssh/id_rsa
721         rm -f ssh/id_rsa.pub
722         ssh-keygen -t rsa -f ssh/id_rsa -N ''
723         touch $@
724 endif HAVE_SSH
726 # streaming plugin test.
727 # Doesn't work:
728 LIBNBD_TESTS += test-streaming
730 test_streaming_SOURCES = test-streaming.c
731 test_streaming_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
732 test_streaming_LDADD = $(LIBNBD_LIBS)
734 if HAVE_VDDK
735 # VDDK plugin test.
736 # This only tests that the plugin can be loaded against a
737 # dummy VDDK library, it is not a detailed test.
739 # check_LTLIBRARIES won't build a shared library (see automake manual).
740 # So we have to do this and add a dependency.
741 noinst_LTLIBRARIES += libvixDiskLib.la
742 TESTS += \
743         test-vddk.sh \
744         test-vddk-real.sh \
745         $(NULL)
747 libvixDiskLib_la_SOURCES = \
748         dummy-vddk.c \
749         $(NULL)
750 libvixDiskLib_la_CPPFLAGS = \
751         -I$(top_srcdir)/plugins/vddk \
752         $(NULL)
753 libvixDiskLib_la_CXXFLAGS = $(WARNINGS_CFLAGS)
754 # For use of the -rpath option, see:
755 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
756 libvixDiskLib_la_LDFLAGS = \
757         -shared -version-number 6:0:0 -rpath /nowhere \
758         $(NULL)
759 endif HAVE_VDDK
761 # zero plugin test.
762 TESTS += test-zero.sh
764 # -D nbdkit.backend.* settings.
765 TESTS += test-nbdkit-backend-debug.sh
767 #----------------------------------------------------------------------
768 # Tests of language plugins.
770 # OCaml plugin test.
771 if HAVE_OCAML
773 LIBGUESTFS_TESTS += test-ocaml
775 # This is somewhat different from the other tests because we have
776 # to build an actual plugin here.
777 test_ocaml_SOURCES = test-ocaml.c test.h
778 test_ocaml_CFLAGS = \
779         $(WARNINGS_CFLAGS) \
780         $(LIBGUESTFS_CFLAGS) \
781         $(NULL)
782 test_ocaml_LDADD = libtest.la $(LIBGUESTFS_LIBS)
784 check_SCRIPTS += test-ocaml-plugin.so
785 test-ocaml-plugin.so: test_ocaml_plugin.cmx ../plugins/ocaml/libnbdkitocaml.la ../plugins/ocaml/NBDKit.cmi ../plugins/ocaml/NBDKit.cmx
786         $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../plugins/ocaml \
787           -output-obj -runtime-variant _pic -o $@ \
788           NBDKit.cmx $< \
789           -cclib -L../plugins/ocaml/.libs -cclib -lnbdkitocaml
790 test_ocaml_plugin.cmx: test_ocaml_plugin.ml ../plugins/ocaml/NBDKit.cmi
791         $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../plugins/ocaml -c $< -o $@
793 endif HAVE_OCAML
795 # perl plugin test.
796 if HAVE_PERL
798 TESTS += \
799         test-dump-plugin-example4.sh \
800         test-shebang-perl.sh \
801         $(NULL)
802 LIBGUESTFS_TESTS += test-perl
804 test_perl_SOURCES = test-lang-plugins.c test.h
805 test_perl_CFLAGS = \
806         -DLANG='"perl"' -DSCRIPT='"$(srcdir)/test.pl"' \
807         $(WARNINGS_CFLAGS) \
808         $(LIBGUESTFS_CFLAGS) \
809         $(NULL)
810 test_perl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
812 endif HAVE_PERL
814 # python plugin test.
815 if HAVE_PYTHON
817 TESTS += \
818         test-python.sh \
819         test-python-exception.sh \
820         test-shebang-python.sh \
821         $(NULL)
823 endif HAVE_PYTHON
825 # Ruby plugin test.
826 if HAVE_RUBY
828 # Ruby tests are disabled.  See "WARNING" section in
829 # plugins/ruby/nbdkit-ruby-plugin.pod
831 #LIBGUESTFS_TESTS += \
832 #       test-ruby \
833 #       $(NULL)
834 #TESTS += test-shebang-ruby.sh
835 EXTRA_PROGRAMS += test-ruby
837 test_ruby_SOURCES = test-lang-plugins.c test.h
838 test_ruby_CFLAGS = \
839         -DLANG='"ruby"' -DSCRIPT='"$(srcdir)/test.rb"' \
840         $(WARNINGS_CFLAGS) \
841         $(LIBGUESTFS_CFLAGS) \
842         $(NULL)
843 test_ruby_LDADD = libtest.la $(LIBGUESTFS_LIBS)
845 endif HAVE_RUBY
847 # Shell (sh) plugin test.
848 LIBGUESTFS_TESTS += test-shell
849 check_DATA += test-shell.img
850 CLEANFILES += test-shell.img
852 test_shell_SOURCES = test-lang-plugins.c test.h
853 test_shell_CFLAGS = \
854         -DLANG='"sh"' -DSCRIPT='"$(srcdir)/test-shell.sh"' \
855         $(WARNINGS_CFLAGS) \
856         $(LIBGUESTFS_CFLAGS) \
857         $(NULL)
858 test_shell_LDADD = libtest.la $(LIBGUESTFS_LIBS)
860 test-shell.img:
861         truncate -s 1048576 $@
863 TESTS += \
864         test-sh-errors.sh \
865         test-sh-extents.sh \
866         $(NULL)
868 # Tcl plugin test.
869 if HAVE_TCL
871 LIBGUESTFS_TESTS += test-tcl
873 test_tcl_SOURCES = test-lang-plugins.c test.h
874 test_tcl_CFLAGS = \
875         -DLANG='"tcl"' -DSCRIPT='"$(srcdir)/test.tcl"' \
876         $(WARNINGS_CFLAGS) \
877         $(LIBGUESTFS_CFLAGS) \
878         $(NULL)
879 test_tcl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
881 endif HAVE_TCL
883 # Lua plugin test.
884 if HAVE_LUA
886 LIBGUESTFS_TESTS += test-lua
888 test_lua_SOURCES = test-lang-plugins.c test.h
889 test_lua_CFLAGS = \
890         -DLANG='"lua"' -DSCRIPT='"$(srcdir)/test.lua"' \
891         $(WARNINGS_CFLAGS) \
892         $(LIBGUESTFS_CFLAGS) \
893         $(NULL)
894 test_lua_LDADD = libtest.la $(LIBGUESTFS_LIBS)
896 endif HAVE_LUA
898 #----------------------------------------------------------------------
899 # Tests of filters.
901 # Generic test of filter layers.
902 check_PROGRAMS += test-layers
903 TESTS += test-layers.sh test-layers
905 test_layers_SOURCES = \
906         test-layers.c \
907         $(NULL)
908 test_layers_CPPFLAGS = \
909         -I$(top_srcdir)/common/include \
910         -I$(top_srcdir)/common/protocol \
911         -I$(top_srcdir)/common/utils \
912         -I$(top_srcdir)/server \
913         $(NULL)
914 test_layers_CFLAGS = \
915         $(WARNINGS_CFLAGS) \
916         $(PTHREAD_CFLAGS) \
917         $(NULL)
918 test_layers_LDFLAGS = \
919         $(PTHREAD_LIBS) \
920         $(NULL)
921 test_layers_LDADD = \
922         $(top_builddir)/common/utils/libutils.la \
923         $(NULL)
924 test_layers_DEPENDENCIES = \
925         test-layers-plugin.la \
926         test-layers-filter1.la \
927         test-layers-filter2.la \
928         test-layers-filter3.la \
929         $(NULL)
931 # check_LTLIBRARIES won't build a shared library (see automake manual).
932 # So we have to do this and add a dependency.
933 noinst_LTLIBRARIES += \
934         test-layers-plugin.la \
935         test-layers-filter1.la \
936         test-layers-filter2.la \
937         test-layers-filter3.la \
938         $(NULL)
940 test_layers_plugin_la_SOURCES = \
941         test-layers-plugin.c \
942         $(top_srcdir)/include/nbdkit-plugin.h \
943         $(NULL)
944 test_layers_plugin_la_CPPFLAGS = -I$(top_srcdir)/include
945 test_layers_plugin_la_CFLAGS = $(WARNINGS_CFLAGS)
946 # For use of the -rpath option, see:
947 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
948 test_layers_plugin_la_LDFLAGS = \
949         -module -avoid-version -shared -rpath /nowhere \
950         $(NULL)
952 test_layers_filter1_la_SOURCES = \
953         test-layers-filter.c \
954         $(top_srcdir)/include/nbdkit-filter.h \
955         $(NULL)
956 test_layers_filter1_la_CPPFLAGS = -I$(top_srcdir)/include
957 test_layers_filter1_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter1"'
958 # For use of the -rpath option, see:
959 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
960 test_layers_filter1_la_LDFLAGS = \
961         -module -avoid-version -shared -rpath /nowhere \
962         $(NULL)
964 test_layers_filter2_la_SOURCES = \
965         test-layers-filter.c \
966         $(top_srcdir)/include/nbdkit-filter.h \
967         $(NULL)
968 test_layers_filter2_la_CPPFLAGS = -I$(top_srcdir)/include
969 test_layers_filter2_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter2"'
970 # For use of the -rpath option, see:
971 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
972 test_layers_filter2_la_LDFLAGS = \
973         -module -avoid-version -shared -rpath /nowhere \
974         $(NULL)
976 test_layers_filter3_la_SOURCES = \
977         test-layers-filter.c \
978         $(top_srcdir)/include/nbdkit-filter.h \
979         $(NULL)
980 test_layers_filter3_la_CPPFLAGS = -I$(top_srcdir)/include
981 test_layers_filter3_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter3"'
982 # For use of the -rpath option, see:
983 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
984 test_layers_filter3_la_LDFLAGS = \
985         -module -avoid-version -shared -rpath /nowhere \
986         $(NULL)
988 # blocksize filter test.
989 TESTS += test-blocksize.sh
991 # cache filter test.
992 TESTS += \
993         test-cache.sh \
994         test-cache-on-read.sh \
995         $(NULL)
996 TESTS += test-cache-max-size.sh
998 # cacheextents filter test.
999 TESTS += test-cacheextents.sh
1001 # cow filter test.
1002 TESTS += \
1003         test-cow.sh \
1004         test-cow-null.sh \
1005         $(NULL)
1007 # delay filter tests.
1008 TESTS += test-shutdown.sh
1009 LIBNBD_TESTS += test-delay
1011 test_delay_SOURCES = test-delay.c
1012 test_delay_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
1013 test_delay_LDADD = $(LIBNBD_LIBS)
1015 # error filter test.
1016 TESTS += \
1017         test-error0.sh \
1018         test-error10.sh \
1019         test-error100.sh \
1020         test-error-triggered.sh \
1021         $(NULL)
1023 # extentlist filter test.
1024 TESTS += test-extentlist.sh
1026 # fua filter test.
1027 TESTS += test-fua.sh
1029 # ip filter test.
1030 TESTS += test-ip-filter.sh
1032 # log filter test.
1033 TESTS += test-log.sh
1035 # nofilter test.
1036 TESTS += test-nofilter.sh
1038 if HAVE_NBD_PLUGIN
1039 # nozero filter test.
1040 TESTS += test-nozero.sh
1041 endif HAVE_NBD_PLUGIN
1043 # offset filter test.
1044 LIBGUESTFS_TESTS += test-offset
1046 test_offset_SOURCES = test-offset.c test.h
1047 test_offset_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
1048 test_offset_LDADD = libtest.la $(LIBGUESTFS_LIBS)
1050 TESTS += \
1051         test-offset2.sh \
1052         test-offset-extents.sh \
1053         $(NULL)
1055 # partition filter test.
1056 TESTS += test-partition1.sh
1057 TESTS += test-partition2.sh
1059 # rate filter test.
1060 TESTS += \
1061         test-rate.sh \
1062         test-rate-dynamic.sh \
1063         $(NULL)
1065 # readahead filter test.
1066 TESTS += \
1067         test-readahead.sh \
1068         test-readahead-copy.sh \
1069         $(NULL)
1071 # retry filter test.
1072 TESTS += \
1073         test-retry.sh \
1074         test-retry-readonly.sh \
1075         test-retry-extents.sh \
1076         test-retry-size.sh \
1077         test-retry-reopen-fail.sh \
1078         test-retry-zero-flags.sh \
1079         $(NULL)
1081 # truncate filter tests.
1082 TESTS += \
1083         test-truncate1.sh \
1084         test-truncate2.sh \
1085         test-truncate3.sh \
1086         test-truncate4.sh \
1087         test-truncate-extents.sh \
1088         $(NULL)
1090 # xz filter test.
1091 if HAVE_LIBLZMA
1092 LIBGUESTFS_TESTS += test-xz
1093 check_DATA += disk.xz
1094 CLEANFILES += disk.xz
1096 test_xz_SOURCES = test-xz.c test.h
1097 test_xz_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
1098 test_xz_LDADD = libtest.la $(LIBGUESTFS_LIBS)
1100 disk.xz: disk
1101         rm -f $@
1102 # We choose a very small block size here only for testing.  Normally
1103 # you should choose a 16M block size.
1104         xz --best --block-size=32768 -c disk > $@
1106 # xz filter + curl.
1107 if HAVE_CURL
1108 LIBGUESTFS_TESTS += test-xz-curl
1110 test_xz_curl_SOURCES = \
1111         test-xz-curl.c \
1112         web-server.c \
1113         web-server.h \
1114         test.h \
1115         $(NULL)
1116 test_xz_curl_CPPFLAGS = \
1117         -I$(top_srcdir)/common/utils
1118 test_xz_curl_CFLAGS = \
1119         $(WARNINGS_CFLAGS) \
1120         $(LIBGUESTFS_CFLAGS) \
1121         $(PTHREAD_CFLAGS) \
1122         $(NULL)
1123 test_xz_curl_LDFLAGS = \
1124         $(top_builddir)/common/utils/libutils.la \
1125         $(PTHREAD_LIBS) \
1126         $(NULL)
1127 test_xz_curl_LDADD = \
1128         libtest.la \
1129         $(LIBGUESTFS_LIBS) \
1130         $(NULL)
1132 endif HAVE_CURL
1133 endif HAVE_LIBLZMA
1135 endif HAVE_PLUGINS
1137 #----------------------------------------------------------------------
1138 # Tests of old plugins.
1140 TESTS += \
1141         test-old-plugins-x86_64-Linux-v1.0.0.sh \
1142         test-old-plugins-x86_64-Linux-v1.2.8.sh \
1143         test-old-plugins-x86_64-Linux-v1.8.4.sh \
1144         test-old-plugins-x86_64-Linux-v1.12.8.sh \
1145         $(NULL)
1147 test-old-plugins-%.sh:
1148         rm -f $@ $@-t
1149         f=`echo "$@" | $(SED) 's/test-old-plugins-\(.*\).sh/\1/'`; \
1150         echo 'script=$@ exec $$srcdir/test-old-plugins.sh' "$$f" > $@-t
1151         chmod 0755 $@-t
1152         mv $@-t $@
1154 EXTRA_DIST += \
1155         old-plugins/README \
1156         old-plugins/*/*/*/nbdkit-file-plugin.so \
1157         test-old-plugins.sh \
1158         $(NULL)
1159 CLEANFILES += \
1160         test-old-plugins-*.sh \
1161         $(NULL)
1163 #----------------------------------------------------------------------
1165 if HAVE_LIBNBD
1166 check_PROGRAMS += $(LIBNBD_TESTS)
1167 TESTS += $(LIBNBD_TESTS)
1168 endif HAVE_LIBNBD
1170 if HAVE_LIBGUESTFS
1171 check_PROGRAMS += $(LIBGUESTFS_TESTS)
1172 TESTS += $(LIBGUESTFS_TESTS)
1173 endif HAVE_LIBGUESTFS