tests: Add ability to automatically rerun failed tests.
[cascardo/ovs.git] / tests / automake.mk
1 EXTRA_DIST += \
2         $(COMMON_MACROS_AT) \
3         $(TESTSUITE_AT) \
4         $(SYSTEM_TESTSUITE_AT) \
5         $(SYSTEM_KMOD_TESTSUITE_AT) \
6         $(SYSTEM_USERSPACE_TESTSUITE_AT) \
7         $(TESTSUITE) \
8         $(SYSTEM_KMOD_TESTSUITE) \
9         $(SYSTEM_USERSPACE_TESTSUITE) \
10         tests/atlocal.in \
11         $(srcdir)/package.m4 \
12         $(srcdir)/tests/testsuite \
13         $(srcdir)/tests/testsuite.patch
14
15 COMMON_MACROS_AT = \
16         tests/ovsdb-macros.at \
17         tests/ovs-macros.at \
18         tests/ofproto-macros.at
19
20 TESTSUITE_AT = \
21         tests/testsuite.at \
22         tests/completion.at \
23         tests/library.at \
24         tests/heap.at \
25         tests/bundle.at \
26         tests/classifier.at \
27         tests/check-structs.at \
28         tests/daemon.at \
29         tests/daemon-py.at \
30         tests/ofp-actions.at \
31         tests/ofp-print.at \
32         tests/ofp-util.at \
33         tests/ofp-errors.at \
34         tests/ovs-ofctl.at \
35         tests/odp.at \
36         tests/mpls-xlate.at \
37         tests/multipath.at \
38         tests/bfd.at \
39         tests/cfm.at \
40         tests/lacp.at \
41         tests/lib.at \
42         tests/learn.at \
43         tests/vconn.at \
44         tests/file_name.at \
45         tests/aes128.at \
46         tests/unixctl-py.at \
47         tests/uuid.at \
48         tests/json.at \
49         tests/jsonrpc.at \
50         tests/jsonrpc-py.at \
51         tests/tunnel.at \
52         tests/tunnel-push-pop.at \
53         tests/tunnel-push-pop-ipv6.at \
54         tests/lockfile.at \
55         tests/reconnect.at \
56         tests/ovs-vswitchd.at \
57         tests/dpif-netdev.at \
58         tests/dpctl.at \
59         tests/ofproto-dpif.at \
60         tests/bridge.at \
61         tests/vlan-splinters.at \
62         tests/ofproto.at \
63         tests/ovsdb.at \
64         tests/ovsdb-log.at \
65         tests/ovsdb-types.at \
66         tests/ovsdb-data.at \
67         tests/ovsdb-column.at \
68         tests/ovsdb-table.at \
69         tests/ovsdb-row.at \
70         tests/ovsdb-schema.at \
71         tests/ovsdb-condition.at \
72         tests/ovsdb-mutation.at \
73         tests/ovsdb-query.at \
74         tests/ovsdb-transaction.at \
75         tests/ovsdb-execution.at \
76         tests/ovsdb-trigger.at \
77         tests/ovsdb-tool.at \
78         tests/ovsdb-server.at \
79         tests/ovsdb-monitor.at \
80         tests/ovsdb-idl.at \
81         tests/ovs-vsctl.at \
82         tests/ovs-monitor-ipsec.at \
83         tests/ovs-xapi-sync.at \
84         tests/stp.at \
85         tests/rstp.at \
86         tests/interface-reconfigure.at \
87         tests/vlog.at \
88         tests/vtep-ctl.at \
89         tests/auto-attach.at \
90         tests/ovn.at \
91         tests/ovn-nbctl.at \
92         tests/ovn-sbctl.at \
93         tests/ovn-controller.at \
94         tests/ovn-controller-vtep.at
95
96 SYSTEM_KMOD_TESTSUITE_AT = \
97         tests/system-common-macros.at \
98         tests/system-kmod-testsuite.at \
99         tests/system-kmod-macros.at
100
101 SYSTEM_USERSPACE_TESTSUITE_AT = \
102         tests/system-userspace-testsuite.at \
103         tests/system-userspace-macros.at
104
105 SYSTEM_TESTSUITE_AT = \
106         tests/system-common-macros.at \
107         tests/system-traffic.at
108
109 TESTSUITE = $(srcdir)/tests/testsuite
110 TESTSUITE_PATCH = $(srcdir)/tests/testsuite.patch
111 SYSTEM_KMOD_TESTSUITE = $(srcdir)/tests/system-kmod-testsuite
112 SYSTEM_USERSPACE_TESTSUITE = $(srcdir)/tests/system-userspace-testsuite
113 DISTCLEANFILES += tests/atconfig tests/atlocal
114
115 AUTOTEST_PATH = utilities:vswitchd:ovsdb:vtep:tests:$(PTHREAD_WIN32_DIR_DLL):ovn/controller-vtep:ovn/northd:ovn/utilities:ovn/controller
116
117 check-local: tests/atconfig tests/atlocal $(TESTSUITE)
118         set $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH) $(TESTSUITEFLAGS); \
119         "$$@" || (test X'$(RECHECK)' = Xyes && "$$@" --recheck)
120 \f
121 # Python Coverage support.
122 # Requires coverage.py http://nedbatchelder.com/code/coverage/.
123
124 COVERAGE = coverage
125 COVERAGE_FILE='$(abs_srcdir)/.coverage'
126 check-pycov: all tests/atconfig tests/atlocal $(TESTSUITE) clean-pycov
127         PYTHONDONTWRITEBYTECODE=yes COVERAGE_FILE=$(COVERAGE_FILE) PYTHON='$(COVERAGE) run -p' $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH) $(TESTSUITEFLAGS)
128         @cd $(srcdir) && $(COVERAGE) combine && COVERAGE_FILE=$(COVERAGE_FILE) $(COVERAGE) annotate
129         @echo
130         @echo '----------------------------------------------------------------------'
131         @echo 'Annotated coverage source has the ",cover" extension.'
132         @echo '----------------------------------------------------------------------'
133         @echo
134         @COVERAGE_FILE=$(COVERAGE_FILE) $(COVERAGE) report
135 \f
136 # valgrind support
137
138 valgrind_wrappers = \
139         tests/valgrind/ovs-appctl \
140         tests/valgrind/ovs-ofctl \
141         tests/valgrind/ovstest \
142         tests/valgrind/ovs-vsctl \
143         tests/valgrind/ovs-vswitchd \
144         tests/valgrind/ovsdb-client \
145         tests/valgrind/ovsdb-server \
146         tests/valgrind/ovsdb-tool \
147         tests/valgrind/test-aes128 \
148         tests/valgrind/test-atomic \
149         tests/valgrind/test-bundle \
150         tests/valgrind/test-byte-order \
151         tests/valgrind/test-classifier \
152         tests/valgrind/test-cmap \
153         tests/valgrind/test-csum \
154         tests/valgrind/test-flows \
155         tests/valgrind/test-hash \
156         tests/valgrind/test-hindex \
157         tests/valgrind/test-hmap \
158         tests/valgrind/test-json \
159         tests/valgrind/test-jsonrpc \
160         tests/valgrind/test-list \
161         tests/valgrind/test-lockfile \
162         tests/valgrind/test-multipath \
163         tests/valgrind/test-odp \
164         tests/valgrind/test-ofpbuf \
165         tests/valgrind/test-ovsdb \
166         tests/valgrind/test-packets \
167         tests/valgrind/test-random \
168         tests/valgrind/test-reconnect \
169         tests/valgrind/test-rstp \
170         tests/valgrind/test-sha1 \
171         tests/valgrind/test-stp \
172         tests/valgrind/test-type-props \
173         tests/valgrind/test-unix-socket \
174         tests/valgrind/test-unixctl \
175         tests/valgrind/test-uuid \
176         tests/valgrind/test-vconn
177
178 $(valgrind_wrappers): tests/valgrind-wrapper.in
179         @test -d tests/valgrind || mkdir tests/valgrind
180         $(AM_V_GEN) sed -e 's,[@]wrap_program[@],$@,' \
181                 $(top_srcdir)/tests/valgrind-wrapper.in > $@.tmp && \
182         chmod +x $@.tmp && \
183         mv $@.tmp $@
184 CLEANFILES += $(valgrind_wrappers)
185 EXTRA_DIST += tests/valgrind-wrapper.in
186
187 VALGRIND = valgrind --log-file=valgrind.%p --leak-check=full \
188         --suppressions=$(abs_top_srcdir)/tests/glibc.supp \
189         --suppressions=$(abs_top_srcdir)/tests/openssl.supp --num-callers=20
190 EXTRA_DIST += tests/glibc.supp tests/openssl.supp
191 check-valgrind: all tests/atconfig tests/atlocal $(TESTSUITE) \
192                 $(valgrind_wrappers) $(check_DATA)
193         $(SHELL) '$(TESTSUITE)' -C tests CHECK_VALGRIND=true VALGRIND='$(VALGRIND)' AUTOTEST_PATH='tests/valgrind:$(AUTOTEST_PATH)' -d $(TESTSUITEFLAGS)
194         @echo
195         @echo '----------------------------------------------------------------------'
196         @echo 'Valgrind output can be found in tests/testsuite.dir/*/valgrind.*'
197         @echo '----------------------------------------------------------------------'
198 \f
199 # OFTest support.
200
201 check-oftest: all
202         $(AM_V_at)srcdir='$(srcdir)' $(SHELL) $(srcdir)/tests/run-oftest
203 EXTRA_DIST += tests/run-oftest
204
205 # Ryu support.
206 check-ryu: all
207         $(AM_V_at)srcdir='$(srcdir)' $(SHELL) $(srcdir)/tests/run-ryu
208 EXTRA_DIST += tests/run-ryu
209 \f
210 # Run kmod tests. Assume kernel modules has been installed or linked into the kernel
211 check-kernel: all tests/atconfig tests/atlocal $(SYSTEM_KMOD_TESTSUITE)
212         $(SHELL) '$(SYSTEM_KMOD_TESTSUITE)' -C tests  AUTOTEST_PATH='$(AUTOTEST_PATH)' -d $(TESTSUITEFLAGS)
213
214 # Testing the out of tree Kernel module
215 check-kmod: all tests/atconfig tests/atlocal $(SYSTEM_KMOD_TESTSUITE)
216         $(MAKE) modules_install
217         modprobe -r openvswitch
218         $(MAKE) check-kernel
219
220 check-system-userspace: all tests/atconfig tests/atlocal $(SYSTEM_USERSPACE_TESTSUITE)
221         $(SHELL) '$(SYSTEM_USERSPACE_TESTSUITE)' -C tests  AUTOTEST_PATH='$(AUTOTEST_PATH)' $(TESTSUITEFLAGS)
222
223 clean-local:
224         test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' -C tests --clean
225
226 AUTOTEST = $(AUTOM4TE) --language=autotest
227
228 if WIN32
229 $(TESTSUITE): package.m4 $(TESTSUITE_AT) $(COMMON_MACROS_AT) $(TESTSUITE_PATCH)
230         $(AM_V_GEN)$(AUTOTEST) -I '$(srcdir)' -o testsuite.tmp $@.at
231         patch -p0 testsuite.tmp $(TESTSUITE_PATCH)
232         $(AM_V_at)mv testsuite.tmp $@
233 else
234 $(TESTSUITE): package.m4 $(TESTSUITE_AT) $(COMMON_MACROS_AT)
235         $(AM_V_GEN)$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
236         $(AM_V_at)mv $@.tmp $@
237 endif
238
239 $(SYSTEM_KMOD_TESTSUITE): package.m4 $(SYSTEM_TESTSUITE_AT) $(SYSTEM_KMOD_TESTSUITE_AT) $(COMMON_MACROS_AT)
240         $(AM_V_GEN)$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
241         $(AM_V_at)mv $@.tmp $@
242
243 $(SYSTEM_USERSPACE_TESTSUITE): package.m4 $(SYSTEM_TESTSUITE_AT) $(SYSTEM_USERSPACE_TESTSUITE_AT) $(COMMON_MACROS_AT)
244         $(AM_V_GEN)$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
245         $(AM_V_at)mv $@.tmp $@
246
247 # The `:;' works around a Bash 3.2 bug when the output is not writeable.
248 $(srcdir)/package.m4: $(top_srcdir)/configure.ac
249         $(AM_V_GEN):;{ \
250           echo '# Signature of the current package.' && \
251           echo 'm4_define([AT_PACKAGE_NAME],      [$(PACKAGE_NAME)])' && \
252           echo 'm4_define([AT_PACKAGE_TARNAME],   [$(PACKAGE_TARNAME)])' && \
253           echo 'm4_define([AT_PACKAGE_VERSION],   [$(PACKAGE_VERSION)])' && \
254           echo 'm4_define([AT_PACKAGE_STRING],    [$(PACKAGE_STRING)])' && \
255           echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])'; \
256         } >'$(srcdir)/package.m4'
257
258 noinst_PROGRAMS += tests/test-ovsdb
259 tests_test_ovsdb_SOURCES = tests/test-ovsdb.c
260 nodist_tests_test_ovsdb_SOURCES = tests/idltest.c tests/idltest.h
261 EXTRA_DIST += tests/uuidfilt.pl tests/ovsdb-monitor-sort.pl
262 tests_test_ovsdb_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la
263
264 noinst_PROGRAMS += tests/test-lib
265 tests_test_lib_SOURCES = \
266         tests/test-lib.c
267 tests_test_lib_LDADD = lib/libopenvswitch.la
268
269 # idltest schema and IDL
270 OVSIDL_BUILT += tests/idltest.c tests/idltest.h tests/idltest.ovsidl
271 IDLTEST_IDL_FILES = tests/idltest.ovsschema tests/idltest.ann
272 EXTRA_DIST += $(IDLTEST_IDL_FILES) tests/idltest2.ovsschema
273 tests/idltest.ovsidl: $(IDLTEST_IDL_FILES)
274         $(AM_V_GEN)$(OVSDB_IDLC) -C $(srcdir) annotate $(IDLTEST_IDL_FILES) > $@.tmp && \
275         mv $@.tmp $@
276
277 tests/idltest.c: tests/idltest.h
278
279 if DPDK_NETDEV
280 noinst_PROGRAMS += tests/test-dpdkr
281 tests_test_dpdkr_SOURCES = \
282         tests/dpdk/ring_client.c
283 tests_test_dpdkr_LDADD = lib/libopenvswitch.la $(LIBS)
284 endif
285
286 noinst_PROGRAMS += tests/ovstest
287 tests_ovstest_SOURCES = \
288         tests/ovstest.c \
289         tests/ovstest.h \
290         tests/test-aes128.c \
291         tests/test-atomic.c \
292         tests/test-bundle.c \
293         tests/test-byte-order.c \
294         tests/test-classifier.c \
295         tests/test-cmap.c \
296         tests/test-csum.c \
297         tests/test-flows.c \
298         tests/test-hash.c \
299         tests/test-heap.c \
300         tests/test-hindex.c \
301         tests/test-hmap.c \
302         tests/test-json.c \
303         tests/test-jsonrpc.c \
304         tests/test-list.c \
305         tests/test-lockfile.c \
306         tests/test-multipath.c \
307         tests/test-netflow.c \
308         tests/test-odp.c \
309         tests/test-ofpbuf.c \
310         tests/test-ovn.c \
311         tests/test-packets.c \
312         tests/test-random.c \
313         tests/test-reconnect.c \
314         tests/test-rstp.c \
315         tests/test-sflow.c \
316         tests/test-sha1.c \
317         tests/test-stp.c \
318         tests/test-unixctl.c \
319         tests/test-util.c \
320         tests/test-uuid.c \
321         tests/test-bitmap.c \
322         tests/test-vconn.c \
323         tests/test-aa.c
324
325 if !WIN32
326 tests_ovstest_SOURCES += \
327         tests/test-unix-socket.c
328 endif
329
330 if LINUX
331 tests_ovstest_SOURCES += \
332         tests/test-netlink-conntrack.c
333 endif
334
335 tests_ovstest_LDADD = lib/libopenvswitch.la ovn/lib/libovn.la
336 dist_check_SCRIPTS = tests/flowgen.pl
337
338 noinst_PROGRAMS += tests/test-strtok_r
339 tests_test_strtok_r_SOURCES = tests/test-strtok_r.c
340
341 noinst_PROGRAMS += tests/test-type-props
342 tests_test_type_props_SOURCES = tests/test-type-props.c
343
344 # Python tests.
345 CHECK_PYFILES = \
346         tests/appctl.py \
347         tests/test-daemon.py \
348         tests/test-json.py \
349         tests/test-jsonrpc.py \
350         tests/test-l7.py \
351         tests/test-ovsdb.py \
352         tests/test-reconnect.py \
353         tests/MockXenAPI.py \
354         tests/test-unix-socket.py \
355         tests/test-unixctl.py \
356         tests/test-vlog.py
357 EXTRA_DIST += $(CHECK_PYFILES)
358 PYCOV_CLEAN_FILES += $(CHECK_PYFILES:.py=.py,cover) .coverage
359
360 FLAKE8_PYFILES += $(CHECK_PYFILES)
361
362 if HAVE_OPENSSL
363 TESTPKI_FILES = \
364         tests/testpki-cacert.pem \
365         tests/testpki-cert.pem \
366         tests/testpki-privkey.pem \
367         tests/testpki-req.pem \
368         tests/testpki-cert2.pem \
369         tests/testpki-privkey2.pem \
370         tests/testpki-req2.pem
371 check_DATA += $(TESTPKI_FILES)
372 CLEANFILES += $(TESTPKI_FILES)
373
374 tests/testpki-cacert.pem: tests/pki/stamp
375         $(AM_V_GEN)cp tests/pki/switchca/cacert.pem $@
376 tests/testpki-cert.pem: tests/pki/stamp
377         $(AM_V_GEN)cp tests/pki/test-cert.pem $@
378 tests/testpki-req.pem: tests/pki/stamp
379         $(AM_V_GEN)cp tests/pki/test-req.pem $@
380 tests/testpki-privkey.pem: tests/pki/stamp
381         $(AM_V_GEN)cp tests/pki/test-privkey.pem $@
382 tests/testpki-cert2.pem: tests/pki/stamp
383         $(AM_V_GEN)cp tests/pki/test2-cert.pem $@
384 tests/testpki-req2.pem: tests/pki/stamp
385         $(AM_V_GEN)cp tests/pki/test2-req.pem $@
386 tests/testpki-privkey2.pem: tests/pki/stamp
387         $(AM_V_GEN)cp tests/pki/test2-privkey.pem $@
388
389 OVS_PKI = $(SHELL) $(srcdir)/utilities/ovs-pki.in --dir=tests/pki --log=tests/ovs-pki.log
390 tests/pki/stamp:
391         $(AM_V_at)rm -f tests/pki/stamp
392         $(AM_V_at)rm -rf tests/pki
393         $(AM_V_GEN)$(OVS_PKI) init && \
394         $(OVS_PKI) req+sign tests/pki/test && \
395         $(OVS_PKI) req+sign tests/pki/test2 && \
396         : > tests/pki/stamp
397 CLEANFILES += tests/ovs-pki.log
398
399 CLEAN_LOCAL += clean-pki
400 clean-pki:
401         rm -f tests/pki/stamp
402         rm -rf tests/pki
403 endif