2 # Copyright (C) 2013-2016 Red Hat Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
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
33 CLEANFILES = *~ *.cmi *.cmx *.cmxa *.so
34 MAINTAINERCLEANFILES =
49 test_ocaml_plugin.ml \
64 test-version-plugin.sh \
67 # Use 'make check' to run the ordinary tests. To run all the tests
68 # under valgrind, use the following rule:
70 $(MAKE) VG="@VG@" check
72 # Basic server command line and start-up tests.
84 test-version-plugin.sh \
93 test-socket-activation
96 test-socket-activation
98 test_socket_activation_SOURCES = test-socket-activation.c
99 test_socket_activation_CFLAGS = $(WARNINGS_CFLAGS)
102 # This builds a plugin using the C++ compiler. The plugin
103 # doesn't do anything interesting when run.
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 += \
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 = \
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
125 # In-depth tests need libguestfs, since that is a convenient way to
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 \
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)
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)
163 for f in `seq 1 512`; do echo -ne '\x01\x02\x03\x04\x05\x06\x07\x08'; done > $@-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)
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)
197 guestfish -N fs -m /dev/sda1 write /hello.txt "hello,world"
211 check_PROGRAMS += test-xz
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)
222 xz --best -c disk > $@
230 check_PROGRAMS += test-perl
231 TESTS += test-perl.sh
233 test_perl_SOURCES = test-lang-plugins.c test.h
235 -DLANG='"perl"' -DSCRIPT='"test.pl"' \
236 $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
237 test_perl_LDADD = libtest.la $(LIBGUESTFS_LIBS)
241 # python plugin test.
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)
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 $@ \
273 -cclib -L../plugins/ocaml/.libs -cclib -lnbdkitocaml
280 check_PROGRAMS += test-ruby
281 TESTS += test-ruby.sh
283 test_ruby_SOURCES = test-lang-plugins.c test.h
285 -DLANG='"ruby"' -DSCRIPT='"test.rb"' \
286 $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
287 test_ruby_LDADD = libtest.la $(LIBGUESTFS_LIBS)
291 # streaming plugin test.
292 check_PROGRAMS += test-streaming
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)