tests: Make all guestfish tests use runtime check.
[nbdkit/ericb.git] / tests / Makefile.am
blob4709020b80677025ec729d992beec5ac9e880db9
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 if HAVE_VDDK
166 # Run a basic check against a real copy of VDDK.  You must set
167 # vddkdir to point to the library location, eg:
169 #   make check-vddk vddkdir=vmware-vix-disklib-distrib
170 check-vddk:
171         $(MAKE) check TESTS=test-vddk-real.sh
172 endif HAVE_VDDK
174 #----------------------------------------------------------------------
175 # Basic test variables.
177 # TESTS: Tests that don't have any special requirements.
179 # LIBGUESTFS_TESTS: Tests that link to libguestfs C library should be
180 # added to this variable.
182 # check_*, noinst_*, EXTRA_PROGRAMS: Usual automake variables.
183 # Consult the automake manual for the meaning of these.
185 TESTS =
186 LIBGUESTFS_TESTS =
188 check_PROGRAMS =
189 check_DATA =
190 check_SCRIPTS =
191 check_LTLIBRARIES =
192 noinst_LTLIBRARIES =
193 EXTRA_PROGRAMS =
195 # Ensure we're testing the local copy by running everything through
196 # the nbdkit helper script in the top build directory.
198 # Use the 'direct' backend, and ensure maximum libguestfs debugging.
200 # Enable libnbd debugging.
201 TESTS_ENVIRONMENT = \
202         PATH=$(abs_top_builddir):$(PATH) \
203         SRCDIR=$(srcdir) \
204         LIBGUESTFS_ATTACH_METHOD=appliance \
205         LIBGUESTFS_DEBUG=1 \
206         LIBGUESTFS_TRACE=1 \
207         LIBNBD_DEBUG=1 \
208         $(NULL)
210 #----------------------------------------------------------------------
211 # Basic server command line and start-up tests.
213 TESTS += \
214         test-help.sh \
215         test-version.sh \
216         test-dump-config.sh \
217         $(NULL)
219 if HAVE_PLUGINS
221 TESTS += \
222         test-help-plugin.sh \
223         test-version-plugin.sh \
224         test-version-filter.sh \
225         test-dump-plugin.sh \
226         test-start.sh \
227         test-single.sh \
228         test-single-from-file.sh \
229         test-captive.sh \
230         test-random-sock.sh \
231         test-tls.sh \
232         test-tls-psk.sh \
233         test-ip.sh \
234         test-socket-activation \
235         test-foreground.sh \
236         test-debug-flags.sh \
237         test-long-name.sh \
238         $(NULL)
240 check_PROGRAMS += \
241         test-socket-activation \
242         $(NULL)
244 test_socket_activation_SOURCES = test-socket-activation.c
245 test_socket_activation_CPPFLAGS = \
246         -I$(top_srcdir)/common/include \
247         -I$(top_srcdir)/common/protocol \
248         $(NULL)
249 test_socket_activation_CFLAGS = $(WARNINGS_CFLAGS)
251 endif HAVE_PLUGINS
253 # Test the header files can be included on their own.
254 check_PROGRAMS += \
255         test-just-plugin-header \
256         test-just-filter-header
257         $(NULL)
258 TESTS += \
259         test-just-plugin-header \
260         test-just-filter-header
261         $(NULL)
263 test_just_plugin_header_SOURCES = \
264         test-just-plugin-header.c \
265         $(NULL)
266 test_just_plugin_header_CPPFLAGS = \
267         -I$(top_srcdir)/include \
268         $(NULL)
269 test_just_plugin_header_CFLAGS = $(WARNINGS_CFLAGS)
271 test_just_filter_header_SOURCES = \
272         test-just-filter-header.c \
273         $(NULL)
274 test_just_filter_header_CPPFLAGS = \
275         -I$(top_srcdir)/include \
276         $(NULL)
277 test_just_filter_header_CFLAGS = $(WARNINGS_CFLAGS)
279 if CAN_TEST_ANSI_C
280 # This builds a plugin using an ANSI (ISO C90) compiler to ensure that
281 # the header file is compatible.  The plugin does nothing very
282 # interesting, it's mainly a compile test.
283 TESTS += \
284         test-ansi-c.sh \
285         $(NULL)
286 # check_LTLIBRARIES won't build a shared library (see automake manual).
287 # So we have to do this and add a dependency.
288 noinst_LTLIBRARIES += test-ansi-c-plugin.la
289 test-ansi-c.sh: test-ansi-c-plugin.la
291 test_ansi_c_plugin_la_SOURCES = \
292         test-ansi-c-plugin.c \
293         $(top_srcdir)/include/nbdkit-plugin.h \
294         $(NULL)
295 test_ansi_c_plugin_la_CPPFLAGS = \
296         -std=c90 -pedantic \
297         -I$(top_srcdir)/include \
298         $(NULL)
299 test_ansi_c_plugin_la_CFLAGS = $(WARNINGS_CFLAGS)
300 # For use of the -rpath option, see:
301 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
302 test_ansi_c_plugin_la_LDFLAGS = \
303         -module -avoid-version -shared -rpath /nowhere \
304         $(NULL)
305 endif CAN_TEST_ANSI_C
307 if HAVE_CXX
308 # This builds a plugin and a filter using the C++ compiler.  They
309 # don't do anything interesting when run.
310 TESTS += \
311         test-cxx.sh \
312         $(NULL)
313 # check_LTLIBRARIES won't build a shared library (see automake manual).
314 # So we have to do this and add a dependency.
315 noinst_LTLIBRARIES += test-cxx-plugin.la test-cxx-filter.la
316 test-cxx.sh: test-cxx-plugin.la test-cxx-filter.la
318 test_cxx_plugin_la_SOURCES = \
319         test-cxx-plugin.cpp \
320         $(top_srcdir)/include/nbdkit-plugin.h \
321         $(NULL)
322 test_cxx_plugin_la_CPPFLAGS = \
323         -I$(top_srcdir)/include \
324         $(NULL)
325 test_cxx_plugin_la_CXXFLAGS = $(WARNINGS_CFLAGS)
326 # For use of the -rpath option, see:
327 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
328 test_cxx_plugin_la_LDFLAGS = \
329         -module -avoid-version -shared -rpath /nowhere \
330         $(NULL)
332 test_cxx_filter_la_SOURCES = \
333         test-cxx-filter.cpp \
334         $(top_srcdir)/include/nbdkit-filter.h \
335         $(NULL)
336 test_cxx_filter_la_CPPFLAGS = \
337         -I$(top_srcdir)/include \
338         $(NULL)
339 test_cxx_filter_la_CXXFLAGS = $(WARNINGS_CFLAGS)
340 # For use of the -rpath option, see:
341 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
342 test_cxx_filter_la_LDFLAGS = \
343         -module -avoid-version -shared -rpath /nowhere \
344         $(NULL)
345 endif HAVE_CXX
347 # Exit with parent test.
348 check_PROGRAMS += test-exit-with-parent
349 TESTS += test-exit-with-parent
351 test_exit_with_parent_SOURCES = \
352         test-exit-with-parent.c test.h \
353         $(NULL)
354 test_exit_with_parent_CPPFLAGS = \
355         -I$(top_srcdir)/common/include \
356         $(NULL)
357 test_exit_with_parent_CFLAGS = \
358         $(WARNINGS_CFLAGS) \
359         $(LIBGUESTFS_CFLAGS) \
360         $(NULL)
362 # PKI files for the TLS tests.
363 check_DATA += pki/.stamp
364 pki/.stamp: $(srcdir)/make-pki.sh
365         SRCDIR=$(srcdir) $(srcdir)/make-pki.sh
367 # PSK keys for the TLS-PSK tests.
368 check_DATA += keys.psk
369 keys.psk: $(srcdir)/make-psk.sh
370         SRCDIR=$(srcdir) $(srcdir)/make-psk.sh
372 # Keys are expensive to recreate so only delete them when we do
373 # â€˜make distclean’.
374 DISTCLEANFILES = keys.psk
375 distclean-local: distclean-local-tls
376 distclean-local-tls:
377         rm -rf pki
379 #----------------------------------------------------------------------
380 # Tests of C plugins or tests which require plugins.
382 if HAVE_PLUGINS
384 # Common data shared by multiple tests
385 check_DATA += file-data
386 CLEANFILES += file-data
387 file-data: generate-file-data.sh
388         $(srcdir)/generate-file-data.sh $@
390 # While most tests need libguestfs, testing parallel I/O is easier when
391 # using qemu-io to kick off asynchronous requests.
392 TESTS += \
393         test-parallel-file.sh \
394         test-parallel-nbd.sh \
395         test-parallel-sh.sh \
396         $(NULL)
398 # Common test library.
399 check_LTLIBRARIES += libtest.la
400 libtest_la_SOURCES = test.c test.h
401 libtest_la_CFLAGS = $(WARNINGS_CFLAGS)
403 # Basic connection test.
404 LIBGUESTFS_TESTS += test-connect
406 test_connect_SOURCES = test-connect.c test.h
407 test_connect_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
408 test_connect_LDADD = libtest.la $(LIBGUESTFS_LIBS)
410 # newstyle protocol test.
411 LIBGUESTFS_TESTS += test-newstyle
413 test_newstyle_SOURCES = test-newstyle.c test.h
414 test_newstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
415 test_newstyle_LDADD = libtest.la $(LIBGUESTFS_LIBS)
417 # oldstyle protocol test.
418 LIBGUESTFS_TESTS += test-oldstyle
420 test_oldstyle_SOURCES = test-oldstyle.c test.h
421 test_oldstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
422 test_oldstyle_LDADD = libtest.la $(LIBGUESTFS_LIBS)
424 # Test export flags.
425 TESTS += test-eflags.sh
427 # Test export name.
428 TESTS += test-export-name.sh
430 # common disk image shared with several tests
431 if HAVE_GUESTFISH
432 check_DATA += disk
433 CLEANFILES += disk
435 disk:
436         rm -f $@ $@-t
437         guestfish -N $@-t=fs:ext4:100M -m /dev/sda1 \
438             write /hello.txt "hello,world"
439         mv $@-t $@
441 endif HAVE_GUESTFISH
443 # curl plugin test.
445 if HAVE_CURL
446 if HAVE_GUESTFISH
448 # curl plugin test.
449 LIBGUESTFS_TESTS += test-curl
451 test_curl_SOURCES = \
452         test-curl.c \
453         web-server.c \
454         web-server.h \
455         test.h \
456         $(NULL)
457 test_curl_CPPFLAGS = \
458         -I$(top_srcdir)/common/utils
459 test_curl_CFLAGS = \
460         $(WARNINGS_CFLAGS) \
461         $(LIBGUESTFS_CFLAGS) \
462         $(PTHREAD_CFLAGS) \
463         $(NULL)
464 test_curl_LDFLAGS = \
465         $(top_builddir)/common/utils/libutils.la \
466         $(PTHREAD_LIBS) \
467         $(NULL)
468 test_curl_LDADD = \
469         libtest.la \
470         $(LIBGUESTFS_LIBS) \
471         $(NULL)
473 endif HAVE_GUESTFISH
474 endif HAVE_CURL
476 # data plugin test.
477 LIBGUESTFS_TESTS += test-data
478 TESTS += \
479         test-data-7E.sh \
480         test-data-base64.sh \
481         test-data-extents.sh \
482         test-data-file.sh \
483         test-data-raw.sh \
484         $(NULL)
486 test_data_SOURCES = test-data.c test.h
487 test_data_CPPFLAGS = -I$(top_srcdir)/common/include
488 test_data_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
489 test_data_LDADD = libtest.la $(LIBGUESTFS_LIBS)
491 # ext2 plugin test.
492 if HAVE_EXT2
493 if HAVE_GUESTFISH
495 LIBGUESTFS_TESTS += test-ext2
496 check_DATA += ext2.img
497 CLEANFILES += ext2.img
499 ext2.img: disk
500         rm -f $@ $@-t
501         guestfish \
502             sparse $@-t 2G : \
503             run : \
504             mkfs ext4 /dev/sda : \
505             mount /dev/sda / : \
506             mkdir /disks : \
507             upload $< /disks/disk.img
508         mv $@-t $@
510 test_ext2_SOURCES = test-ext2.c test.h
511 test_ext2_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
512 test_ext2_LDADD = libtest.la $(LIBGUESTFS_LIBS)
514 endif HAVE_GUESTFISH
515 endif HAVE_EXT2
517 # file plugin test.
518 LIBGUESTFS_TESTS += test-file test-file-block
520 test_file_SOURCES = test-file.c test.h
521 test_file_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
522 test_file_LDADD = libtest.la $(LIBGUESTFS_LIBS)
524 test_file_block_SOURCES = test-file-block.c test.h
525 test_file_block_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
526 test_file_block_LDADD = libtest.la $(LIBGUESTFS_LIBS)
528 if HAVE_GUESTFISH
529 TESTS += test-file-extents.sh
530 endif HAVE_GUESTFISH
532 # floppy plugin test.
533 TESTS += test-floppy.sh
535 # full plugin test.
536 TESTS += test-full.sh
538 # gzip plugin test.
539 if HAVE_ZLIB
540 if HAVE_GUESTFISH
542 LIBGUESTFS_TESTS += test-gzip
543 check_DATA += disk.gz
544 CLEANFILES += disk.gz
546 test_gzip_SOURCES = test-gzip.c test.h
547 test_gzip_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
548 test_gzip_LDADD = libtest.la $(LIBGUESTFS_LIBS)
550 disk.gz: disk
551         rm -f $@
552         gzip -9 -c disk > $@
554 endif HAVE_GUESTFISH
555 endif HAVE_ZLIB
557 # info plugin test.
558 TESTS += \
559         test-info-address.sh \
560         test-info-base64.sh \
561         test-info-raw.sh \
562         test-info-time.sh \
563         test-info-uptime.sh \
564         test-info-conntime.sh \
565         $(NULL)
567 # iso plugin test.
568 if HAVE_ISO
569 TESTS += test-iso.sh
570 endif HAVE_ISO
572 # linuxdisk plugin test.
573 TESTS += \
574         test-linuxdisk.sh \
575         test-linuxdisk-copy-out.sh \
576         $(NULL)
578 # memory plugin test.
579 LIBGUESTFS_TESTS += test-memory
580 TESTS += test-memory-largest.sh test-memory-largest-for-qemu.sh
582 test_memory_SOURCES = test-memory.c test.h
583 test_memory_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
584 test_memory_LDADD = libtest.la $(LIBGUESTFS_LIBS)
586 # partitioning plugin test.
587 TESTS += \
588         test-partitioning1.sh \
589         test-partitioning2.sh \
590         test-partitioning3.sh \
591         test-partitioning4.sh \
592         test-partitioning5.sh \
593         test-partitioning6.sh \
594         $(NULL)
596 # pattern plugin test.
597 TESTS += \
598         test-pattern.sh \
599         test-pattern-largest.sh \
600         test-pattern-largest-for-qemu.sh \
601         $(NULL)
603 if HAVE_NBD_PLUGIN
604 # nbd plugin test.
605 LIBGUESTFS_TESTS += test-nbd
606 TESTS += \
607         test-nbd-extents.sh \
608         test-nbd-tls.sh \
609         test-nbd-tls-psk.sh \
610         $(NULL)
612 test_nbd_SOURCES = test-nbd.c test.h
613 test_nbd_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
614 test_nbd_LDADD = libtest.la $(LIBGUESTFS_LIBS)
615 endif HAVE_NBD_PLUGIN
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 if HAVE_VDDK
717 # VDDK plugin test.
718 # This only tests that the plugin can be loaded against a
719 # dummy VDDK library, it is not a detailed test.
721 # check_LTLIBRARIES won't build a shared library (see automake manual).
722 # So we have to do this and add a dependency.
723 noinst_LTLIBRARIES += libvixDiskLib.la
724 TESTS += \
725         test-vddk.sh \
726         test-vddk-real.sh \
727         $(NULL)
729 libvixDiskLib_la_SOURCES = \
730         dummy-vddk.c \
731         $(NULL)
732 libvixDiskLib_la_CPPFLAGS = \
733         -I$(top_srcdir)/plugins/vddk \
734         $(NULL)
735 libvixDiskLib_la_CXXFLAGS = $(WARNINGS_CFLAGS)
736 # For use of the -rpath option, see:
737 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
738 libvixDiskLib_la_LDFLAGS = \
739         -shared -version-number 6:0:0 -rpath /nowhere \
740         $(NULL)
741 endif HAVE_VDDK
743 # zero plugin test.
744 TESTS += test-zero.sh
746 #----------------------------------------------------------------------
747 # Tests of language plugins.
749 # OCaml plugin test.
750 if HAVE_OCAML
752 LIBGUESTFS_TESTS += test-ocaml
754 # This is somewhat different from the other tests because we have
755 # to build an actual plugin here.
756 test_ocaml_SOURCES = test-ocaml.c test.h
757 test_ocaml_CFLAGS = \
758         $(WARNINGS_CFLAGS) \
759         $(LIBGUESTFS_CFLAGS) \
760         $(NULL)
761 test_ocaml_LDADD = libtest.la $(LIBGUESTFS_LIBS)
763 check_SCRIPTS += test-ocaml-plugin.so
764 test-ocaml-plugin.so: test_ocaml_plugin.cmx ../plugins/ocaml/libnbdkitocaml.la ../plugins/ocaml/NBDKit.cmi ../plugins/ocaml/NBDKit.cmx
765         $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../plugins/ocaml \
766           -output-obj -runtime-variant _pic -o $@ \
767           NBDKit.cmx $< \
768           -cclib -L../plugins/ocaml/.libs -cclib -lnbdkitocaml
769 test_ocaml_plugin.cmx: test_ocaml_plugin.ml ../plugins/ocaml/NBDKit.cmi
770         $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../plugins/ocaml -c $< -o $@
772 endif HAVE_OCAML
774 # perl plugin test.
775 if HAVE_PERL
777 TESTS += \
778         test-dump-plugin-example4.sh \
779         test-shebang-perl.sh \
780         $(NULL)
781 LIBGUESTFS_TESTS += test-perl
783 test_perl_SOURCES = test-lang-plugins.c test.h
784 test_perl_CFLAGS = \
785         -DLANG='"perl"' -DSCRIPT='"$(srcdir)/test.pl"' \
786         $(WARNINGS_CFLAGS) \
787         $(LIBGUESTFS_CFLAGS) \
788         $(NULL)
789 test_perl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
791 endif HAVE_PERL
793 # python plugin test.
794 if HAVE_PYTHON
796 TESTS += \
797         test-python-exception.sh \
798         test-shebang-python.sh \
799         $(NULL)
800 LIBGUESTFS_TESTS += test-python
802 test_python_SOURCES = test-lang-plugins.c test.h
803 test_python_CFLAGS = \
804         -DLANG='"python"' -DSCRIPT='"$(srcdir)/test.py"' \
805         $(WARNINGS_CFLAGS) \
806         $(LIBGUESTFS_CFLAGS) \
807         $(NULL)
808 test_python_LDADD = libtest.la $(LIBGUESTFS_LIBS)
810 endif HAVE_PYTHON
812 # Ruby plugin test.
813 if HAVE_RUBY
815 # Ruby tests are disabled.  See "WARNING" section in
816 # plugins/ruby/nbdkit-ruby-plugin.pod
818 #LIBGUESTFS_TESTS += \
819 #       test-ruby \
820 #       $(NULL)
821 #TESTS += test-shebang-ruby.sh
822 EXTRA_PROGRAMS += test-ruby
824 test_ruby_SOURCES = test-lang-plugins.c test.h
825 test_ruby_CFLAGS = \
826         -DLANG='"ruby"' -DSCRIPT='"$(srcdir)/test.rb"' \
827         $(WARNINGS_CFLAGS) \
828         $(LIBGUESTFS_CFLAGS) \
829         $(NULL)
830 test_ruby_LDADD = libtest.la $(LIBGUESTFS_LIBS)
832 endif HAVE_RUBY
834 # Shell (sh) plugin test.
835 LIBGUESTFS_TESTS += test-shell
836 check_DATA += test-shell.img
837 CLEANFILES += test-shell.img
839 test_shell_SOURCES = test-lang-plugins.c test.h
840 test_shell_CFLAGS = \
841         -DLANG='"sh"' -DSCRIPT='"$(srcdir)/test-shell.sh"' \
842         $(WARNINGS_CFLAGS) \
843         $(LIBGUESTFS_CFLAGS) \
844         $(NULL)
845 test_shell_LDADD = libtest.la $(LIBGUESTFS_LIBS)
847 test-shell.img:
848         truncate -s 1048576 $@
850 TESTS += \
851         test-sh-errors.sh \
852         test-sh-extents.sh \
853         $(NULL)
855 # Tcl plugin test.
856 if HAVE_TCL
858 LIBGUESTFS_TESTS += test-tcl
860 test_tcl_SOURCES = test-lang-plugins.c test.h
861 test_tcl_CFLAGS = \
862         -DLANG='"tcl"' -DSCRIPT='"$(srcdir)/test.tcl"' \
863         $(WARNINGS_CFLAGS) \
864         $(LIBGUESTFS_CFLAGS) \
865         $(NULL)
866 test_tcl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
868 endif HAVE_TCL
870 # Lua plugin test.
871 if HAVE_LUA
873 LIBGUESTFS_TESTS += test-lua
875 test_lua_SOURCES = test-lang-plugins.c test.h
876 test_lua_CFLAGS = \
877         -DLANG='"lua"' -DSCRIPT='"$(srcdir)/test.lua"' \
878         $(WARNINGS_CFLAGS) \
879         $(LIBGUESTFS_CFLAGS) \
880         $(NULL)
881 test_lua_LDADD = libtest.la $(LIBGUESTFS_LIBS)
883 endif HAVE_LUA
885 #----------------------------------------------------------------------
886 # Tests of filters.
888 # Generic test of filter layers.
889 check_PROGRAMS += test-layers
890 TESTS += test-layers.sh test-layers
892 test_layers_SOURCES = \
893         test-layers.c \
894         $(NULL)
895 test_layers_CPPFLAGS = \
896         -I$(top_srcdir)/common/include \
897         -I$(top_srcdir)/common/protocol \
898         -I$(top_srcdir)/common/utils \
899         -I$(top_srcdir)/server \
900         $(NULL)
901 test_layers_CFLAGS = \
902         $(WARNINGS_CFLAGS) \
903         $(PTHREAD_CFLAGS) \
904         $(NULL)
905 test_layers_LDFLAGS = \
906         $(PTHREAD_LIBS) \
907         $(NULL)
908 test_layers_LDADD = \
909         $(top_builddir)/common/utils/libutils.la \
910         $(NULL)
911 test_layers_DEPENDENCIES = \
912         test-layers-plugin.la \
913         test-layers-filter1.la \
914         test-layers-filter2.la \
915         test-layers-filter3.la \
916         $(NULL)
918 # check_LTLIBRARIES won't build a shared library (see automake manual).
919 # So we have to do this and add a dependency.
920 noinst_LTLIBRARIES += \
921         test-layers-plugin.la \
922         test-layers-filter1.la \
923         test-layers-filter2.la \
924         test-layers-filter3.la \
925         $(NULL)
927 test_layers_plugin_la_SOURCES = \
928         test-layers-plugin.c \
929         $(top_srcdir)/include/nbdkit-plugin.h \
930         $(NULL)
931 test_layers_plugin_la_CPPFLAGS = -I$(top_srcdir)/include
932 test_layers_plugin_la_CFLAGS = $(WARNINGS_CFLAGS)
933 # For use of the -rpath option, see:
934 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
935 test_layers_plugin_la_LDFLAGS = \
936         -module -avoid-version -shared -rpath /nowhere \
937         $(NULL)
939 test_layers_filter1_la_SOURCES = \
940         test-layers-filter.c \
941         $(top_srcdir)/include/nbdkit-filter.h \
942         $(NULL)
943 test_layers_filter1_la_CPPFLAGS = -I$(top_srcdir)/include
944 test_layers_filter1_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter1"'
945 # For use of the -rpath option, see:
946 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
947 test_layers_filter1_la_LDFLAGS = \
948         -module -avoid-version -shared -rpath /nowhere \
949         $(NULL)
951 test_layers_filter2_la_SOURCES = \
952         test-layers-filter.c \
953         $(top_srcdir)/include/nbdkit-filter.h \
954         $(NULL)
955 test_layers_filter2_la_CPPFLAGS = -I$(top_srcdir)/include
956 test_layers_filter2_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter2"'
957 # For use of the -rpath option, see:
958 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
959 test_layers_filter2_la_LDFLAGS = \
960         -module -avoid-version -shared -rpath /nowhere \
961         $(NULL)
963 test_layers_filter3_la_SOURCES = \
964         test-layers-filter.c \
965         $(top_srcdir)/include/nbdkit-filter.h \
966         $(NULL)
967 test_layers_filter3_la_CPPFLAGS = -I$(top_srcdir)/include
968 test_layers_filter3_la_CFLAGS = $(WARNINGS_CFLAGS) -Dlayer='"filter3"'
969 # For use of the -rpath option, see:
970 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
971 test_layers_filter3_la_LDFLAGS = \
972         -module -avoid-version -shared -rpath /nowhere \
973         $(NULL)
975 # blocksize filter test.
976 TESTS += test-blocksize.sh
978 # cache filter test.
979 TESTS += \
980         test-cache.sh \
981         test-cache-on-read.sh \
982         $(NULL)
983 TESTS += test-cache-max-size.sh
985 # cacheextents filter test.
986 TESTS += test-cacheextents.sh
988 # cow filter test.
989 TESTS += \
990         test-cow.sh \
991         test-cow-null.sh \
992         $(NULL)
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 if HAVE_NBD_PLUGIN
1022 # nozero filter test.
1023 TESTS += test-nozero.sh
1024 endif HAVE_NBD_PLUGIN
1026 # offset filter test.
1027 check_DATA += offset-data
1028 CLEANFILES += offset-data
1029 LIBGUESTFS_TESTS += test-offset
1031 offset-data: generate-offset-data.sh
1032         $(srcdir)/generate-offset-data.sh $@
1034 test_offset_SOURCES = test-offset.c test.h
1035 test_offset_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
1036 test_offset_LDADD = libtest.la $(LIBGUESTFS_LIBS)
1038 TESTS += \
1039         test-offset2.sh \
1040         test-offset-extents.sh \
1041         $(NULL)
1043 # partition filter test.
1044 TESTS += test-partition1.sh
1045 if HAVE_GUESTFISH
1046 TESTS += test-partition2.sh
1047 endif HAVE_GUESTFISH
1049 # rate filter test.
1050 TESTS += \
1051         test-rate.sh \
1052         test-rate-dynamic.sh \
1053         $(NULL)
1055 # readahead filter test.
1056 LIBGUESTFS_TESTS += test-readahead
1057 TESTS += test-readahead-copy.sh
1059 test_readahead_SOURCES = test-readahead.c test.h
1060 test_readahead_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
1061 test_readahead_LDADD = libtest.la $(LIBGUESTFS_LIBS)
1063 # retry filter test.
1064 TESTS += \
1065         test-retry.sh \
1066         test-retry-readonly.sh \
1067         test-retry-extents.sh \
1068         test-retry-size.sh \
1069         test-retry-reopen-fail.sh \
1070         test-retry-zero-flags.sh \
1071         $(NULL)
1073 # truncate filter tests.
1074 TESTS += \
1075         test-truncate1.sh \
1076         test-truncate2.sh \
1077         test-truncate3.sh \
1078         test-truncate4.sh \
1079         test-truncate-extents.sh \
1080         $(NULL)
1082 # xz filter test.
1083 if HAVE_LIBLZMA
1084 if HAVE_GUESTFISH
1086 LIBGUESTFS_TESTS += test-xz
1087 check_DATA += disk.xz
1088 CLEANFILES += disk.xz
1090 test_xz_SOURCES = test-xz.c test.h
1091 test_xz_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
1092 test_xz_LDADD = libtest.la $(LIBGUESTFS_LIBS)
1094 disk.xz: disk
1095         rm -f $@
1096 # We choose a very small block size here only for testing.  Normally
1097 # you should choose a 16M block size.
1098         xz --best --block-size=32768 -c disk > $@
1100 if HAVE_CURL
1102 # xz filter + curl.
1103 LIBGUESTFS_TESTS += test-xz-curl
1105 test_xz_curl_SOURCES = \
1106         test-xz-curl.c \
1107         web-server.c \
1108         web-server.h \
1109         test.h \
1110         $(NULL)
1111 test_xz_curl_CPPFLAGS = \
1112         -I$(top_srcdir)/common/utils
1113 test_xz_curl_CFLAGS = \
1114         $(WARNINGS_CFLAGS) \
1115         $(LIBGUESTFS_CFLAGS) \
1116         $(PTHREAD_CFLAGS) \
1117         $(NULL)
1118 test_xz_curl_LDFLAGS = \
1119         $(top_builddir)/common/utils/libutils.la \
1120         $(PTHREAD_LIBS) \
1121         $(NULL)
1122 test_xz_curl_LDADD = \
1123         libtest.la \
1124         $(LIBGUESTFS_LIBS) \
1125         $(NULL)
1127 endif HAVE_CURL
1129 endif HAVE_GUESTFISH
1130 endif HAVE_LIBLZMA
1132 endif HAVE_PLUGINS
1134 #----------------------------------------------------------------------
1136 if HAVE_LIBGUESTFS
1137 check_PROGRAMS += $(LIBGUESTFS_TESTS)
1138 TESTS += $(LIBGUESTFS_TESTS)
1139 endif HAVE_LIBGUESTFS