tests: Improve test-readahead test.
[nbdkit/ericb.git] / tests / Makefile.am
bloba5e9897a316e3687c57177e1f23d7b4b13c64083
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 #----------------------------------------------------------------------
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-file-extents.sh \
115         test-floppy.sh \
116         test-foreground.sh \
117         test-fua.sh \
118         test-full.sh \
119         test-help.sh \
120         test-help-plugin.sh \
121         test-info-address.sh \
122         test-info-base64.sh \
123         test-info-raw.sh \
124         test-info-time.sh \
125         test-info-uptime.sh \
126         test-info-conntime.sh \
127         test-ip.sh \
128         test-ip-filter.sh \
129         test-iso.sh \
130         test-layers.sh \
131         test-linuxdisk.sh \
132         test-linuxdisk-copy-out.sh \
133         test-log.sh \
134         test-long-name.sh \
135         test.lua \
136         test-memory-largest.sh \
137         test-memory-largest-for-qemu.sh \
138         test-nbd-extents.sh \
139         test-nbd-tls.sh \
140         test-nbd-tls-psk.sh \
141         test-nbdkit-backend-debug.sh \
142         test-nofilter.sh \
143         test-nozero.sh \
144         test-null-extents.sh \
145         test_ocaml_plugin.ml \
146         test-ocaml.c \
147         test-offset2.sh \
148         test-offset-extents.sh \
149         test-parallel-file.sh \
150         test-parallel-nbd.sh \
151         test-parallel-sh.sh \
152         test-partition1.sh \
153         test-partition2.sh \
154         test-partitioning1.sh \
155         test-partitioning2.sh \
156         test-partitioning3.sh \
157         test-partitioning4.sh \
158         test-partitioning5.sh \
159         test-partitioning6.sh \
160         test-pattern.sh \
161         test-pattern-largest.sh \
162         test-pattern-largest-for-qemu.sh \
163         test-python-exception.sh \
164         test.pl \
165         test_python.py \
166         test-python-plugin.py \
167         test-python.sh \
168         test-rate.sh \
169         test-rate-dynamic.sh \
170         test.rb \
171         test-readahead.sh \
172         test-readahead-copy.sh \
173         test-readahead-test-plugin.sh \
174         test-readahead-test-request.py \
175         test-retry.sh \
176         test-retry-extents.sh \
177         test-retry-size.sh \
178         test-retry-readonly.sh \
179         test-retry-reopen-fail.sh \
180         test-retry-zero-flags.sh \
181         test-shutdown.sh \
182         test-ssh.sh \
183         test-swap.sh \
184         test.tcl \
185         test-shebang-perl.sh \
186         test-shebang-python.sh \
187         test-shebang-ruby.sh \
188         test-shell.sh \
189         test-sh-errors.sh \
190         test-sh-extents.sh \
191         test-single.sh \
192         test-single-from-file.sh \
193         test-start.sh \
194         test-random-sock.sh \
195         test-tls.sh \
196         test-tls-psk.sh \
197         test-truncate1.sh \
198         test-truncate2.sh \
199         test-truncate3.sh \
200         test-truncate4.sh \
201         test-truncate-extents.sh \
202         test-vddk.sh \
203         test-vddk-real.sh \
204         test-version.sh \
205         test-version-filter.sh \
206         test-version-plugin.sh \
207         test-zero.sh \
208         $(NULL)
210 #----------------------------------------------------------------------
211 # Use 'make check' to run the ordinary tests as non-root.  The
212 # following are special commands for particular scenarios:
214 # To run all the tests under valgrind, use the following rule:
215 check-valgrind:
216         NBDKIT_VALGRIND=1 $(MAKE) check
218 # To run only tests which require root, use:
219 check-root:
220         $(MAKE) check TESTS="test-file-block test-swap.sh"
222 if HAVE_VDDK
223 # Run a basic check against a real copy of VDDK.  You must set
224 # vddkdir to point to the library location, eg:
226 #   make check-vddk vddkdir=vmware-vix-disklib-distrib
227 check-vddk:
228         $(MAKE) check TESTS=test-vddk-real.sh
229 endif HAVE_VDDK
231 #----------------------------------------------------------------------
232 # Basic server command line and start-up tests.
234 TESTS += \
235         test-help.sh \
236         test-version.sh \
237         test-dump-config.sh \
238         $(NULL)
240 if HAVE_PLUGINS
242 TESTS += \
243         test-help-plugin.sh \
244         test-version-plugin.sh \
245         test-version-filter.sh \
246         test-dump-plugin.sh \
247         test-start.sh \
248         test-single.sh \
249         test-single-from-file.sh \
250         test-captive.sh \
251         test-random-sock.sh \
252         test-tls.sh \
253         test-tls-psk.sh \
254         test-ip.sh \
255         test-socket-activation \
256         test-foreground.sh \
257         test-debug-flags.sh \
258         test-long-name.sh \
259         test-swap.sh \
260         $(NULL)
262 check_PROGRAMS += \
263         test-socket-activation \
264         $(NULL)
266 test_socket_activation_SOURCES = test-socket-activation.c
267 test_socket_activation_CPPFLAGS = \
268         -I$(top_srcdir)/common/include \
269         -I$(top_srcdir)/common/protocol \
270         $(NULL)
271 test_socket_activation_CFLAGS = $(WARNINGS_CFLAGS)
273 endif HAVE_PLUGINS
275 # Test the header files can be included on their own.
276 check_PROGRAMS += \
277         test-just-plugin-header \
278         test-just-filter-header
279         $(NULL)
280 TESTS += \
281         test-just-plugin-header \
282         test-just-filter-header
283         $(NULL)
285 test_just_plugin_header_SOURCES = \
286         test-just-plugin-header.c \
287         $(NULL)
288 test_just_plugin_header_CPPFLAGS = \
289         -I$(top_srcdir)/include \
290         $(NULL)
291 test_just_plugin_header_CFLAGS = $(WARNINGS_CFLAGS)
293 test_just_filter_header_SOURCES = \
294         test-just-filter-header.c \
295         $(NULL)
296 test_just_filter_header_CPPFLAGS = \
297         -I$(top_srcdir)/include \
298         $(NULL)
299 test_just_filter_header_CFLAGS = $(WARNINGS_CFLAGS)
301 if CAN_TEST_ANSI_C
302 # This builds a plugin using an ANSI (ISO C90) compiler to ensure that
303 # the header file is compatible.  The plugin does nothing very
304 # interesting, it's mainly a compile test.
305 TESTS += \
306         test-ansi-c.sh \
307         $(NULL)
308 # check_LTLIBRARIES won't build a shared library (see automake manual).
309 # So we have to do this and add a dependency.
310 noinst_LTLIBRARIES += test-ansi-c-plugin.la
311 test-ansi-c.sh: test-ansi-c-plugin.la
313 test_ansi_c_plugin_la_SOURCES = \
314         test-ansi-c-plugin.c \
315         $(top_srcdir)/include/nbdkit-plugin.h \
316         $(NULL)
317 test_ansi_c_plugin_la_CPPFLAGS = \
318         -std=c90 -pedantic \
319         -I$(top_srcdir)/include \
320         $(NULL)
321 test_ansi_c_plugin_la_CFLAGS = $(WARNINGS_CFLAGS)
322 # For use of the -rpath option, see:
323 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
324 test_ansi_c_plugin_la_LDFLAGS = \
325         -module -avoid-version -shared -rpath /nowhere \
326         $(NULL)
327 endif CAN_TEST_ANSI_C
329 if HAVE_CXX
330 # This builds a plugin and a filter using the C++ compiler.  They
331 # don't do anything interesting when run.
332 TESTS += \
333         test-cxx.sh \
334         $(NULL)
335 # check_LTLIBRARIES won't build a shared library (see automake manual).
336 # So we have to do this and add a dependency.
337 noinst_LTLIBRARIES += test-cxx-plugin.la test-cxx-filter.la
338 test-cxx.sh: test-cxx-plugin.la test-cxx-filter.la
340 test_cxx_plugin_la_SOURCES = \
341         test-cxx-plugin.cpp \
342         $(top_srcdir)/include/nbdkit-plugin.h \
343         $(NULL)
344 test_cxx_plugin_la_CPPFLAGS = \
345         -I$(top_srcdir)/include \
346         $(NULL)
347 test_cxx_plugin_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_plugin_la_LDFLAGS = \
351         -module -avoid-version -shared -rpath /nowhere \
352         $(NULL)
354 test_cxx_filter_la_SOURCES = \
355         test-cxx-filter.cpp \
356         $(top_srcdir)/include/nbdkit-filter.h \
357         $(NULL)
358 test_cxx_filter_la_CPPFLAGS = \
359         -I$(top_srcdir)/include \
360         $(NULL)
361 test_cxx_filter_la_CXXFLAGS = $(WARNINGS_CFLAGS)
362 # For use of the -rpath option, see:
363 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
364 test_cxx_filter_la_LDFLAGS = \
365         -module -avoid-version -shared -rpath /nowhere \
366         $(NULL)
367 endif HAVE_CXX
369 # Exit with parent test.
370 check_PROGRAMS += test-exit-with-parent
371 TESTS += test-exit-with-parent
373 test_exit_with_parent_SOURCES = \
374         test-exit-with-parent.c test.h \
375         $(NULL)
376 test_exit_with_parent_CPPFLAGS = \
377         -I$(top_srcdir)/common/include \
378         $(NULL)
379 test_exit_with_parent_CFLAGS = \
380         $(WARNINGS_CFLAGS) \
381         $(LIBGUESTFS_CFLAGS) \
382         $(NULL)
384 # PKI files for the TLS tests.
385 check_DATA += pki/.stamp
386 pki/.stamp: $(srcdir)/make-pki.sh
387         SRCDIR=$(srcdir) $(srcdir)/make-pki.sh
389 # PSK keys for the TLS-PSK tests.
390 check_DATA += keys.psk
391 keys.psk: $(srcdir)/make-psk.sh
392         SRCDIR=$(srcdir) $(srcdir)/make-psk.sh
394 # Keys are expensive to recreate so only delete them when we do
395 # â€˜make distclean’.
396 DISTCLEANFILES = keys.psk
397 distclean-local: distclean-local-tls
398 distclean-local-tls:
399         rm -rf pki
401 #----------------------------------------------------------------------
402 # Tests of C plugins or tests which require plugins.
404 if HAVE_PLUGINS
406 # Common data shared by multiple tests
407 check_DATA += file-data
408 CLEANFILES += file-data
409 file-data: generate-file-data.sh
410         $(srcdir)/generate-file-data.sh $@
412 # While most tests need libguestfs, testing parallel I/O is easier when
413 # using qemu-io to kick off asynchronous requests.
414 TESTS += \
415         test-parallel-file.sh \
416         test-parallel-nbd.sh \
417         test-parallel-sh.sh \
418         $(NULL)
420 # Common test library.
421 check_LTLIBRARIES += libtest.la
422 libtest_la_SOURCES = test.c test.h
423 libtest_la_CFLAGS = $(WARNINGS_CFLAGS)
425 # Basic connection test.
426 LIBNBD_TESTS += test-connect
428 test_connect_SOURCES = test-connect.c
429 test_connect_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
430 test_connect_LDADD = $(LIBNBD_LIBS)
432 # newstyle protocol test.
433 LIBNBD_TESTS += test-newstyle
435 test_newstyle_SOURCES = test-newstyle.c
436 test_newstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
437 test_newstyle_LDADD = $(LIBNBD_LIBS)
439 # oldstyle protocol test.
440 LIBNBD_TESTS += test-oldstyle
442 test_oldstyle_SOURCES = test-oldstyle.c
443 test_oldstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
444 test_oldstyle_LDADD = $(LIBNBD_LIBS)
446 # Test export flags.
447 TESTS += test-eflags.sh
449 # Test export name.
450 TESTS += test-export-name.sh
452 # common disk image shared with several tests
453 check_DATA += disk
454 CLEANFILES += disk
456 disk:
457         rm -rf disk.tmp $@ $@-t
458         mkdir disk.tmp
459         echo -n "hello,world" > disk.tmp/hello.txt
460         $(top_builddir)/nbdkit -fv -U - linuxdisk disk.tmp size=100M \
461             --run 'qemu-img convert $$nbd $@-t'
462         rm -rf disk.tmp
463         mv $@-t $@
465 # curl plugin test.
466 if HAVE_CURL
467 LIBGUESTFS_TESTS += test-curl
469 test_curl_SOURCES = \
470         test-curl.c \
471         web-server.c \
472         web-server.h \
473         test.h \
474         $(NULL)
475 test_curl_CPPFLAGS = \
476         -I$(top_srcdir)/common/utils
477 test_curl_CFLAGS = \
478         $(WARNINGS_CFLAGS) \
479         $(LIBGUESTFS_CFLAGS) \
480         $(PTHREAD_CFLAGS) \
481         $(NULL)
482 test_curl_LDFLAGS = \
483         $(top_builddir)/common/utils/libutils.la \
484         $(PTHREAD_LIBS) \
485         $(NULL)
486 test_curl_LDADD = \
487         libtest.la \
488         $(LIBGUESTFS_LIBS) \
489         $(NULL)
490 endif HAVE_CURL
492 # data plugin test.
493 LIBGUESTFS_TESTS += test-data
494 TESTS += \
495         test-data-7E.sh \
496         test-data-base64.sh \
497         test-data-extents.sh \
498         test-data-file.sh \
499         test-data-raw.sh \
500         $(NULL)
502 test_data_SOURCES = test-data.c test.h
503 test_data_CPPFLAGS = -I$(top_srcdir)/common/include
504 test_data_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
505 test_data_LDADD = libtest.la $(LIBGUESTFS_LIBS)
507 # eval plugin test.
508 TESTS += test-eval.sh
510 # ext2 plugin test.
511 if HAVE_EXT2
512 if HAVE_GUESTFISH
514 LIBGUESTFS_TESTS += test-ext2
515 check_DATA += ext2.img
516 CLEANFILES += ext2.img
518 ext2.img: disk
519         rm -f $@ $@-t
520         guestfish \
521             sparse $@-t 2G : \
522             run : \
523             mkfs ext4 /dev/sda : \
524             mount /dev/sda / : \
525             mkdir /disks : \
526             upload $< /disks/disk.img
527         mv $@-t $@
529 test_ext2_SOURCES = test-ext2.c test.h
530 test_ext2_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
531 test_ext2_LDADD = libtest.la $(LIBGUESTFS_LIBS)
533 endif HAVE_GUESTFISH
534 endif HAVE_EXT2
536 # file plugin test.
537 LIBNBD_TESTS += test-file
538 LIBGUESTFS_TESTS += test-file-block
540 test_file_SOURCES = test-file.c
541 test_file_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
542 test_file_LDADD = $(LIBNBD_LIBS)
544 test_file_block_SOURCES = test-file-block.c test.h
545 test_file_block_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
546 test_file_block_LDADD = libtest.la $(LIBGUESTFS_LIBS)
548 TESTS += test-file-extents.sh
550 # floppy plugin test.
551 TESTS += test-floppy.sh
553 # full plugin test.
554 TESTS += test-full.sh
556 # gzip plugin test.
557 if HAVE_ZLIB
558 LIBGUESTFS_TESTS += test-gzip
559 check_DATA += disk.gz
560 CLEANFILES += disk.gz
562 test_gzip_SOURCES = test-gzip.c test.h
563 test_gzip_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
564 test_gzip_LDADD = libtest.la $(LIBGUESTFS_LIBS)
566 disk.gz: disk
567         rm -f $@
568         gzip -9 -c disk > $@
569 endif HAVE_ZLIB
571 # info plugin test.
572 TESTS += \
573         test-info-address.sh \
574         test-info-base64.sh \
575         test-info-raw.sh \
576         test-info-time.sh \
577         test-info-uptime.sh \
578         test-info-conntime.sh \
579         $(NULL)
581 # iso plugin test.
582 if HAVE_ISO
583 TESTS += test-iso.sh
584 endif HAVE_ISO
586 # linuxdisk plugin test.
587 TESTS += \
588         test-linuxdisk.sh \
589         test-linuxdisk-copy-out.sh \
590         $(NULL)
592 # memory plugin test.
593 LIBGUESTFS_TESTS += test-memory
594 TESTS += test-memory-largest.sh test-memory-largest-for-qemu.sh
596 test_memory_SOURCES = test-memory.c test.h
597 test_memory_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
598 test_memory_LDADD = libtest.la $(LIBGUESTFS_LIBS)
600 # partitioning plugin test.
601 TESTS += \
602         test-partitioning1.sh \
603         test-partitioning2.sh \
604         test-partitioning3.sh \
605         test-partitioning4.sh \
606         test-partitioning5.sh \
607         test-partitioning6.sh \
608         $(NULL)
610 # pattern plugin test.
611 TESTS += \
612         test-pattern.sh \
613         test-pattern-largest.sh \
614         test-pattern-largest-for-qemu.sh \
615         $(NULL)
617 if HAVE_NBD_PLUGIN
618 # nbd plugin test.
619 LIBGUESTFS_TESTS += test-nbd
620 TESTS += \
621         test-nbd-extents.sh \
622         test-nbd-tls.sh \
623         test-nbd-tls-psk.sh \
624         $(NULL)
626 test_nbd_SOURCES = test-nbd.c test.h
627 test_nbd_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
628 test_nbd_LDADD = libtest.la $(LIBGUESTFS_LIBS)
629 endif HAVE_NBD_PLUGIN
631 # null plugin test.
632 LIBNBD_TESTS += test-null
633 TESTS += test-null-extents.sh
635 test_null_SOURCES = test-null.c
636 test_null_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
637 test_null_LDADD = $(LIBNBD_LIBS)
639 # random plugin test.
640 LIBNBD_TESTS += test-random
642 test_random_SOURCES = test-random.c
643 test_random_CPPFLAGS = -I $(top_srcdir)/common/include
644 test_random_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
645 test_random_LDADD = $(LIBNBD_LIBS)
647 # split files plugin test.
648 check_DATA += split1 split2 split3
649 CLEANFILES += split1 split2 split3
650 split1: file-data
651         rm -f $@ $@-t
652         dd if=$< of=$@-t bs=1 count=100
653         mv $@-t $@
654 split2: file-data
655         rm -f $@ $@-t
656         dd if=$< of=$@-t bs=1 count=100 skip=100
657         mv $@-t $@
658 split3: file-data
659         rm -f $@ $@-t
660         dd if=$< of=$@-t bs=1 skip=200
661         mv $@-t $@
662 LIBNBD_TESTS += test-split
664 test_split_SOURCES = test-split.c
665 test_split_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
666 test_split_LDADD = $(LIBNBD_LIBS)
668 # ssh plugin test.
669 if HAVE_SSH
670 # Uses â€˜disk’ so we have to make it conditional on guestfish.
671 TESTS += test-ssh.sh
672 check_DATA += \
673         ssh/sshd_config \
674         ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub \
675         ssh/authorized_keys \
676         $(NULL)
677 SSH_RANDOM_PORT := $(shell bash -c 'echo $$(( 10000 + $$RANDOM ))')
678 CLEANFILES += \
679         ssh/*~ \
680         ssh/sshd_config \
681         ssh/authorized_keys \
682         $(NULL)
683 DISTCLEANFILES += \
684         ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub \
685         ssh/id_rsa ssh/id_rsa.pub \
686         stamp-ssh-host-key stamp-ssh-user-key \
687         $(NULL)
689 ssh/sshd_config: ssh/sshd_config.in Makefile
690         rm -f $@ $@-t
691         $(SED) \
692             -e 's,__abs_builddir__,$(abs_builddir),g' \
693             -e 's,__RANDOM_PORT__,$(SSH_RANDOM_PORT),g' \
694             < $< > $@-t
695         mv $@-t $@
697 ssh/ssh_host_rsa_key ssh/ssh_host_rsa_key.pub: stamp-ssh-host-key
698 stamp-ssh-host-key:
699         rm -f $@
700         rm -f ssh/ssh_host_rsa_key
701         rm -f ssh/ssh_host_rsa_key.pub
702         ssh-keygen -t rsa -f ssh/ssh_host_rsa_key -N ''
703         touch $@
705 ssh/authorized_keys: ssh/id_rsa.pub
706         rm -f $@ $@-t
707         cp $< $@-t
708         mv $@-t $@
710 ssh/id_rsa ssh/id_rsa.pub: stamp-ssh-user-key
711 stamp-ssh-user-key:
712         rm -f $@
713         rm -f ssh/id_rsa
714         rm -f ssh/id_rsa.pub
715         ssh-keygen -t rsa -f ssh/id_rsa -N ''
716         touch $@
717 endif HAVE_SSH
719 # streaming plugin test.
720 # Doesn't work:
721 LIBNBD_TESTS += test-streaming
723 test_streaming_SOURCES = test-streaming.c
724 test_streaming_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
725 test_streaming_LDADD = $(LIBNBD_LIBS)
727 if HAVE_VDDK
728 # VDDK plugin test.
729 # This only tests that the plugin can be loaded against a
730 # dummy VDDK library, it is not a detailed test.
732 # check_LTLIBRARIES won't build a shared library (see automake manual).
733 # So we have to do this and add a dependency.
734 noinst_LTLIBRARIES += libvixDiskLib.la
735 TESTS += \
736         test-vddk.sh \
737         test-vddk-real.sh \
738         $(NULL)
740 libvixDiskLib_la_SOURCES = \
741         dummy-vddk.c \
742         $(NULL)
743 libvixDiskLib_la_CPPFLAGS = \
744         -I$(top_srcdir)/plugins/vddk \
745         $(NULL)
746 libvixDiskLib_la_CXXFLAGS = $(WARNINGS_CFLAGS)
747 # For use of the -rpath option, see:
748 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
749 libvixDiskLib_la_LDFLAGS = \
750         -shared -version-number 6:0:0 -rpath /nowhere \
751         $(NULL)
752 endif HAVE_VDDK
754 # zero plugin test.
755 TESTS += test-zero.sh
757 # -D nbdkit.backend.* settings.
758 TESTS += test-nbdkit-backend-debug.sh
760 #----------------------------------------------------------------------
761 # Tests of language plugins.
763 # OCaml plugin test.
764 if HAVE_OCAML
766 LIBGUESTFS_TESTS += test-ocaml
768 # This is somewhat different from the other tests because we have
769 # to build an actual plugin here.
770 test_ocaml_SOURCES = test-ocaml.c test.h
771 test_ocaml_CFLAGS = \
772         $(WARNINGS_CFLAGS) \
773         $(LIBGUESTFS_CFLAGS) \
774         $(NULL)
775 test_ocaml_LDADD = libtest.la $(LIBGUESTFS_LIBS)
777 check_SCRIPTS += test-ocaml-plugin.so
778 test-ocaml-plugin.so: test_ocaml_plugin.cmx ../plugins/ocaml/libnbdkitocaml.la ../plugins/ocaml/NBDKit.cmi ../plugins/ocaml/NBDKit.cmx
779         $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../plugins/ocaml \
780           -output-obj -runtime-variant _pic -o $@ \
781           NBDKit.cmx $< \
782           -cclib -L../plugins/ocaml/.libs -cclib -lnbdkitocaml
783 test_ocaml_plugin.cmx: test_ocaml_plugin.ml ../plugins/ocaml/NBDKit.cmi
784         $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../plugins/ocaml -c $< -o $@
786 endif HAVE_OCAML
788 # perl plugin test.
789 if HAVE_PERL
791 TESTS += \
792         test-dump-plugin-example4.sh \
793         test-shebang-perl.sh \
794         $(NULL)
795 LIBGUESTFS_TESTS += test-perl
797 test_perl_SOURCES = test-lang-plugins.c test.h
798 test_perl_CFLAGS = \
799         -DLANG='"perl"' -DSCRIPT='"$(srcdir)/test.pl"' \
800         $(WARNINGS_CFLAGS) \
801         $(LIBGUESTFS_CFLAGS) \
802         $(NULL)
803 test_perl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
805 endif HAVE_PERL
807 # python plugin test.
808 if HAVE_PYTHON
810 TESTS += \
811         test-python.sh \
812         test-python-exception.sh \
813         test-shebang-python.sh \
814         $(NULL)
816 endif HAVE_PYTHON
818 # Ruby plugin test.
819 if HAVE_RUBY
821 # Ruby tests are disabled.  See "WARNING" section in
822 # plugins/ruby/nbdkit-ruby-plugin.pod
824 #LIBGUESTFS_TESTS += \
825 #       test-ruby \
826 #       $(NULL)
827 #TESTS += test-shebang-ruby.sh
828 EXTRA_PROGRAMS += test-ruby
830 test_ruby_SOURCES = test-lang-plugins.c test.h
831 test_ruby_CFLAGS = \
832         -DLANG='"ruby"' -DSCRIPT='"$(srcdir)/test.rb"' \
833         $(WARNINGS_CFLAGS) \
834         $(LIBGUESTFS_CFLAGS) \
835         $(NULL)
836 test_ruby_LDADD = libtest.la $(LIBGUESTFS_LIBS)
838 endif HAVE_RUBY
840 # Shell (sh) plugin test.
841 LIBGUESTFS_TESTS += test-shell
842 check_DATA += test-shell.img
843 CLEANFILES += test-shell.img
845 test_shell_SOURCES = test-lang-plugins.c test.h
846 test_shell_CFLAGS = \
847         -DLANG='"sh"' -DSCRIPT='"$(srcdir)/test-shell.sh"' \
848         $(WARNINGS_CFLAGS) \
849         $(LIBGUESTFS_CFLAGS) \
850         $(NULL)
851 test_shell_LDADD = libtest.la $(LIBGUESTFS_LIBS)
853 test-shell.img:
854         truncate -s 1048576 $@
856 TESTS += \
857         test-sh-errors.sh \
858         test-sh-extents.sh \
859         $(NULL)
861 # Tcl plugin test.
862 if HAVE_TCL
864 LIBGUESTFS_TESTS += test-tcl
866 test_tcl_SOURCES = test-lang-plugins.c test.h
867 test_tcl_CFLAGS = \
868         -DLANG='"tcl"' -DSCRIPT='"$(srcdir)/test.tcl"' \
869         $(WARNINGS_CFLAGS) \
870         $(LIBGUESTFS_CFLAGS) \
871         $(NULL)
872 test_tcl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
874 endif HAVE_TCL
876 # Lua plugin test.
877 if HAVE_LUA
879 LIBGUESTFS_TESTS += test-lua
881 test_lua_SOURCES = test-lang-plugins.c test.h
882 test_lua_CFLAGS = \
883         -DLANG='"lua"' -DSCRIPT='"$(srcdir)/test.lua"' \
884         $(WARNINGS_CFLAGS) \
885         $(LIBGUESTFS_CFLAGS) \
886         $(NULL)
887 test_lua_LDADD = libtest.la $(LIBGUESTFS_LIBS)
889 endif HAVE_LUA
891 #----------------------------------------------------------------------
892 # Tests of filters.
894 # Generic test of filter layers.
895 check_PROGRAMS += test-layers
896 TESTS += test-layers.sh test-layers
898 test_layers_SOURCES = \
899         test-layers.c \
900         $(NULL)
901 test_layers_CPPFLAGS = \
902         -I$(top_srcdir)/common/include \
903         -I$(top_srcdir)/common/protocol \
904         -I$(top_srcdir)/common/utils \
905         -I$(top_srcdir)/server \
906         $(NULL)
907 test_layers_CFLAGS = \
908         $(WARNINGS_CFLAGS) \
909         $(PTHREAD_CFLAGS) \
910         $(NULL)
911 test_layers_LDFLAGS = \
912         $(PTHREAD_LIBS) \
913         $(NULL)
914 test_layers_LDADD = \
915         $(top_builddir)/common/utils/libutils.la \
916         $(NULL)
917 test_layers_DEPENDENCIES = \
918         test-layers-plugin.la \
919         test-layers-filter1.la \
920         test-layers-filter2.la \
921         test-layers-filter3.la \
922         $(NULL)
924 # check_LTLIBRARIES won't build a shared library (see automake manual).
925 # So we have to do this and add a dependency.
926 noinst_LTLIBRARIES += \
927         test-layers-plugin.la \
928         test-layers-filter1.la \
929         test-layers-filter2.la \
930         test-layers-filter3.la \
931         $(NULL)
933 test_layers_plugin_la_SOURCES = \
934         test-layers-plugin.c \
935         $(top_srcdir)/include/nbdkit-plugin.h \
936         $(NULL)
937 test_layers_plugin_la_CPPFLAGS = -I$(top_srcdir)/include
938 test_layers_plugin_la_CFLAGS = $(WARNINGS_CFLAGS)
939 # For use of the -rpath option, see:
940 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
941 test_layers_plugin_la_LDFLAGS = \
942         -module -avoid-version -shared -rpath /nowhere \
943         $(NULL)
945 test_layers_filter1_la_SOURCES = \
946         test-layers-filter.c \
947         $(top_srcdir)/include/nbdkit-filter.h \
948         $(NULL)
949 test_layers_filter1_la_CPPFLAGS = -I$(top_srcdir)/include
950 test_layers_filter1_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter1"'
951 # For use of the -rpath option, see:
952 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
953 test_layers_filter1_la_LDFLAGS = \
954         -module -avoid-version -shared -rpath /nowhere \
955         $(NULL)
957 test_layers_filter2_la_SOURCES = \
958         test-layers-filter.c \
959         $(top_srcdir)/include/nbdkit-filter.h \
960         $(NULL)
961 test_layers_filter2_la_CPPFLAGS = -I$(top_srcdir)/include
962 test_layers_filter2_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter2"'
963 # For use of the -rpath option, see:
964 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
965 test_layers_filter2_la_LDFLAGS = \
966         -module -avoid-version -shared -rpath /nowhere \
967         $(NULL)
969 test_layers_filter3_la_SOURCES = \
970         test-layers-filter.c \
971         $(top_srcdir)/include/nbdkit-filter.h \
972         $(NULL)
973 test_layers_filter3_la_CPPFLAGS = -I$(top_srcdir)/include
974 test_layers_filter3_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter3"'
975 # For use of the -rpath option, see:
976 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
977 test_layers_filter3_la_LDFLAGS = \
978         -module -avoid-version -shared -rpath /nowhere \
979         $(NULL)
981 # blocksize filter test.
982 TESTS += test-blocksize.sh
984 # cache filter test.
985 TESTS += \
986         test-cache.sh \
987         test-cache-on-read.sh \
988         $(NULL)
989 TESTS += test-cache-max-size.sh
991 # cacheextents filter test.
992 TESTS += test-cacheextents.sh
994 # cow filter test.
995 TESTS += \
996         test-cow.sh \
997         test-cow-null.sh \
998         $(NULL)
1000 # delay filter tests.
1001 TESTS += test-shutdown.sh
1002 LIBNBD_TESTS += test-delay
1004 test_delay_SOURCES = test-delay.c
1005 test_delay_CFLAGS = $(WARNINGS_CFLAGS) $(LIBNBD_CFLAGS)
1006 test_delay_LDADD = $(LIBNBD_LIBS)
1008 # error filter test.
1009 TESTS += \
1010         test-error0.sh \
1011         test-error10.sh \
1012         test-error100.sh \
1013         test-error-triggered.sh \
1014         $(NULL)
1016 # fua filter test.
1017 TESTS += test-fua.sh
1019 # ip filter test.
1020 TESTS += test-ip-filter.sh
1022 # log filter test.
1023 TESTS += test-log.sh
1025 # nofilter test.
1026 TESTS += test-nofilter.sh
1028 if HAVE_NBD_PLUGIN
1029 # nozero filter test.
1030 TESTS += test-nozero.sh
1031 endif HAVE_NBD_PLUGIN
1033 # offset filter test.
1034 LIBGUESTFS_TESTS += test-offset
1036 test_offset_SOURCES = test-offset.c test.h
1037 test_offset_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
1038 test_offset_LDADD = libtest.la $(LIBGUESTFS_LIBS)
1040 TESTS += \
1041         test-offset2.sh \
1042         test-offset-extents.sh \
1043         $(NULL)
1045 # partition filter test.
1046 TESTS += test-partition1.sh
1047 TESTS += test-partition2.sh
1049 # rate filter test.
1050 TESTS += \
1051         test-rate.sh \
1052         test-rate-dynamic.sh \
1053         $(NULL)
1055 # readahead filter test.
1056 TESTS += \
1057         test-readahead.sh \
1058         test-readahead-copy.sh \
1059         $(NULL)
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 LIBGUESTFS_TESTS += test-xz
1083 check_DATA += disk.xz
1084 CLEANFILES += disk.xz
1086 test_xz_SOURCES = test-xz.c test.h
1087 test_xz_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
1088 test_xz_LDADD = libtest.la $(LIBGUESTFS_LIBS)
1090 disk.xz: disk
1091         rm -f $@
1092 # We choose a very small block size here only for testing.  Normally
1093 # you should choose a 16M block size.
1094         xz --best --block-size=32768 -c disk > $@
1096 # xz filter + curl.
1097 if HAVE_CURL
1098 LIBGUESTFS_TESTS += test-xz-curl
1100 test_xz_curl_SOURCES = \
1101         test-xz-curl.c \
1102         web-server.c \
1103         web-server.h \
1104         test.h \
1105         $(NULL)
1106 test_xz_curl_CPPFLAGS = \
1107         -I$(top_srcdir)/common/utils
1108 test_xz_curl_CFLAGS = \
1109         $(WARNINGS_CFLAGS) \
1110         $(LIBGUESTFS_CFLAGS) \
1111         $(PTHREAD_CFLAGS) \
1112         $(NULL)
1113 test_xz_curl_LDFLAGS = \
1114         $(top_builddir)/common/utils/libutils.la \
1115         $(PTHREAD_LIBS) \
1116         $(NULL)
1117 test_xz_curl_LDADD = \
1118         libtest.la \
1119         $(LIBGUESTFS_LIBS) \
1120         $(NULL)
1122 endif HAVE_CURL
1123 endif HAVE_LIBLZMA
1125 endif HAVE_PLUGINS
1127 #----------------------------------------------------------------------
1129 if HAVE_LIBNBD
1130 check_PROGRAMS += $(LIBNBD_TESTS)
1131 TESTS += $(LIBNBD_TESTS)
1132 endif HAVE_LIBNBD
1134 if HAVE_LIBGUESTFS
1135 check_PROGRAMS += $(LIBGUESTFS_TESTS)
1136 TESTS += $(LIBGUESTFS_TESTS)
1137 endif HAVE_LIBGUESTFS