ruby: Expose nbdkit_set_error to ruby script
[nbdkit/ericb.git] / tests / Makefile.am
blobdaf1d2a2913e6e71f9df5d10f7a843f110b7927d
1 # nbdkit
2 # Copyright (C) 2013-2016 Red Hat Inc.
3 # All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # * Neither the name of Red Hat nor the names of its contributors may be
17 # used to endorse or promote products derived from this software without
18 # specific prior written permission.
20 # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
21 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
24 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 # SUCH DAMAGE.
33 CLEANFILES = *~ *.cmi *.cmx *.cmxa *.so
34 MAINTAINERCLEANFILES =
36 EXTRA_DIST = \
37         README.tests \
38         test-captive.sh \
39         test-connect.sh \
40         test-dump-config.sh \
41         test-dump-plugin.sh \
42         test-file.sh \
43         test-foreground.sh \
44         test-gzip.sh \
45         test-help.sh \
46         test-help-plugin.sh \
47         test-ipv4.sh \
48         test-newstyle.sh \
49         test_ocaml_plugin.ml \
50         test-ocaml.c \
51         test-ocaml.sh \
52         test-oldstyle.sh \
53         test.pl \
54         test-perl.sh \
55         test.py \
56         test-python.sh \
57         test.rb \
58         test-single.sh \
59         test-start.sh \
60         test-random-sock.sh \
61         test-ruby.sh \
62         test-streaming.sh \
63         test-version.sh \
64         test-version-plugin.sh \
65         test-xz.sh
67 # Use 'make check' to run the ordinary tests.  To run all the tests
68 # under valgrind, use the following rule:
69 check-valgrind:
70         $(MAKE) VG="@VG@" check
72 # Basic server command line and start-up tests.
74 check_PROGRAMS =
75 check_DATA =
76 check_SCRIPTS =
77 check_LTLIBRARIES =
78 noinst_LTLIBRARIES =
80 TESTS = \
81         test-help.sh \
82         test-help-plugin.sh \
83         test-version.sh \
84         test-version-plugin.sh \
85         test-dump-config.sh \
86         test-dump-plugin.sh \
87         test-start.sh \
88         test-foreground.sh \
89         test-single.sh \
90         test-captive.sh \
91         test-random-sock.sh \
92         test-ipv4.sh \
93         test-socket-activation
95 check_PROGRAMS += \
96         test-socket-activation
98 test_socket_activation_SOURCES = test-socket-activation.c
99 test_socket_activation_CFLAGS = $(WARNINGS_CFLAGS)
101 if HAVE_CXX
102 # This builds a plugin using the C++ compiler.  The plugin
103 # doesn't do anything interesting when run.
104 TESTS += \
105         test-cxx.sh
106 # check_LTLIBRARIES won't build a shared library (see automake manual).
107 # So we have to do this and add a dependency.
108 noinst_LTLIBRARIES += \
109         test-cxx-plugin.la
110 test-cxx.sh: test-cxx-plugin.la
112 test_cxx_plugin_la_SOURCES = \
113         test-cxx-plugin.cpp \
114         $(top_srcdir)/include/nbdkit-plugin.h
115 test_cxx_plugin_la_CPPFLAGS = \
116         -I$(top_srcdir)/include
117 test_cxx_plugin_la_CXXFLAGS = \
118         $(WARNINGS_CFLAGS)
119 # For use of the -rpath option, see:
120 # https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
121 test_cxx_plugin_la_LDFLAGS = \
122         -module -avoid-version -shared -rpath /nowhere
123 endif
125 # In-depth tests need libguestfs, since that is a convenient way to
126 # drive qemu.
128 if HAVE_LIBGUESTFS
130 # Use the 'direct' backend, and ensure maximum libguestfs debugging is
131 # written to the *.log files in case there is a problem.
132 TESTS_ENVIRONMENT = \
133         LIBGUESTFS_ATTACH_METHOD=appliance \
134         LIBGUESTFS_DEBUG=1 \
135         LIBGUESTFS_TRACE=1 \
136         LD_LIBRARY_PATH=../plugins/ocaml/.libs
138 # Common test library.
139 check_LTLIBRARIES += libtest.la
140 libtest_la_SOURCES = test.c test.h
141 libtest_la_CFLAGS = $(WARNINGS_CFLAGS)
143 # Basic connection test.
144 check_PROGRAMS += test-connect
145 TESTS += test-connect.sh
147 test_connect_SOURCES = test-connect.c test.h
148 test_connect_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
149 test_connect_LDADD = libtest.la $(LIBGUESTFS_LIBS)
151 # file plugin test.
152 check_PROGRAMS += test-file
153 TESTS += test-file.sh
154 check_DATA += file-data
155 MAINTAINERCLEANFILES += file-data
157 test_file_SOURCES = test-file.c test.h
158 test_file_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
159 test_file_LDADD = libtest.la $(LIBGUESTFS_LIBS)
161 file-data:
162         rm -f $@ $@-t
163         for f in `seq 1 512`; do echo -ne '\x01\x02\x03\x04\x05\x06\x07\x08'; done > $@-t
164         mv $@-t $@
166 # newstyle protocol test.
167 check_PROGRAMS += test-newstyle
168 TESTS += test-newstyle.sh
170 test_newstyle_SOURCES = test-newstyle.c test.h
171 test_newstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
172 test_newstyle_LDADD = libtest.la $(LIBGUESTFS_LIBS)
174 # oldstyle protocol test.
175 check_PROGRAMS += test-oldstyle
176 TESTS += test-oldstyle.sh
178 test_oldstyle_SOURCES = test-oldstyle.c test.h
179 test_oldstyle_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
180 test_oldstyle_LDADD = libtest.la $(LIBGUESTFS_LIBS)
182 # gzip plugin test.
183 if HAVE_ZLIB
184 if HAVE_GUESTFISH
186 check_PROGRAMS += test-gzip
187 TESTS += test-gzip.sh
188 check_DATA += disk disk.gz
189 MAINTAINERCLEANFILES += disk disk.gz
191 test_gzip_SOURCES = test-gzip.c test.h
192 test_gzip_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
193 test_gzip_LDADD = libtest.la $(LIBGUESTFS_LIBS)
195 disk:
196         rm -f $@ test1.img
197         guestfish -N fs -m /dev/sda1 write /hello.txt "hello,world"
198         mv test1.img disk
200 disk.gz: disk
201         rm -f $@
202         gzip -9 -c disk > $@
204 endif
205 endif
207 # xz plugin test.
208 if HAVE_LIBLZMA
209 if HAVE_GUESTFISH
211 check_PROGRAMS += test-xz
212 TESTS += test-xz.sh
213 check_DATA += disk.xz
214 MAINTAINERCLEANFILES += disk.xz
216 test_xz_SOURCES = test-xz.c test.h
217 test_xz_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
218 test_xz_LDADD = libtest.la $(LIBGUESTFS_LIBS)
220 disk.xz: disk
221         rm -f $@
222         xz --best -c disk > $@
224 endif
225 endif
227 # perl plugin test.
228 if HAVE_PERL
230 check_PROGRAMS += test-perl
231 TESTS += test-perl.sh
233 test_perl_SOURCES = test-lang-plugins.c test.h
234 test_perl_CFLAGS = \
235         -DLANG='"perl"' -DSCRIPT='"test.pl"' \
236         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
237 test_perl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
239 endif
241 # python plugin test.
242 if HAVE_PYTHON
244 check_PROGRAMS += test-python
245 TESTS += test-python.sh
247 test_python_SOURCES = test-lang-plugins.c test.h
248 test_python_CFLAGS = \
249         -DLANG='"python"' -DSCRIPT='"test.py"' \
250         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
251 test_python_LDADD = libtest.la $(LIBGUESTFS_LIBS)
253 endif
255 # OCaml plugin test.
256 if HAVE_OCAML
258 check_PROGRAMS += test-ocaml
259 TESTS += test-ocaml.sh
261 # This is somewhat different from the other tests because we have
262 # to build an actual plugin here.
263 test_ocaml_SOURCES = test-ocaml.c test.h
264 test_ocaml_CFLAGS = \
265         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
266 test_ocaml_LDADD = libtest.la $(LIBGUESTFS_LIBS)
268 check_SCRIPTS += test-ocaml-plugin.so
269 test-ocaml-plugin.so: test_ocaml_plugin.ml ../plugins/ocaml/libnbdkitocaml.la ../plugins/ocaml/NBDKit.cmi ../plugins/ocaml/NBDKit.cmx
270         $(OCAMLOPT) $(OCAMLOPTFLAGS) -I ../plugins/ocaml \
271           -output-obj -runtime-variant _pic -o $@ \
272           NBDKit.cmx $< \
273           -cclib -L../plugins/ocaml/.libs -cclib -lnbdkitocaml
275 endif
277 # Ruby plugin test.
278 if HAVE_RUBY
280 check_PROGRAMS += test-ruby
281 TESTS += test-ruby.sh
283 test_ruby_SOURCES = test-lang-plugins.c test.h
284 test_ruby_CFLAGS = \
285         -DLANG='"ruby"' -DSCRIPT='"test.rb"' \
286         $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
287 test_ruby_LDADD = libtest.la $(LIBGUESTFS_LIBS)
289 endif
291 # streaming plugin test.
292 check_PROGRAMS += test-streaming
293 # Doesn't work:
294 #TESTS += test-streaming.sh
296 test_streaming_SOURCES = test-streaming.c test.h
297 test_streaming_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
298 test_streaming_LDADD = libtest.la $(LIBGUESTFS_LIBS)
300 endif