tests/test-captive.sh: Increase sleep times.
[nbdkit/ericb.git] / tests / Makefile.am
blob558ea86f1f7c26bd58592dd6c5863480478db362
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-export-name.sh \
69         test-file-extents.sh \
70         test-floppy.sh \
71         test-foreground.sh \
72         test-fua.sh \
73         test-full.sh \
74         test-help.sh \
75         test-help-plugin.sh \
76         test-info-address.sh \
77         test-info-base64.sh \
78         test-info-raw.sh \
79         test-info-time.sh \
80         test-info-uptime.sh \
81         test-info-conntime.sh \
82         test-ip.sh \
83         test-iso.sh \
84         test-layers.sh \
85         test-linuxdisk.sh \
86         test-linuxdisk-copy-out.sh \
87         test-log.sh \
88         test-long-name.sh \
89         test.lua \
90         test-memory-largest.sh \
91         test-memory-largest-for-qemu.sh \
92         test-nbd-extents.sh \
93         test-nbd-tls.sh \
94         test-nbd-tls-psk.sh \
95         test-nozero.sh \
96         test-null-extents.sh \
97         test_ocaml_plugin.ml \
98         test-ocaml.c \
99         test-offset2.sh \
100         test-offset-extents.sh \
101         test-parallel-file.sh \
102         test-parallel-nbd.sh \
103         test-parallel-sh.sh \
104         test-partition1.sh \
105         test-partition2.sh \
106         test-partitioning1.sh \
107         test-partitioning2.sh \
108         test-partitioning3.sh \
109         test-partitioning4.sh \
110         test-partitioning5.sh \
111         test-partitioning6.sh \
112         test-pattern.sh \
113         test-pattern-largest.sh \
114         test-pattern-largest-for-qemu.sh \
115         test-python-exception.sh \
116         test.pl \
117         test.py \
118         test-rate.sh \
119         test-rate-dynamic.sh \
120         test.rb \
121         test-readahead-copy.sh \
122         test-retry.sh \
123         test-retry-extents.sh \
124         test-retry-size.sh \
125         test-retry-readonly.sh \
126         test-retry-reopen-fail.sh \
127         test-retry-zero-flags.sh \
128         test-shutdown.sh \
129         test-ssh.sh \
130         test.tcl \
131         test-shebang-perl.sh \
132         test-shebang-python.sh \
133         test-shebang-ruby.sh \
134         test-shell.sh \
135         test-sh-errors.sh \
136         test-sh-extents.sh \
137         test-single.sh \
138         test-single-from-file.sh \
139         test-start.sh \
140         test-random-sock.sh \
141         test-tls.sh \
142         test-tls-psk.sh \
143         test-truncate1.sh \
144         test-truncate2.sh \
145         test-truncate3.sh \
146         test-truncate4.sh \
147         test-truncate-extents.sh \
148         test-vddk.sh \
149         test-vddk-real.sh \
150         test-version.sh \
151         test-version-filter.sh \
152         test-version-plugin.sh \
153         test-zero.sh \
154         $(NULL)
156 # Use 'make check' to run the ordinary tests.  To run all the tests
157 # under valgrind, use the following rule:
158 check-valgrind:
159         NBDKIT_VALGRIND=1 $(MAKE) check
161 # To run only tests which require root, use:
162 check-root:
163         $(MAKE) check TESTS="test-file-block"
165 # Run a basic check against a real copy of VDDK.  You must set
166 # vddkdir to point to the library location, eg:
168 #   make check-vddk vddkdir=vmware-vix-disklib-distrib
169 check-vddk:
170         $(MAKE) check TESTS=test-vddk-real.sh
172 #----------------------------------------------------------------------
173 # Basic server command line and start-up tests.
175 check_PROGRAMS =
176 check_DATA =
177 check_SCRIPTS =
178 check_LTLIBRARIES =
179 noinst_LTLIBRARIES =
181 # Ensure we're testing the local copy by running everything through
182 # the nbdkit helper script in the top build directory.
183 TESTS_ENVIRONMENT = PATH=$(abs_top_builddir):$(PATH) SRCDIR=$(srcdir)
185 TESTS = \
186         test-help.sh \
187         test-version.sh \
188         test-dump-config.sh \
189         $(NULL)
191 if HAVE_PLUGINS
193 TESTS += \
194         test-help-plugin.sh \
195         test-version-plugin.sh \
196         test-version-filter.sh \
197         test-dump-plugin.sh \
198         test-start.sh \
199         test-single.sh \
200         test-single-from-file.sh \
201         test-captive.sh \
202         test-random-sock.sh \
203         test-tls.sh \
204         test-tls-psk.sh \
205         test-ip.sh \
206         test-socket-activation \
207         test-foreground.sh \
208         test-debug-flags.sh \
209         test-long-name.sh \
210         $(NULL)
212 check_PROGRAMS += \
213         test-socket-activation \
214         $(NULL)
216 test_socket_activation_SOURCES = test-socket-activation.c
217 test_socket_activation_CPPFLAGS = \
218         -I$(top_srcdir)/common/protocol \
219         $(NULL)
220 test_socket_activation_CFLAGS = $(WARNINGS_CFLAGS)
222 endif HAVE_PLUGINS
224 # Test the header files can be included on their own.
225 check_PROGRAMS += \
226         test-just-plugin-header \
227         test-just-filter-header
228         $(NULL)
229 TESTS += \
230         test-just-plugin-header \
231         test-just-filter-header
232         $(NULL)
234 test_just_plugin_header_SOURCES = \
235         test-just-plugin-header.c \
236         $(NULL)
237 test_just_plugin_header_CPPFLAGS = \
238         -I$(top_srcdir)/include \
239         $(NULL)
240 test_just_plugin_header_CFLAGS = $(WARNINGS_CFLAGS)
242 test_just_filter_header_SOURCES = \
243         test-just-filter-header.c \
244         $(NULL)
245 test_just_filter_header_CPPFLAGS = \
246         -I$(top_srcdir)/include \
247         $(NULL)
248 test_just_filter_header_CFLAGS = $(WARNINGS_CFLAGS)
250 if CAN_TEST_ANSI_C
251 # This builds a plugin using an ANSI (ISO C90) compiler to ensure that
252 # the header file is compatible.  The plugin does nothing very
253 # interesting, it's mainly a compile test.
254 TESTS += \
255         test-ansi-c.sh \
256         $(NULL)
257 # check_LTLIBRARIES won't build a shared library (see automake manual).
258 # So we have to do this and add a dependency.
259 noinst_LTLIBRARIES += test-ansi-c-plugin.la
260 test-ansi-c.sh: test-ansi-c-plugin.la
262 test_ansi_c_plugin_la_SOURCES = \
263         test-ansi-c-plugin.c \
264         $(top_srcdir)/include/nbdkit-plugin.h \
265         $(NULL)
266 test_ansi_c_plugin_la_CPPFLAGS = \
267         -std=c90 -pedantic \
268         -I$(top_srcdir)/include \
269         $(NULL)
270 test_ansi_c_plugin_la_CFLAGS = $(WARNINGS_CFLAGS)
271 # For use of the -rpath option, see:
272 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
273 test_ansi_c_plugin_la_LDFLAGS = \
274         -module -avoid-version -shared -rpath /nowhere \
275         $(NULL)
276 endif CAN_TEST_ANSI_C
278 if HAVE_CXX
279 # This builds a plugin and a filter using the C++ compiler.  They
280 # don't do anything interesting when run.
281 TESTS += \
282         test-cxx.sh \
283         $(NULL)
284 # check_LTLIBRARIES won't build a shared library (see automake manual).
285 # So we have to do this and add a dependency.
286 noinst_LTLIBRARIES += test-cxx-plugin.la test-cxx-filter.la
287 test-cxx.sh: test-cxx-plugin.la test-cxx-filter.la
289 test_cxx_plugin_la_SOURCES = \
290         test-cxx-plugin.cpp \
291         $(top_srcdir)/include/nbdkit-plugin.h \
292         $(NULL)
293 test_cxx_plugin_la_CPPFLAGS = \
294         -I$(top_srcdir)/include \
295         $(NULL)
296 test_cxx_plugin_la_CXXFLAGS = $(WARNINGS_CFLAGS)
297 # For use of the -rpath option, see:
298 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
299 test_cxx_plugin_la_LDFLAGS = \
300         -module -avoid-version -shared -rpath /nowhere \
301         $(NULL)
303 test_cxx_filter_la_SOURCES = \
304         test-cxx-filter.cpp \
305         $(top_srcdir)/include/nbdkit-filter.h \
306         $(NULL)
307 test_cxx_filter_la_CPPFLAGS = \
308         -I$(top_srcdir)/include \
309         $(NULL)
310 test_cxx_filter_la_CXXFLAGS = $(WARNINGS_CFLAGS)
311 # For use of the -rpath option, see:
312 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
313 test_cxx_filter_la_LDFLAGS = \
314         -module -avoid-version -shared -rpath /nowhere \
315         $(NULL)
316 endif HAVE_CXX
318 # Exit with parent test.
319 check_PROGRAMS += test-exit-with-parent
320 TESTS += test-exit-with-parent
322 test_exit_with_parent_SOURCES = \
323         test-exit-with-parent.c test.h \
324         $(NULL)
325 test_exit_with_parent_CPPFLAGS = \
326         -I$(top_srcdir)/common/include \
327         $(NULL)
328 test_exit_with_parent_CFLAGS = \
329         $(WARNINGS_CFLAGS) \
330         $(LIBGUESTFS_CFLAGS) \
331         $(NULL)
333 # PKI files for the TLS tests.
334 check_DATA += pki/.stamp
335 pki/.stamp: $(srcdir)/make-pki.sh
336         SRCDIR=$(srcdir) $(srcdir)/make-pki.sh
338 # PSK keys for the TLS-PSK tests.
339 check_DATA += keys.psk
340 keys.psk: $(srcdir)/make-psk.sh
341         SRCDIR=$(srcdir) $(srcdir)/make-psk.sh
343 # Keys are expensive to recreate so only delete them when we do
344 # â€˜make distclean’.
345 DISTCLEANFILES = keys.psk
346 distclean-local: distclean-local-tls
347 distclean-local-tls:
348         rm -rf pki
350 #----------------------------------------------------------------------
351 # Tests of C plugins or tests which require plugins.
353 if HAVE_PLUGINS
355 # Common data shared by multiple tests
356 check_DATA += file-data
357 CLEANFILES += file-data
358 file-data: generate-file-data.sh
359         $(srcdir)/generate-file-data.sh $@
361 # While most tests need libguestfs, testing parallel I/O is easier when
362 # using qemu-io to kick off asynchronous requests.
363 TESTS += \
364         test-parallel-file.sh \
365         test-parallel-nbd.sh \
366         test-parallel-sh.sh \
367         $(NULL)
369 # Most in-depth tests need libguestfs, since that is a convenient way to
370 # drive qemu.
371 LIBGUESTFS_TESTS =
372 EXTRA_PROGRAMS =
373 if HAVE_LIBGUESTFS
374 check_PROGRAMS += $(LIBGUESTFS_TESTS)
375 TESTS += $(LIBGUESTFS_TESTS)
377 # Use the 'direct' backend, and ensure maximum libguestfs and libnbd
378 # debugging is written to the *.log files in case there is a problem.
379 TESTS_ENVIRONMENT += \
380         LIBGUESTFS_ATTACH_METHOD=appliance \
381         LIBGUESTFS_DEBUG=1 \
382         LIBGUESTFS_TRACE=1 \
383         LIBNBD_DEBUG=1 \
384         $(NULL)
386 # Common test library.
387 check_LTLIBRARIES += libtest.la
388 libtest_la_SOURCES = test.c test.h
389 libtest_la_CFLAGS = $(WARNINGS_CFLAGS)
391 # Basic connection test.
392 LIBGUESTFS_TESTS += test-connect
394 test_connect_SOURCES = test-connect.c test.h
395 test_connect_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
396 test_connect_LDADD = libtest.la $(LIBGUESTFS_LIBS)
398 # newstyle protocol test.
399 LIBGUESTFS_TESTS += test-newstyle
401 test_newstyle_SOURCES = test-newstyle.c test.h
402 test_newstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
403 test_newstyle_LDADD = libtest.la $(LIBGUESTFS_LIBS)
405 # oldstyle protocol test.
406 LIBGUESTFS_TESTS += test-oldstyle
408 test_oldstyle_SOURCES = test-oldstyle.c test.h
409 test_oldstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
410 test_oldstyle_LDADD = libtest.la $(LIBGUESTFS_LIBS)
412 endif HAVE_LIBGUESTFS
414 # Test export flags.
415 TESTS += test-eflags.sh
417 # Test export name.
418 TESTS += test-export-name.sh
420 # common disk image shared with several tests
421 if HAVE_GUESTFISH
422 check_DATA += disk
423 CLEANFILES += disk
425 disk:
426         rm -f $@ $@-t
427         guestfish -N $@-t=fs:ext4:100M -m /dev/sda1 \
428             write /hello.txt "hello,world"
429         mv $@-t $@
431 endif HAVE_GUESTFISH
433 # curl plugin test.
435 if HAVE_CURL
436 if HAVE_GUESTFISH
438 # curl plugin test.
439 LIBGUESTFS_TESTS += test-curl
441 test_curl_SOURCES = \
442         test-curl.c \
443         web-server.c \
444         web-server.h \
445         test.h \
446         $(NULL)
447 test_curl_CPPFLAGS = \
448         -I$(top_srcdir)/common/utils
449 test_curl_CFLAGS = \
450         $(WARNINGS_CFLAGS) \
451         $(LIBGUESTFS_CFLAGS) \
452         $(PTHREAD_CFLAGS) \
453         $(NULL)
454 test_curl_LDFLAGS = \
455         $(top_builddir)/common/utils/libutils.la \
456         $(PTHREAD_LIBS) \
457         $(NULL)
458 test_curl_LDADD = \
459         libtest.la \
460         $(LIBGUESTFS_LIBS) \
461         $(NULL)
463 endif HAVE_GUESTFISH
464 endif HAVE_CURL
466 # data plugin test.
467 LIBGUESTFS_TESTS += test-data
468 TESTS += \
469         test-data-7E.sh \
470         test-data-base64.sh \
471         test-data-extents.sh \
472         test-data-file.sh \
473         test-data-raw.sh \
474         $(NULL)
476 test_data_SOURCES = test-data.c test.h
477 test_data_CPPFLAGS = -I$(top_srcdir)/common/include
478 test_data_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
479 test_data_LDADD = libtest.la $(LIBGUESTFS_LIBS)
481 # ext2 plugin test.
482 if HAVE_EXT2
483 if HAVE_GUESTFISH
485 LIBGUESTFS_TESTS += test-ext2
486 check_DATA += ext2.img
487 CLEANFILES += ext2.img
489 ext2.img: disk
490         rm -f $@ $@-t
491         guestfish \
492             sparse $@-t 2G : \
493             run : \
494             mkfs ext4 /dev/sda : \
495             mount /dev/sda / : \
496             mkdir /disks : \
497             upload $< /disks/disk.img
498         mv $@-t $@
500 test_ext2_SOURCES = test-ext2.c test.h
501 test_ext2_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
502 test_ext2_LDADD = libtest.la $(LIBGUESTFS_LIBS)
504 endif HAVE_GUESTFISH
505 endif HAVE_EXT2
507 # file plugin test.
508 LIBGUESTFS_TESTS += test-file test-file-block
510 test_file_SOURCES = test-file.c test.h
511 test_file_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
512 test_file_LDADD = libtest.la $(LIBGUESTFS_LIBS)
514 test_file_block_SOURCES = test-file-block.c test.h
515 test_file_block_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
516 test_file_block_LDADD = libtest.la $(LIBGUESTFS_LIBS)
518 if HAVE_GUESTFISH
519 TESTS += test-file-extents.sh
520 endif HAVE_GUESTFISH
522 # floppy plugin test.
523 if HAVE_GUESTFISH
524 TESTS += test-floppy.sh
525 endif HAVE_GUESTFISH
527 # full plugin test.
528 TESTS += test-full.sh
530 # gzip plugin test.
531 if HAVE_ZLIB
532 if HAVE_GUESTFISH
534 LIBGUESTFS_TESTS += test-gzip
535 check_DATA += disk.gz
536 CLEANFILES += disk.gz
538 test_gzip_SOURCES = test-gzip.c test.h
539 test_gzip_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
540 test_gzip_LDADD = libtest.la $(LIBGUESTFS_LIBS)
542 disk.gz: disk
543         rm -f $@
544         gzip -9 -c disk > $@
546 endif HAVE_GUESTFISH
547 endif HAVE_ZLIB
549 # info plugin test.
550 TESTS += \
551         test-info-address.sh \
552         test-info-base64.sh \
553         test-info-raw.sh \
554         test-info-time.sh \
555         test-info-uptime.sh \
556         test-info-conntime.sh \
557         $(NULL)
559 # iso plugin test.
560 if HAVE_ISO
561 if HAVE_GUESTFISH
563 TESTS += test-iso.sh
565 endif HAVE_GUESTFISH
566 endif HAVE_ISO
568 # linuxdisk plugin test.
569 if HAVE_GUESTFISH
570 TESTS += \
571         test-linuxdisk.sh \
572         test-linuxdisk-copy-out.sh \
573         $(NULL)
574 endif HAVE_GUESTFISH
576 # memory plugin test.
577 LIBGUESTFS_TESTS += test-memory
578 TESTS += test-memory-largest.sh test-memory-largest-for-qemu.sh
580 test_memory_SOURCES = test-memory.c test.h
581 test_memory_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
582 test_memory_LDADD = libtest.la $(LIBGUESTFS_LIBS)
584 # partitioning plugin test.
585 TESTS += \
586         test-partitioning1.sh \
587         test-partitioning4.sh \
588         test-partitioning6.sh \
589         $(NULL)
590 if HAVE_GUESTFISH
591 TESTS += \
592         test-partitioning2.sh \
593         test-partitioning3.sh \
594         test-partitioning5.sh \
595         $(NULL)
596 endif HAVE_GUESTFISH
598 # pattern plugin test.
599 TESTS += \
600         test-pattern.sh \
601         test-pattern-largest.sh \
602         test-pattern-largest-for-qemu.sh \
603         $(NULL)
605 # nbd plugin test.
606 LIBGUESTFS_TESTS += test-nbd
607 TESTS += \
608         test-nbd-extents.sh \
609         test-nbd-tls.sh \
610         test-nbd-tls-psk.sh \
611         $(NULL)
613 test_nbd_SOURCES = test-nbd.c test.h
614 test_nbd_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
615 test_nbd_LDADD = libtest.la $(LIBGUESTFS_LIBS)
617 # null plugin test.
618 LIBGUESTFS_TESTS += test-null
619 TESTS += test-null-extents.sh
621 test_null_SOURCES = test-null.c test.h
622 test_null_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
623 test_null_LDADD = libtest.la $(LIBGUESTFS_LIBS)
625 # random plugin test.
626 LIBGUESTFS_TESTS += test-random
628 test_random_SOURCES = test-random.c test.h
629 test_random_CPPFLAGS = -I $(top_srcdir)/common/include
630 test_random_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
631 test_random_LDADD = libtest.la $(LIBGUESTFS_LIBS)
633 # split files plugin test.
634 check_DATA += split1 split2 split3
635 CLEANFILES += split1 split2 split3
636 split1: file-data
637         rm -f $@ $@-t
638         dd if=$< of=$@-t bs=1 count=100
639         mv $@-t $@
640 split2: file-data
641         rm -f $@ $@-t
642         dd if=$< of=$@-t bs=1 count=100 skip=100
643         mv $@-t $@
644 split3: file-data
645         rm -f $@ $@-t
646         dd if=$< of=$@-t bs=1 skip=200
647         mv $@-t $@
648 LIBGUESTFS_TESTS += test-split
650 test_split_SOURCES = test-split.c test.h
651 test_split_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
652 test_split_LDADD = libtest.la $(LIBGUESTFS_LIBS)
654 # ssh plugin test.
655 if HAVE_SSH
656 # Uses â€˜disk’ so we have to make it conditional on guestfish.
657 if HAVE_GUESTFISH
658 TESTS += test-ssh.sh
659 endif HAVE_GUESTFISH
660 check_DATA += \
661         ssh/sshd_config \
662         ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub \
663         ssh/authorized_keys \
664         $(NULL)
665 SSH_RANDOM_PORT := $(shell bash -c 'echo $$(( 10000 + $$RANDOM ))')
666 CLEANFILES += \
667         ssh/*~ \
668         ssh/sshd_config \
669         ssh/authorized_keys \
670         $(NULL)
671 DISTCLEANFILES += \
672         ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub \
673         ssh/id_rsa ssh/id_rsa.pub \
674         stamp-ssh-host-key stamp-ssh-user-key \
675         $(NULL)
677 ssh/sshd_config: ssh/sshd_config.in Makefile
678         rm -f $@ $@-t
679         $(SED) \
680             -e 's,__abs_builddir__,$(abs_builddir),g' \
681             -e 's,__RANDOM_PORT__,$(SSH_RANDOM_PORT),g' \
682             < $< > $@-t
683         mv $@-t $@
685 ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub: stamp-ssh-host-key
686 stamp-ssh-host-key:
687         rm -f $@
688         rm -f ssh/ssh_host_rsa_key
689         rm -f ssh/ssh_host_rsa_key.pub
690         ssh-keygen -t rsa -f ssh/ssh_host_rsa_key -N ''
691         touch $@
693 ssh/authorized_keys: ssh/id_rsa.pub
694         rm -f $@ $@-t
695         cp $< $@-t
696         mv $@-t $@
698 ssh/id_rsa ssh/id_rsa.pub: stamp-ssh-user-key
699 stamp-ssh-user-key:
700         rm -f $@
701         rm -f ssh/id_rsa
702         rm -f ssh/id_rsa.pub
703         ssh-keygen -t rsa -f ssh/id_rsa -N ''
704         touch $@
705 endif HAVE_SSH
707 # streaming plugin test.
708 # Doesn't work:
709 #LIBGUESTFS_TESTS += test-streaming
710 EXTRA_PROGRAMS += test-streaming
712 test_streaming_SOURCES = test-streaming.c test.h
713 test_streaming_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
714 test_streaming_LDADD = libtest.la $(LIBGUESTFS_LIBS)
716 # VDDK plugin test.
717 # This only tests that the plugin can be loaded against a
718 # dummy VDDK library, it is not a detailed test.
720 # check_LTLIBRARIES won't build a shared library (see automake manual).
721 # So we have to do this and add a dependency.
722 noinst_LTLIBRARIES += libvixDiskLib.la
723 TESTS += \
724         test-vddk.sh \
725         test-vddk-real.sh \
726         $(NULL)
728 libvixDiskLib_la_SOURCES = \
729         dummy-vddk.c \
730         $(NULL)
731 libvixDiskLib_la_CPPFLAGS = \
732         -I$(top_srcdir)/plugins/vddk \
733         $(NULL)
734 libvixDiskLib_la_CXXFLAGS = $(WARNINGS_CFLAGS)
735 # For use of the -rpath option, see:
736 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
737 libvixDiskLib_la_LDFLAGS = \
738         -shared -version-number 6:0:0 -rpath /nowhere \
739         $(NULL)
741 # zero plugin test.
742 TESTS += test-zero.sh
744 #----------------------------------------------------------------------
745 # Tests of language plugins.
747 # OCaml plugin test.
748 if HAVE_OCAML
750 LIBGUESTFS_TESTS += test-ocaml
752 # This is somewhat different from the other tests because we have
753 # to build an actual plugin here.
754 test_ocaml_SOURCES = test-ocaml.c test.h
755 test_ocaml_CFLAGS = \
756         $(WARNINGS_CFLAGS) \
757         $(LIBGUESTFS_CFLAGS) \
758         $(NULL)
759 test_ocaml_LDADD = libtest.la $(LIBGUESTFS_LIBS)
761 check_SCRIPTS += test-ocaml-plugin.so
762 test-ocaml-plugin.so: test_ocaml_plugin.cmx ../plugins/ocaml/libnbdkitocaml.la ../plugins/ocaml/NBDKit.cmi ../plugins/ocaml/NBDKit.cmx
763         $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../plugins/ocaml \
764           -output-obj -runtime-variant _pic -o $@ \
765           NBDKit.cmx $< \
766           -cclib -L../plugins/ocaml/.libs -cclib -lnbdkitocaml
767 test_ocaml_plugin.cmx: test_ocaml_plugin.ml ../plugins/ocaml/NBDKit.cmi
768         $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../plugins/ocaml -c $< -o $@
770 endif HAVE_OCAML
772 # perl plugin test.
773 if HAVE_PERL
775 TESTS += \
776         test-dump-plugin-example4.sh \
777         test-shebang-perl.sh \
778         $(NULL)
779 LIBGUESTFS_TESTS += test-perl
781 test_perl_SOURCES = test-lang-plugins.c test.h
782 test_perl_CFLAGS = \
783         -DLANG='"perl"' -DSCRIPT='"$(srcdir)/test.pl"' \
784         $(WARNINGS_CFLAGS) \
785         $(LIBGUESTFS_CFLAGS) \
786         $(NULL)
787 test_perl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
789 endif HAVE_PERL
791 # python plugin test.
792 if HAVE_PYTHON
794 TESTS += \
795         test-python-exception.sh \
796         test-shebang-python.sh \
797         $(NULL)
798 LIBGUESTFS_TESTS += test-python
800 test_python_SOURCES = test-lang-plugins.c test.h
801 test_python_CFLAGS = \
802         -DLANG='"python"' -DSCRIPT='"$(srcdir)/test.py"' \
803         $(WARNINGS_CFLAGS) \
804         $(LIBGUESTFS_CFLAGS) \
805         $(NULL)
806 test_python_LDADD = libtest.la $(LIBGUESTFS_LIBS)
808 endif HAVE_PYTHON
810 # Ruby plugin test.
811 if HAVE_RUBY
813 # Ruby tests are disabled.  See "WARNING" section in
814 # plugins/ruby/nbdkit-ruby-plugin.pod
816 #LIBGUESTFS_TESTS += \
817 #       test-ruby \
818 #       $(NULL)
819 #TESTS += test-shebang-ruby.sh
820 EXTRA_PROGRAMS += test-ruby
822 test_ruby_SOURCES = test-lang-plugins.c test.h
823 test_ruby_CFLAGS = \
824         -DLANG='"ruby"' -DSCRIPT='"$(srcdir)/test.rb"' \
825         $(WARNINGS_CFLAGS) \
826         $(LIBGUESTFS_CFLAGS) \
827         $(NULL)
828 test_ruby_LDADD = libtest.la $(LIBGUESTFS_LIBS)
830 endif HAVE_RUBY
832 # Shell (sh) plugin test.
833 LIBGUESTFS_TESTS += test-shell
834 check_DATA += test-shell.img
835 CLEANFILES += test-shell.img
837 test_shell_SOURCES = test-lang-plugins.c test.h
838 test_shell_CFLAGS = \
839         -DLANG='"sh"' -DSCRIPT='"$(srcdir)/test-shell.sh"' \
840         $(WARNINGS_CFLAGS) \
841         $(LIBGUESTFS_CFLAGS) \
842         $(NULL)
843 test_shell_LDADD = libtest.la $(LIBGUESTFS_LIBS)
845 test-shell.img:
846         truncate -s 1048576 $@
848 TESTS += \
849         test-sh-errors.sh \
850         test-sh-extents.sh \
851         $(NULL)
853 # Tcl plugin test.
854 if HAVE_TCL
856 LIBGUESTFS_TESTS += test-tcl
858 test_tcl_SOURCES = test-lang-plugins.c test.h
859 test_tcl_CFLAGS = \
860         -DLANG='"tcl"' -DSCRIPT='"$(srcdir)/test.tcl"' \
861         $(WARNINGS_CFLAGS) \
862         $(LIBGUESTFS_CFLAGS) \
863         $(NULL)
864 test_tcl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
866 endif HAVE_TCL
868 # Lua plugin test.
869 if HAVE_LUA
871 LIBGUESTFS_TESTS += test-lua
873 test_lua_SOURCES = test-lang-plugins.c test.h
874 test_lua_CFLAGS = \
875         -DLANG='"lua"' -DSCRIPT='"$(srcdir)/test.lua"' \
876         $(WARNINGS_CFLAGS) \
877         $(LIBGUESTFS_CFLAGS) \
878         $(NULL)
879 test_lua_LDADD = libtest.la $(LIBGUESTFS_LIBS)
881 endif HAVE_LUA
883 #----------------------------------------------------------------------
884 # Tests of filters.
886 # Generic test of filter layers.
887 check_PROGRAMS += test-layers
888 TESTS += test-layers.sh test-layers
890 test_layers_SOURCES = \
891         test-layers.c \
892         $(NULL)
893 test_layers_CPPFLAGS = \
894         -I$(top_srcdir)/common/include \
895         -I$(top_srcdir)/common/protocol \
896         -I$(top_srcdir)/common/utils \
897         -I$(top_srcdir)/server \
898         $(NULL)
899 test_layers_CFLAGS = \
900         $(WARNINGS_CFLAGS) \
901         $(PTHREAD_CFLAGS) \
902         $(NULL)
903 test_layers_LDFLAGS = \
904         $(PTHREAD_LIBS) \
905         $(NULL)
906 test_layers_LDADD = \
907         $(top_builddir)/common/utils/libutils.la \
908         $(NULL)
909 test_layers_DEPENDENCIES = \
910         test-layers-plugin.la \
911         test-layers-filter1.la \
912         test-layers-filter2.la \
913         test-layers-filter3.la \
914         $(NULL)
916 # check_LTLIBRARIES won't build a shared library (see automake manual).
917 # So we have to do this and add a dependency.
918 noinst_LTLIBRARIES += \
919         test-layers-plugin.la \
920         test-layers-filter1.la \
921         test-layers-filter2.la \
922         test-layers-filter3.la \
923         $(NULL)
925 test_layers_plugin_la_SOURCES = \
926         test-layers-plugin.c \
927         $(top_srcdir)/include/nbdkit-plugin.h \
928         $(NULL)
929 test_layers_plugin_la_CPPFLAGS = -I$(top_srcdir)/include
930 test_layers_plugin_la_CFLAGS = $(WARNINGS_CFLAGS)
931 # For use of the -rpath option, see:
932 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
933 test_layers_plugin_la_LDFLAGS = \
934         -module -avoid-version -shared -rpath /nowhere \
935         $(NULL)
937 test_layers_filter1_la_SOURCES = \
938         test-layers-filter.c \
939         $(top_srcdir)/include/nbdkit-filter.h \
940         $(NULL)
941 test_layers_filter1_la_CPPFLAGS = -I$(top_srcdir)/include
942 test_layers_filter1_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter1"'
943 # For use of the -rpath option, see:
944 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
945 test_layers_filter1_la_LDFLAGS = \
946         -module -avoid-version -shared -rpath /nowhere \
947         $(NULL)
949 test_layers_filter2_la_SOURCES = \
950         test-layers-filter.c \
951         $(top_srcdir)/include/nbdkit-filter.h \
952         $(NULL)
953 test_layers_filter2_la_CPPFLAGS = -I$(top_srcdir)/include
954 test_layers_filter2_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter2"'
955 # For use of the -rpath option, see:
956 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
957 test_layers_filter2_la_LDFLAGS = \
958         -module -avoid-version -shared -rpath /nowhere \
959         $(NULL)
961 test_layers_filter3_la_SOURCES = \
962         test-layers-filter.c \
963         $(top_srcdir)/include/nbdkit-filter.h \
964         $(NULL)
965 test_layers_filter3_la_CPPFLAGS = -I$(top_srcdir)/include
966 test_layers_filter3_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter3"'
967 # For use of the -rpath option, see:
968 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
969 test_layers_filter3_la_LDFLAGS = \
970         -module -avoid-version -shared -rpath /nowhere \
971         $(NULL)
973 # blocksize filter test.
974 TESTS += test-blocksize.sh
976 # cache filter test.
977 if HAVE_GUESTFISH
978 TESTS += \
979         test-cache.sh \
980         test-cache-on-read.sh \
981         $(NULL)
982 endif HAVE_GUESTFISH
983 TESTS += test-cache-max-size.sh
985 # cacheextents filter test.
986 TESTS += test-cacheextents.sh
988 # cow filter test.
989 if HAVE_GUESTFISH
990 TESTS += test-cow.sh
991 endif HAVE_GUESTFISH
992 TESTS += test-cow-null.sh
994 # delay filter tests.
995 TESTS += test-shutdown.sh
996 LIBGUESTFS_TESTS += test-delay
998 test_delay_SOURCES = test-delay.c test.h
999 test_delay_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
1000 test_delay_LDADD = libtest.la $(LIBGUESTFS_LIBS)
1002 # error filter test.
1003 LIBGUESTFS_TESTS += test-error
1005 test_error_SOURCES = test-error.c test.h
1006 test_error_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
1007 test_error_LDADD = libtest.la $(LIBGUESTFS_LIBS)
1009 TESTS += \
1010         test-error0.sh \
1011         test-error10.sh \
1012         test-error100.sh \
1013         $(NULL)
1015 # fua filter test.
1016 TESTS += test-fua.sh
1018 # log filter test.
1019 TESTS += test-log.sh
1021 # nozero filter test.
1022 TESTS += test-nozero.sh
1024 # offset filter test.
1025 check_DATA += offset-data
1026 CLEANFILES += offset-data
1027 LIBGUESTFS_TESTS += test-offset
1029 offset-data: generate-offset-data.sh
1030         $(srcdir)/generate-offset-data.sh $@
1032 test_offset_SOURCES = test-offset.c test.h
1033 test_offset_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
1034 test_offset_LDADD = libtest.la $(LIBGUESTFS_LIBS)
1036 TESTS += \
1037         test-offset2.sh \
1038         test-offset-extents.sh \
1039         $(NULL)
1041 # partition filter test.
1042 TESTS += test-partition1.sh
1043 if HAVE_GUESTFISH
1044 TESTS += test-partition2.sh
1045 endif HAVE_GUESTFISH
1047 # rate filter test.
1048 TESTS += \
1049         test-rate.sh \
1050         test-rate-dynamic.sh \
1051         $(NULL)
1053 # readahead filter test.
1054 LIBGUESTFS_TESTS += test-readahead
1055 TESTS += test-readahead-copy.sh
1057 test_readahead_SOURCES = test-readahead.c test.h
1058 test_readahead_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
1059 test_readahead_LDADD = libtest.la $(LIBGUESTFS_LIBS)
1061 # retry filter test.
1062 TESTS += \
1063         test-retry.sh \
1064         test-retry-readonly.sh \
1065         test-retry-extents.sh \
1066         test-retry-size.sh \
1067         test-retry-reopen-fail.sh \
1068         test-retry-zero-flags.sh \
1069         $(NULL)
1071 # truncate filter tests.
1072 TESTS += \
1073         test-truncate1.sh \
1074         test-truncate2.sh \
1075         test-truncate3.sh \
1076         test-truncate4.sh \
1077         test-truncate-extents.sh \
1078         $(NULL)
1080 # xz filter test.
1081 if HAVE_LIBLZMA
1082 if HAVE_GUESTFISH
1084 LIBGUESTFS_TESTS += test-xz
1085 check_DATA += disk.xz
1086 CLEANFILES += disk.xz
1088 test_xz_SOURCES = test-xz.c test.h
1089 test_xz_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
1090 test_xz_LDADD = libtest.la $(LIBGUESTFS_LIBS)
1092 disk.xz: disk
1093         rm -f $@
1094 # We choose a very small block size here only for testing.  Normally
1095 # you should choose a 16M block size.
1096         xz --best --block-size=32768 -c disk > $@
1098 if HAVE_CURL
1100 # xz filter + curl.
1101 LIBGUESTFS_TESTS += test-xz-curl
1103 test_xz_curl_SOURCES = \
1104         test-xz-curl.c \
1105         web-server.c \
1106         web-server.h \
1107         test.h \
1108         $(NULL)
1109 test_xz_curl_CPPFLAGS = \
1110         -I$(top_srcdir)/common/utils
1111 test_xz_curl_CFLAGS = \
1112         $(WARNINGS_CFLAGS) \
1113         $(LIBGUESTFS_CFLAGS) \
1114         $(PTHREAD_CFLAGS) \
1115         $(NULL)
1116 test_xz_curl_LDFLAGS = \
1117         $(top_builddir)/common/utils/libutils.la \
1118         $(PTHREAD_LIBS) \
1119         $(NULL)
1120 test_xz_curl_LDADD = \
1121         libtest.la \
1122         $(LIBGUESTFS_LIBS) \
1123         $(NULL)
1125 endif HAVE_CURL
1127 endif HAVE_GUESTFISH
1128 endif HAVE_LIBLZMA
1130 endif HAVE_PLUGINS