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