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