New nbdkit-ip-filter allows you to filter clients by IP address.
[nbdkit/ericb.git] / tests / Makefile.am
blob87753568c05fb900010ede4c75566110d3965add
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-cow-null.sh \
54         test-cxx.sh \
55         test-data-7E.sh \
56         test-data-base64.sh \
57         test-data-extents.sh \
58         test-data-file.sh \
59         test-data-raw.sh \
60         test-debug-flags.sh \
61         test-dump-config.sh \
62         test-dump-plugin.sh \
63         test-dump-plugin-example4.sh \
64         test-eflags.sh \
65         test-error0.sh \
66         test-error10.sh \
67         test-error100.sh \
68         test-error-triggered.sh \
69         test-export-name.sh \
70         test-file-extents.sh \
71         test-floppy.sh \
72         test-foreground.sh \
73         test-fua.sh \
74         test-full.sh \
75         test-help.sh \
76         test-help-plugin.sh \
77         test-info-address.sh \
78         test-info-base64.sh \
79         test-info-raw.sh \
80         test-info-time.sh \
81         test-info-uptime.sh \
82         test-info-conntime.sh \
83         test-ip.sh \
84         test-ip-filter.sh \
85         test-iso.sh \
86         test-layers.sh \
87         test-linuxdisk.sh \
88         test-linuxdisk-copy-out.sh \
89         test-log.sh \
90         test-long-name.sh \
91         test.lua \
92         test-memory-largest.sh \
93         test-memory-largest-for-qemu.sh \
94         test-nbd-extents.sh \
95         test-nbd-tls.sh \
96         test-nbd-tls-psk.sh \
97         test-nozero.sh \
98         test-null-extents.sh \
99         test_ocaml_plugin.ml \
100         test-ocaml.c \
101         test-offset2.sh \
102         test-offset-extents.sh \
103         test-parallel-file.sh \
104         test-parallel-nbd.sh \
105         test-parallel-sh.sh \
106         test-partition1.sh \
107         test-partition2.sh \
108         test-partitioning1.sh \
109         test-partitioning2.sh \
110         test-partitioning3.sh \
111         test-partitioning4.sh \
112         test-partitioning5.sh \
113         test-partitioning6.sh \
114         test-pattern.sh \
115         test-pattern-largest.sh \
116         test-pattern-largest-for-qemu.sh \
117         test-python-exception.sh \
118         test.pl \
119         test.py \
120         test-rate.sh \
121         test-rate-dynamic.sh \
122         test.rb \
123         test-readahead-copy.sh \
124         test-retry.sh \
125         test-retry-extents.sh \
126         test-retry-size.sh \
127         test-retry-readonly.sh \
128         test-retry-reopen-fail.sh \
129         test-retry-zero-flags.sh \
130         test-shutdown.sh \
131         test-ssh.sh \
132         test-swap.sh \
133         test.tcl \
134         test-shebang-perl.sh \
135         test-shebang-python.sh \
136         test-shebang-ruby.sh \
137         test-shell.sh \
138         test-sh-errors.sh \
139         test-sh-extents.sh \
140         test-single.sh \
141         test-single-from-file.sh \
142         test-start.sh \
143         test-random-sock.sh \
144         test-tls.sh \
145         test-tls-psk.sh \
146         test-truncate1.sh \
147         test-truncate2.sh \
148         test-truncate3.sh \
149         test-truncate4.sh \
150         test-truncate-extents.sh \
151         test-vddk.sh \
152         test-vddk-real.sh \
153         test-version.sh \
154         test-version-filter.sh \
155         test-version-plugin.sh \
156         test-zero.sh \
157         $(NULL)
159 # Use 'make check' to run the ordinary tests.  To run all the tests
160 # under valgrind, use the following rule:
161 check-valgrind:
162         NBDKIT_VALGRIND=1 $(MAKE) check
164 # To run only tests which require root, use:
165 check-root:
166         $(MAKE) check TESTS="test-file-block test-swap.sh"
168 if HAVE_VDDK
169 # Run a basic check against a real copy of VDDK.  You must set
170 # vddkdir to point to the library location, eg:
172 #   make check-vddk vddkdir=vmware-vix-disklib-distrib
173 check-vddk:
174         $(MAKE) check TESTS=test-vddk-real.sh
175 endif HAVE_VDDK
177 #----------------------------------------------------------------------
178 # Basic test variables.
180 # TESTS: Tests that don't have any special requirements.
182 # LIBNBD_TESTS: Tests that link to the libnbd C library should be
183 # added to this variable.
185 # LIBGUESTFS_TESTS: Tests that link to libguestfs C library should be
186 # added to this variable.
188 # check_*, noinst_*, EXTRA_PROGRAMS: Usual automake variables.
189 # Consult the automake manual for the meaning of these.
191 TESTS =
192 LIBNBD_TESTS =
193 LIBGUESTFS_TESTS =
195 check_PROGRAMS =
196 check_DATA =
197 check_SCRIPTS =
198 check_LTLIBRARIES =
199 noinst_LTLIBRARIES =
200 EXTRA_PROGRAMS =
202 # Ensure we're testing the local copy by running everything through
203 # the nbdkit helper script in the top build directory.
205 # Use the 'direct' backend, and ensure maximum libguestfs debugging.
207 # Enable libnbd debugging.
208 TESTS_ENVIRONMENT = \
209         PATH=$(abs_top_builddir):$(PATH) \
210         SRCDIR=$(srcdir) \
211         LIBGUESTFS_ATTACH_METHOD=appliance \
212         LIBGUESTFS_DEBUG=1 \
213         LIBGUESTFS_TRACE=1 \
214         LIBNBD_DEBUG=1 \
215         $(NULL)
217 #----------------------------------------------------------------------
218 # Basic server command line and start-up tests.
220 TESTS += \
221         test-help.sh \
222         test-version.sh \
223         test-dump-config.sh \
224         $(NULL)
226 if HAVE_PLUGINS
228 TESTS += \
229         test-help-plugin.sh \
230         test-version-plugin.sh \
231         test-version-filter.sh \
232         test-dump-plugin.sh \
233         test-start.sh \
234         test-single.sh \
235         test-single-from-file.sh \
236         test-captive.sh \
237         test-random-sock.sh \
238         test-tls.sh \
239         test-tls-psk.sh \
240         test-ip.sh \
241         test-socket-activation \
242         test-foreground.sh \
243         test-debug-flags.sh \
244         test-long-name.sh \
245         test-swap.sh \
246         $(NULL)
248 check_PROGRAMS += \
249         test-socket-activation \
250         $(NULL)
252 test_socket_activation_SOURCES = test-socket-activation.c
253 test_socket_activation_CPPFLAGS = \
254         -I$(top_srcdir)/common/include \
255         -I$(top_srcdir)/common/protocol \
256         $(NULL)
257 test_socket_activation_CFLAGS = $(WARNINGS_CFLAGS)
259 endif HAVE_PLUGINS
261 # Test the header files can be included on their own.
262 check_PROGRAMS += \
263         test-just-plugin-header \
264         test-just-filter-header
265         $(NULL)
266 TESTS += \
267         test-just-plugin-header \
268         test-just-filter-header
269         $(NULL)
271 test_just_plugin_header_SOURCES = \
272         test-just-plugin-header.c \
273         $(NULL)
274 test_just_plugin_header_CPPFLAGS = \
275         -I$(top_srcdir)/include \
276         $(NULL)
277 test_just_plugin_header_CFLAGS = $(WARNINGS_CFLAGS)
279 test_just_filter_header_SOURCES = \
280         test-just-filter-header.c \
281         $(NULL)
282 test_just_filter_header_CPPFLAGS = \
283         -I$(top_srcdir)/include \
284         $(NULL)
285 test_just_filter_header_CFLAGS = $(WARNINGS_CFLAGS)
287 if CAN_TEST_ANSI_C
288 # This builds a plugin using an ANSI (ISO C90) compiler to ensure that
289 # the header file is compatible.  The plugin does nothing very
290 # interesting, it's mainly a compile test.
291 TESTS += \
292         test-ansi-c.sh \
293         $(NULL)
294 # check_LTLIBRARIES won't build a shared library (see automake manual).
295 # So we have to do this and add a dependency.
296 noinst_LTLIBRARIES += test-ansi-c-plugin.la
297 test-ansi-c.sh: test-ansi-c-plugin.la
299 test_ansi_c_plugin_la_SOURCES = \
300         test-ansi-c-plugin.c \
301         $(top_srcdir)/include/nbdkit-plugin.h \
302         $(NULL)
303 test_ansi_c_plugin_la_CPPFLAGS = \
304         -std=c90 -pedantic \
305         -I$(top_srcdir)/include \
306         $(NULL)
307 test_ansi_c_plugin_la_CFLAGS = $(WARNINGS_CFLAGS)
308 # For use of the -rpath option, see:
309 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
310 test_ansi_c_plugin_la_LDFLAGS = \
311         -module -avoid-version -shared -rpath /nowhere \
312         $(NULL)
313 endif CAN_TEST_ANSI_C
315 if HAVE_CXX
316 # This builds a plugin and a filter using the C++ compiler.  They
317 # don't do anything interesting when run.
318 TESTS += \
319         test-cxx.sh \
320         $(NULL)
321 # check_LTLIBRARIES won't build a shared library (see automake manual).
322 # So we have to do this and add a dependency.
323 noinst_LTLIBRARIES += test-cxx-plugin.la test-cxx-filter.la
324 test-cxx.sh: test-cxx-plugin.la test-cxx-filter.la
326 test_cxx_plugin_la_SOURCES = \
327         test-cxx-plugin.cpp \
328         $(top_srcdir)/include/nbdkit-plugin.h \
329         $(NULL)
330 test_cxx_plugin_la_CPPFLAGS = \
331         -I$(top_srcdir)/include \
332         $(NULL)
333 test_cxx_plugin_la_CXXFLAGS = $(WARNINGS_CFLAGS)
334 # For use of the -rpath option, see:
335 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
336 test_cxx_plugin_la_LDFLAGS = \
337         -module -avoid-version -shared -rpath /nowhere \
338         $(NULL)
340 test_cxx_filter_la_SOURCES = \
341         test-cxx-filter.cpp \
342         $(top_srcdir)/include/nbdkit-filter.h \
343         $(NULL)
344 test_cxx_filter_la_CPPFLAGS = \
345         -I$(top_srcdir)/include \
346         $(NULL)
347 test_cxx_filter_la_CXXFLAGS = $(WARNINGS_CFLAGS)
348 # For use of the -rpath option, see:
349 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
350 test_cxx_filter_la_LDFLAGS = \
351         -module -avoid-version -shared -rpath /nowhere \
352         $(NULL)
353 endif HAVE_CXX
355 # Exit with parent test.
356 check_PROGRAMS += test-exit-with-parent
357 TESTS += test-exit-with-parent
359 test_exit_with_parent_SOURCES = \
360         test-exit-with-parent.c test.h \
361         $(NULL)
362 test_exit_with_parent_CPPFLAGS = \
363         -I$(top_srcdir)/common/include \
364         $(NULL)
365 test_exit_with_parent_CFLAGS = \
366         $(WARNINGS_CFLAGS) \
367         $(LIBGUESTFS_CFLAGS) \
368         $(NULL)
370 # PKI files for the TLS tests.
371 check_DATA += pki/.stamp
372 pki/.stamp: $(srcdir)/make-pki.sh
373         SRCDIR=$(srcdir) $(srcdir)/make-pki.sh
375 # PSK keys for the TLS-PSK tests.
376 check_DATA += keys.psk
377 keys.psk: $(srcdir)/make-psk.sh
378         SRCDIR=$(srcdir) $(srcdir)/make-psk.sh
380 # Keys are expensive to recreate so only delete them when we do
381 # â€˜make distclean’.
382 DISTCLEANFILES = keys.psk
383 distclean-local: distclean-local-tls
384 distclean-local-tls:
385         rm -rf pki
387 #----------------------------------------------------------------------
388 # Tests of C plugins or tests which require plugins.
390 if HAVE_PLUGINS
392 # Common data shared by multiple tests
393 check_DATA += file-data
394 CLEANFILES += file-data
395 file-data: generate-file-data.sh
396         $(srcdir)/generate-file-data.sh $@
398 # While most tests need libguestfs, testing parallel I/O is easier when
399 # using qemu-io to kick off asynchronous requests.
400 TESTS += \
401         test-parallel-file.sh \
402         test-parallel-nbd.sh \
403         test-parallel-sh.sh \
404         $(NULL)
406 # Common test library.
407 check_LTLIBRARIES += libtest.la
408 libtest_la_SOURCES = test.c test.h
409 libtest_la_CFLAGS = $(WARNINGS_CFLAGS)
411 # Basic connection test.
412 LIBNBD_TESTS += test-connect
414 test_connect_SOURCES = test-connect.c
415 test_connect_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
416 test_connect_LDADD = $(LIBNBD_LIBS)
418 # newstyle protocol test.
419 LIBNBD_TESTS += test-newstyle
421 test_newstyle_SOURCES = test-newstyle.c
422 test_newstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
423 test_newstyle_LDADD = $(LIBNBD_LIBS)
425 # oldstyle protocol test.
426 LIBNBD_TESTS += test-oldstyle
428 test_oldstyle_SOURCES = test-oldstyle.c
429 test_oldstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
430 test_oldstyle_LDADD = $(LIBNBD_LIBS)
432 # Test export flags.
433 TESTS += test-eflags.sh
435 # Test export name.
436 TESTS += test-export-name.sh
438 # common disk image shared with several tests
439 check_DATA += disk
440 CLEANFILES += disk
442 disk:
443         rm -rf disk.tmp $@ $@-t
444         mkdir disk.tmp
445         echo -n "hello,world" > disk.tmp/hello.txt
446         nbdkit -fv -U - linuxdisk disk.tmp size=100M \
447             --run 'qemu-img convert $$nbd $@-t'
448         rm -rf disk.tmp
449         mv $@-t $@
451 # curl plugin test.
452 if HAVE_CURL
453 LIBGUESTFS_TESTS += test-curl
455 test_curl_SOURCES = \
456         test-curl.c \
457         web-server.c \
458         web-server.h \
459         test.h \
460         $(NULL)
461 test_curl_CPPFLAGS = \
462         -I$(top_srcdir)/common/utils
463 test_curl_CFLAGS = \
464         $(WARNINGS_CFLAGS) \
465         $(LIBGUESTFS_CFLAGS) \
466         $(PTHREAD_CFLAGS) \
467         $(NULL)
468 test_curl_LDFLAGS = \
469         $(top_builddir)/common/utils/libutils.la \
470         $(PTHREAD_LIBS) \
471         $(NULL)
472 test_curl_LDADD = \
473         libtest.la \
474         $(LIBGUESTFS_LIBS) \
475         $(NULL)
476 endif HAVE_CURL
478 # data plugin test.
479 LIBGUESTFS_TESTS += test-data
480 TESTS += \
481         test-data-7E.sh \
482         test-data-base64.sh \
483         test-data-extents.sh \
484         test-data-file.sh \
485         test-data-raw.sh \
486         $(NULL)
488 test_data_SOURCES = test-data.c test.h
489 test_data_CPPFLAGS = -I$(top_srcdir)/common/include
490 test_data_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
491 test_data_LDADD = libtest.la $(LIBGUESTFS_LIBS)
493 # ext2 plugin test.
494 if HAVE_EXT2
495 if HAVE_GUESTFISH
497 LIBGUESTFS_TESTS += test-ext2
498 check_DATA += ext2.img
499 CLEANFILES += ext2.img
501 ext2.img: disk
502         rm -f $@ $@-t
503         guestfish \
504             sparse $@-t 2G : \
505             run : \
506             mkfs ext4 /dev/sda : \
507             mount /dev/sda / : \
508             mkdir /disks : \
509             upload $< /disks/disk.img
510         mv $@-t $@
512 test_ext2_SOURCES = test-ext2.c test.h
513 test_ext2_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
514 test_ext2_LDADD = libtest.la $(LIBGUESTFS_LIBS)
516 endif HAVE_GUESTFISH
517 endif HAVE_EXT2
519 # file plugin test.
520 LIBNBD_TESTS += test-file
521 LIBGUESTFS_TESTS += test-file-block
523 test_file_SOURCES = test-file.c
524 test_file_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
525 test_file_LDADD = $(LIBNBD_LIBS)
527 test_file_block_SOURCES = test-file-block.c test.h
528 test_file_block_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
529 test_file_block_LDADD = libtest.la $(LIBGUESTFS_LIBS)
531 TESTS += test-file-extents.sh
533 # floppy plugin test.
534 TESTS += test-floppy.sh
536 # full plugin test.
537 TESTS += test-full.sh
539 # gzip plugin test.
540 if HAVE_ZLIB
541 LIBGUESTFS_TESTS += test-gzip
542 check_DATA += disk.gz
543 CLEANFILES += disk.gz
545 test_gzip_SOURCES = test-gzip.c test.h
546 test_gzip_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
547 test_gzip_LDADD = libtest.la $(LIBGUESTFS_LIBS)
549 disk.gz: disk
550         rm -f $@
551         gzip -9 -c disk > $@
552 endif HAVE_ZLIB
554 # info plugin test.
555 TESTS += \
556         test-info-address.sh \
557         test-info-base64.sh \
558         test-info-raw.sh \
559         test-info-time.sh \
560         test-info-uptime.sh \
561         test-info-conntime.sh \
562         $(NULL)
564 # iso plugin test.
565 if HAVE_ISO
566 TESTS += test-iso.sh
567 endif HAVE_ISO
569 # linuxdisk plugin test.
570 TESTS += \
571         test-linuxdisk.sh \
572         test-linuxdisk-copy-out.sh \
573         $(NULL)
575 # memory plugin test.
576 LIBGUESTFS_TESTS += test-memory
577 TESTS += test-memory-largest.sh test-memory-largest-for-qemu.sh
579 test_memory_SOURCES = test-memory.c test.h
580 test_memory_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
581 test_memory_LDADD = libtest.la $(LIBGUESTFS_LIBS)
583 # partitioning plugin test.
584 TESTS += \
585         test-partitioning1.sh \
586         test-partitioning2.sh \
587         test-partitioning3.sh \
588         test-partitioning4.sh \
589         test-partitioning5.sh \
590         test-partitioning6.sh \
591         $(NULL)
593 # pattern plugin test.
594 TESTS += \
595         test-pattern.sh \
596         test-pattern-largest.sh \
597         test-pattern-largest-for-qemu.sh \
598         $(NULL)
600 if HAVE_NBD_PLUGIN
601 # nbd plugin test.
602 LIBGUESTFS_TESTS += test-nbd
603 TESTS += \
604         test-nbd-extents.sh \
605         test-nbd-tls.sh \
606         test-nbd-tls-psk.sh \
607         $(NULL)
609 test_nbd_SOURCES = test-nbd.c test.h
610 test_nbd_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
611 test_nbd_LDADD = libtest.la $(LIBGUESTFS_LIBS)
612 endif HAVE_NBD_PLUGIN
614 # null plugin test.
615 LIBNBD_TESTS += test-null
616 TESTS += test-null-extents.sh
618 test_null_SOURCES = test-null.c
619 test_null_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
620 test_null_LDADD = $(LIBNBD_LIBS)
622 # random plugin test.
623 LIBNBD_TESTS += test-random
625 test_random_SOURCES = test-random.c
626 test_random_CPPFLAGS = -I $(top_srcdir)/common/include
627 test_random_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
628 test_random_LDADD = $(LIBNBD_LIBS)
630 # split files plugin test.
631 check_DATA += split1 split2 split3
632 CLEANFILES += split1 split2 split3
633 split1: file-data
634         rm -f $@ $@-t
635         dd if=$< of=$@-t bs=1 count=100
636         mv $@-t $@
637 split2: file-data
638         rm -f $@ $@-t
639         dd if=$< of=$@-t bs=1 count=100 skip=100
640         mv $@-t $@
641 split3: file-data
642         rm -f $@ $@-t
643         dd if=$< of=$@-t bs=1 skip=200
644         mv $@-t $@
645 LIBNBD_TESTS += test-split
647 test_split_SOURCES = test-split.c
648 test_split_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
649 test_split_LDADD = $(LIBNBD_LIBS)
651 # ssh plugin test.
652 if HAVE_SSH
653 # Uses â€˜disk’ so we have to make it conditional on guestfish.
654 TESTS += test-ssh.sh
655 check_DATA += \
656         ssh/sshd_config \
657         ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub \
658         ssh/authorized_keys \
659         $(NULL)
660 SSH_RANDOM_PORT := $(shell bash -c 'echo $$(( 10000 + $$RANDOM ))')
661 CLEANFILES += \
662         ssh/*~ \
663         ssh/sshd_config \
664         ssh/authorized_keys \
665         $(NULL)
666 DISTCLEANFILES += \
667         ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub \
668         ssh/id_rsa ssh/id_rsa.pub \
669         stamp-ssh-host-key stamp-ssh-user-key \
670         $(NULL)
672 ssh/sshd_config: ssh/sshd_config.in Makefile
673         rm -f $@ $@-t
674         $(SED) \
675             -e 's,__abs_builddir__,$(abs_builddir),g' \
676             -e 's,__RANDOM_PORT__,$(SSH_RANDOM_PORT),g' \
677             < $< > $@-t
678         mv $@-t $@
680 ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub: stamp-ssh-host-key
681 stamp-ssh-host-key:
682         rm -f $@
683         rm -f ssh/ssh_host_rsa_key
684         rm -f ssh/ssh_host_rsa_key.pub
685         ssh-keygen -t rsa -f ssh/ssh_host_rsa_key -N ''
686         touch $@
688 ssh/authorized_keys: ssh/id_rsa.pub
689         rm -f $@ $@-t
690         cp $< $@-t
691         mv $@-t $@
693 ssh/id_rsa ssh/id_rsa.pub: stamp-ssh-user-key
694 stamp-ssh-user-key:
695         rm -f $@
696         rm -f ssh/id_rsa
697         rm -f ssh/id_rsa.pub
698         ssh-keygen -t rsa -f ssh/id_rsa -N ''
699         touch $@
700 endif HAVE_SSH
702 # streaming plugin test.
703 # Doesn't work:
704 LIBNBD_TESTS += test-streaming
706 test_streaming_SOURCES = test-streaming.c
707 test_streaming_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
708 test_streaming_LDADD = $(LIBNBD_LIBS)
710 if HAVE_VDDK
711 # VDDK plugin test.
712 # This only tests that the plugin can be loaded against a
713 # dummy VDDK library, it is not a detailed test.
715 # check_LTLIBRARIES won't build a shared library (see automake manual).
716 # So we have to do this and add a dependency.
717 noinst_LTLIBRARIES += libvixDiskLib.la
718 TESTS += \
719         test-vddk.sh \
720         test-vddk-real.sh \
721         $(NULL)
723 libvixDiskLib_la_SOURCES = \
724         dummy-vddk.c \
725         $(NULL)
726 libvixDiskLib_la_CPPFLAGS = \
727         -I$(top_srcdir)/plugins/vddk \
728         $(NULL)
729 libvixDiskLib_la_CXXFLAGS = $(WARNINGS_CFLAGS)
730 # For use of the -rpath option, see:
731 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
732 libvixDiskLib_la_LDFLAGS = \
733         -shared -version-number 6:0:0 -rpath /nowhere \
734         $(NULL)
735 endif HAVE_VDDK
737 # zero plugin test.
738 TESTS += test-zero.sh
740 #----------------------------------------------------------------------
741 # Tests of language plugins.
743 # OCaml plugin test.
744 if HAVE_OCAML
746 LIBGUESTFS_TESTS += test-ocaml
748 # This is somewhat different from the other tests because we have
749 # to build an actual plugin here.
750 test_ocaml_SOURCES = test-ocaml.c test.h
751 test_ocaml_CFLAGS = \
752         $(WARNINGS_CFLAGS) \
753         $(LIBGUESTFS_CFLAGS) \
754         $(NULL)
755 test_ocaml_LDADD = libtest.la $(LIBGUESTFS_LIBS)
757 check_SCRIPTS += test-ocaml-plugin.so
758 test-ocaml-plugin.so: test_ocaml_plugin.cmx ../plugins/ocaml/libnbdkitocaml.la ../plugins/ocaml/NBDKit.cmi ../plugins/ocaml/NBDKit.cmx
759         $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../plugins/ocaml \
760           -output-obj -runtime-variant _pic -o $@ \
761           NBDKit.cmx $< \
762           -cclib -L../plugins/ocaml/.libs -cclib -lnbdkitocaml
763 test_ocaml_plugin.cmx: test_ocaml_plugin.ml ../plugins/ocaml/NBDKit.cmi
764         $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../plugins/ocaml -c $< -o $@
766 endif HAVE_OCAML
768 # perl plugin test.
769 if HAVE_PERL
771 TESTS += \
772         test-dump-plugin-example4.sh \
773         test-shebang-perl.sh \
774         $(NULL)
775 LIBGUESTFS_TESTS += test-perl
777 test_perl_SOURCES = test-lang-plugins.c test.h
778 test_perl_CFLAGS = \
779         -DLANG='"perl"' -DSCRIPT='"$(srcdir)/test.pl"' \
780         $(WARNINGS_CFLAGS) \
781         $(LIBGUESTFS_CFLAGS) \
782         $(NULL)
783 test_perl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
785 endif HAVE_PERL
787 # python plugin test.
788 if HAVE_PYTHON
790 TESTS += \
791         test-python-exception.sh \
792         test-shebang-python.sh \
793         $(NULL)
794 LIBGUESTFS_TESTS += test-python
796 test_python_SOURCES = test-lang-plugins.c test.h
797 test_python_CFLAGS = \
798         -DLANG='"python"' -DSCRIPT='"$(srcdir)/test.py"' \
799         $(WARNINGS_CFLAGS) \
800         $(LIBGUESTFS_CFLAGS) \
801         $(NULL)
802 test_python_LDADD = libtest.la $(LIBGUESTFS_LIBS)
804 endif HAVE_PYTHON
806 # Ruby plugin test.
807 if HAVE_RUBY
809 # Ruby tests are disabled.  See "WARNING" section in
810 # plugins/ruby/nbdkit-ruby-plugin.pod
812 #LIBGUESTFS_TESTS += \
813 #       test-ruby \
814 #       $(NULL)
815 #TESTS += test-shebang-ruby.sh
816 EXTRA_PROGRAMS += test-ruby
818 test_ruby_SOURCES = test-lang-plugins.c test.h
819 test_ruby_CFLAGS = \
820         -DLANG='"ruby"' -DSCRIPT='"$(srcdir)/test.rb"' \
821         $(WARNINGS_CFLAGS) \
822         $(LIBGUESTFS_CFLAGS) \
823         $(NULL)
824 test_ruby_LDADD = libtest.la $(LIBGUESTFS_LIBS)
826 endif HAVE_RUBY
828 # Shell (sh) plugin test.
829 LIBGUESTFS_TESTS += test-shell
830 check_DATA += test-shell.img
831 CLEANFILES += test-shell.img
833 test_shell_SOURCES = test-lang-plugins.c test.h
834 test_shell_CFLAGS = \
835         -DLANG='"sh"' -DSCRIPT='"$(srcdir)/test-shell.sh"' \
836         $(WARNINGS_CFLAGS) \
837         $(LIBGUESTFS_CFLAGS) \
838         $(NULL)
839 test_shell_LDADD = libtest.la $(LIBGUESTFS_LIBS)
841 test-shell.img:
842         truncate -s 1048576 $@
844 TESTS += \
845         test-sh-errors.sh \
846         test-sh-extents.sh \
847         $(NULL)
849 # Tcl plugin test.
850 if HAVE_TCL
852 LIBGUESTFS_TESTS += test-tcl
854 test_tcl_SOURCES = test-lang-plugins.c test.h
855 test_tcl_CFLAGS = \
856         -DLANG='"tcl"' -DSCRIPT='"$(srcdir)/test.tcl"' \
857         $(WARNINGS_CFLAGS) \
858         $(LIBGUESTFS_CFLAGS) \
859         $(NULL)
860 test_tcl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
862 endif HAVE_TCL
864 # Lua plugin test.
865 if HAVE_LUA
867 LIBGUESTFS_TESTS += test-lua
869 test_lua_SOURCES = test-lang-plugins.c test.h
870 test_lua_CFLAGS = \
871         -DLANG='"lua"' -DSCRIPT='"$(srcdir)/test.lua"' \
872         $(WARNINGS_CFLAGS) \
873         $(LIBGUESTFS_CFLAGS) \
874         $(NULL)
875 test_lua_LDADD = libtest.la $(LIBGUESTFS_LIBS)
877 endif HAVE_LUA
879 #----------------------------------------------------------------------
880 # Tests of filters.
882 # Generic test of filter layers.
883 check_PROGRAMS += test-layers
884 TESTS += test-layers.sh test-layers
886 test_layers_SOURCES = \
887         test-layers.c \
888         $(NULL)
889 test_layers_CPPFLAGS = \
890         -I$(top_srcdir)/common/include \
891         -I$(top_srcdir)/common/protocol \
892         -I$(top_srcdir)/common/utils \
893         -I$(top_srcdir)/server \
894         $(NULL)
895 test_layers_CFLAGS = \
896         $(WARNINGS_CFLAGS) \
897         $(PTHREAD_CFLAGS) \
898         $(NULL)
899 test_layers_LDFLAGS = \
900         $(PTHREAD_LIBS) \
901         $(NULL)
902 test_layers_LDADD = \
903         $(top_builddir)/common/utils/libutils.la \
904         $(NULL)
905 test_layers_DEPENDENCIES = \
906         test-layers-plugin.la \
907         test-layers-filter1.la \
908         test-layers-filter2.la \
909         test-layers-filter3.la \
910         $(NULL)
912 # check_LTLIBRARIES won't build a shared library (see automake manual).
913 # So we have to do this and add a dependency.
914 noinst_LTLIBRARIES += \
915         test-layers-plugin.la \
916         test-layers-filter1.la \
917         test-layers-filter2.la \
918         test-layers-filter3.la \
919         $(NULL)
921 test_layers_plugin_la_SOURCES = \
922         test-layers-plugin.c \
923         $(top_srcdir)/include/nbdkit-plugin.h \
924         $(NULL)
925 test_layers_plugin_la_CPPFLAGS = -I$(top_srcdir)/include
926 test_layers_plugin_la_CFLAGS = $(WARNINGS_CFLAGS)
927 # For use of the -rpath option, see:
928 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
929 test_layers_plugin_la_LDFLAGS = \
930         -module -avoid-version -shared -rpath /nowhere \
931         $(NULL)
933 test_layers_filter1_la_SOURCES = \
934         test-layers-filter.c \
935         $(top_srcdir)/include/nbdkit-filter.h \
936         $(NULL)
937 test_layers_filter1_la_CPPFLAGS = -I$(top_srcdir)/include
938 test_layers_filter1_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter1"'
939 # For use of the -rpath option, see:
940 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
941 test_layers_filter1_la_LDFLAGS = \
942         -module -avoid-version -shared -rpath /nowhere \
943         $(NULL)
945 test_layers_filter2_la_SOURCES = \
946         test-layers-filter.c \
947         $(top_srcdir)/include/nbdkit-filter.h \
948         $(NULL)
949 test_layers_filter2_la_CPPFLAGS = -I$(top_srcdir)/include
950 test_layers_filter2_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter2"'
951 # For use of the -rpath option, see:
952 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
953 test_layers_filter2_la_LDFLAGS = \
954         -module -avoid-version -shared -rpath /nowhere \
955         $(NULL)
957 test_layers_filter3_la_SOURCES = \
958         test-layers-filter.c \
959         $(top_srcdir)/include/nbdkit-filter.h \
960         $(NULL)
961 test_layers_filter3_la_CPPFLAGS = -I$(top_srcdir)/include
962 test_layers_filter3_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter3"'
963 # For use of the -rpath option, see:
964 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
965 test_layers_filter3_la_LDFLAGS = \
966         -module -avoid-version -shared -rpath /nowhere \
967         $(NULL)
969 # blocksize filter test.
970 TESTS += test-blocksize.sh
972 # cache filter test.
973 TESTS += \
974         test-cache.sh \
975         test-cache-on-read.sh \
976         $(NULL)
977 TESTS += test-cache-max-size.sh
979 # cacheextents filter test.
980 TESTS += test-cacheextents.sh
982 # cow filter test.
983 TESTS += \
984         test-cow.sh \
985         test-cow-null.sh \
986         $(NULL)
988 # delay filter tests.
989 TESTS += test-shutdown.sh
990 LIBNBD_TESTS += test-delay
992 test_delay_SOURCES = test-delay.c
993 test_delay_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
994 test_delay_LDADD = $(LIBNBD_LIBS)
996 # error filter test.
997 TESTS += \
998         test-error0.sh \
999         test-error10.sh \
1000         test-error100.sh \
1001         test-error-triggered.sh \
1002         $(NULL)
1004 # fua filter test.
1005 TESTS += test-fua.sh
1007 # ip filter test.
1008 TESTS += test-ip-filter.sh
1010 # log filter test.
1011 TESTS += test-log.sh
1013 if HAVE_NBD_PLUGIN
1014 # nozero filter test.
1015 TESTS += test-nozero.sh
1016 endif HAVE_NBD_PLUGIN
1018 # offset filter test.
1019 LIBGUESTFS_TESTS += test-offset
1021 test_offset_SOURCES = test-offset.c test.h
1022 test_offset_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
1023 test_offset_LDADD = libtest.la $(LIBGUESTFS_LIBS)
1025 TESTS += \
1026         test-offset2.sh \
1027         test-offset-extents.sh \
1028         $(NULL)
1030 # partition filter test.
1031 TESTS += test-partition1.sh
1032 TESTS += test-partition2.sh
1034 # rate filter test.
1035 TESTS += \
1036         test-rate.sh \
1037         test-rate-dynamic.sh \
1038         $(NULL)
1040 # readahead filter test.
1041 LIBGUESTFS_TESTS += test-readahead
1042 TESTS += test-readahead-copy.sh
1044 test_readahead_SOURCES = test-readahead.c test.h
1045 test_readahead_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
1046 test_readahead_LDADD = libtest.la $(LIBGUESTFS_LIBS)
1048 # retry filter test.
1049 TESTS += \
1050         test-retry.sh \
1051         test-retry-readonly.sh \
1052         test-retry-extents.sh \
1053         test-retry-size.sh \
1054         test-retry-reopen-fail.sh \
1055         test-retry-zero-flags.sh \
1056         $(NULL)
1058 # truncate filter tests.
1059 TESTS += \
1060         test-truncate1.sh \
1061         test-truncate2.sh \
1062         test-truncate3.sh \
1063         test-truncate4.sh \
1064         test-truncate-extents.sh \
1065         $(NULL)
1067 # xz filter test.
1068 if HAVE_LIBLZMA
1069 LIBGUESTFS_TESTS += test-xz
1070 check_DATA += disk.xz
1071 CLEANFILES += disk.xz
1073 test_xz_SOURCES = test-xz.c test.h
1074 test_xz_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
1075 test_xz_LDADD = libtest.la $(LIBGUESTFS_LIBS)
1077 disk.xz: disk
1078         rm -f $@
1079 # We choose a very small block size here only for testing.  Normally
1080 # you should choose a 16M block size.
1081         xz --best --block-size=32768 -c disk > $@
1083 # xz filter + curl.
1084 if HAVE_CURL
1085 LIBGUESTFS_TESTS += test-xz-curl
1087 test_xz_curl_SOURCES = \
1088         test-xz-curl.c \
1089         web-server.c \
1090         web-server.h \
1091         test.h \
1092         $(NULL)
1093 test_xz_curl_CPPFLAGS = \
1094         -I$(top_srcdir)/common/utils
1095 test_xz_curl_CFLAGS = \
1096         $(WARNINGS_CFLAGS) \
1097         $(LIBGUESTFS_CFLAGS) \
1098         $(PTHREAD_CFLAGS) \
1099         $(NULL)
1100 test_xz_curl_LDFLAGS = \
1101         $(top_builddir)/common/utils/libutils.la \
1102         $(PTHREAD_LIBS) \
1103         $(NULL)
1104 test_xz_curl_LDADD = \
1105         libtest.la \
1106         $(LIBGUESTFS_LIBS) \
1107         $(NULL)
1109 endif HAVE_CURL
1110 endif HAVE_LIBLZMA
1112 endif HAVE_PLUGINS
1114 #----------------------------------------------------------------------
1116 if HAVE_LIBNBD
1117 check_PROGRAMS += $(LIBNBD_TESTS)
1118 TESTS += $(LIBNBD_TESTS)
1119 endif HAVE_LIBNBD
1121 if HAVE_LIBGUESTFS
1122 check_PROGRAMS += $(LIBGUESTFS_TESTS)
1123 TESTS += $(LIBGUESTFS_TESTS)
1124 endif HAVE_LIBGUESTFS