1############################################################################
2# x509 certificates:
3TEST_DIR := @abs_top_srcdir@/tests
4SUMMARY  := $(TEST_DIR)/summarise-tests.py
5CERT_DIR := $(TEST_DIR)/certs
6CA_KEY   := $(CERT_DIR)/ca-0-key.pem
7CA_CERT  := $(CERT_DIR)/ca-0-cert.pem
8SS_KEY   := $(CERT_DIR)/ss-key.pem
9SS_CERT  := $(CERT_DIR)/ss-cert.pem
10REV_KEY  := $(CERT_DIR)/rev-key.pem
11REV_CERT := $(CERT_DIR)/rev-cert.pem
12EXP_KEY  := $(CERT_DIR)/exp-key.pem
13EXP_CERT := $(CERT_DIR)/exp-cert.pem
14NEW_KEY  := $(CERT_DIR)/new-key.pem
15NEW_CERT := $(CERT_DIR)/new-cert.pem
16TLS_KEY  := $(CERT_DIR)/tls-key.pem
17TLS_CERT := $(CERT_DIR)/tls-cert.pem
18CA_DIR   := $(CERT_DIR)/cas
19CRL_DIR  := $(CERT_DIR)/crl
20UNKNOWN_KEY  := $(CERT_DIR)/unknown-key.pem
21UNKNOWN_CERT := $(CERT_DIR)/unknown-cert.pem
22LIBWOCKY := $(top_builddir)/wocky/libwocky.la
23INCLUDES := -I$(top_builddir)/wocky
24TLSDEFS  := -DTLS_CA_KEY_FILE='"$(CA_KEY)"'      \
25            -DTLS_CA_CRT_FILE='"$(CA_CERT)"'     \
26            -DTLS_SS_KEY_FILE='"$(SS_KEY)"'      \
27            -DTLS_SS_CRT_FILE='"$(SS_CERT)"'     \
28            -DTLS_EXP_KEY_FILE='"$(EXP_KEY)"'    \
29            -DTLS_EXP_CRT_FILE='"$(EXP_CERT)"'   \
30            -DTLS_NEW_KEY_FILE='"$(NEW_KEY)"'    \
31            -DTLS_NEW_CRT_FILE='"$(NEW_CERT)"'   \
32            -DTLS_REV_KEY_FILE='"$(REV_KEY)"'    \
33            -DTLS_REV_CRT_FILE='"$(REV_CERT)"'   \
34            -DTLS_UNKNOWN_KEY_FILE='"$(UNKNOWN_KEY)"'  \
35            -DTLS_UNKNOWN_CRT_FILE='"$(UNKNOWN_CERT)"' \
36            -DTLS_SERVER_KEY_FILE='"$(TLS_KEY)"' \
37            -DTLS_SERVER_CRT_FILE='"$(TLS_CERT)"'\
38            -DTLS_CRL_DIR='"$(CRL_DIR)"'         \
39            -DTLS_CA_DIR='"$(CA_DIR)"'
40############################################################################
41TEST_PROGS = wocky-xmpp-reader-test \
42  wocky-xmpp-readwrite-test \
43  wocky-xmpp-connection-test \
44  wocky-porter-test \
45  wocky-loopback-test \
46  wocky-xmpp-node-test \
47  wocky-node-tree-test \
48  wocky-stanza-test \
49  wocky-roster-test \
50  wocky-bare-contact-test \
51  wocky-resource-contact-test \
52  wocky-contact-factory-test \
53  wocky-session-test \
54  wocky-pep-service-test \
55  wocky-tls-test \
56  wocky-data-form-test \
57  wocky-pubsub-service-test \
58  wocky-pubsub-node-test \
59  wocky-connector-test \
60  wocky-ping-test \
61  wocky-jid-validation-test \
62  wocky-sasl-utils-test \
63  wocky-utils-test \
64  wocky-scram-sha1-test \
65  wocky-caps-hash-test
66
67noinst_PROGRAMS=
68
69wocky_tls_test_DEPENDENCIES = $(LIBWOCKY)
70wocky_tls_test_SOURCES = \
71  wocky-tls-test.c        \
72  wocky-test-helper.c wocky-test-helper.h \
73  wocky-test-stream.c wocky-test-stream.h
74wocky_tls_test_CFLAGS = $(AM_CFLAGS) $(TLSDEFS)
75
76wocky_xmpp_connection_test_DEPENDENCIES = $(LIBWOCKY)
77wocky_xmpp_connection_test_SOURCES = \
78  wocky-xmpp-connection-test.c \
79  wocky-test-helper.c wocky-test-helper.h \
80  wocky-test-stream.c wocky-test-stream.h
81
82wocky_xmpp_readwrite_test_DEPENDENCIES = $(LIBWOCKY)
83wocky_xmpp_readwrite_test_SOURCES = \
84  wocky-test-stream.c wocky-test-stream.h \
85  wocky-test-helper.c wocky-test-helper.h \
86  wocky-xmpp-readwrite-test.c
87
88wocky_xmpp_reader_test_DEPENDENCIES = $(LIBWOCKY)
89wocky_xmpp_reader_test_SOURCES = \
90  wocky-test-helper.c wocky-test-helper.h \
91  wocky-test-stream.c wocky-test-stream.h \
92  wocky-xmpp-reader-test.c
93
94wocky_connector_test_DEPENDENCIES = $(CRL_DIR) $(CA_DIR) certs $(LIBWOCKY)
95
96wocky_connector_test_SOURCES = \
97   wocky-connector-test.c        \
98   wocky-test-sasl-auth-server.c \
99   wocky-test-sasl-auth-server.h \
100   wocky-test-connector-server.c \
101   wocky-test-connector-server.h \
102   wocky-test-helper.c wocky-test-helper.h \
103  wocky-test-stream.c wocky-test-stream.h \
104   test-resolver.h        	 \
105   test-resolver.c
106wocky_connector_test_LDADD = $(LDADD) @LIBSASL2_LIBS@
107wocky_connector_test_CFLAGS = $(AM_CFLAGS) @LIBSASL2_CFLAGS@ $(TLSDEFS)
108
109if HAVE_LIBSASL2
110  TEST_PROGS += wocky-test-sasl-auth
111endif
112
113wocky_sasl_utils_test_DEPENDENCIES = $(LIBWOCKY)
114wocky_sasl_utils_test_SOURCES = wocky-sasl-utils-test.c
115
116wocky_test_sasl_auth_DEPENDENCIES = $(LIBWOCKY)
117wocky_test_sasl_auth_SOURCES = \
118   wocky-test-helper.c wocky-test-helper.h \
119   wocky-test-sasl-auth.c \
120   wocky-test-sasl-handler.c \
121   wocky-test-sasl-handler.h \
122   wocky-test-sasl-auth-server.c \
123   wocky-test-sasl-auth-server.h \
124   wocky-test-stream.c \
125   wocky-test-stream.h
126
127wocky_test_sasl_auth_LDADD = $(LDADD) @LIBSASL2_LIBS@
128wocky_test_sasl_auth_CFLAGS = $(AM_CFLAGS) @LIBSASL2_CFLAGS@
129
130wocky_porter_test_DEPENDENCIES = $(LIBWOCKY)
131wocky_porter_test_SOURCES = \
132  wocky-porter-test.c \
133  wocky-test-helper.c wocky-test-helper.h \
134  wocky-test-stream.c wocky-test-stream.h
135
136wocky_loopback_test_DEPENDENCIES = $(LIBWOCKY)
137wocky_loopback_test_SOURCES = \
138  wocky-test-helper.c wocky-test-helper.h \
139  wocky-test-stream.c wocky-test-stream.h \
140  wocky-loopback-test.c
141
142wocky_xmpp_node_test_DEPENDENCIES = $(LIBWOCKY)
143wocky_xmpp_node_test_SOURCES = \
144  wocky-test-helper.c wocky-test-helper.h \
145  wocky-test-stream.c wocky-test-stream.h \
146  wocky-xmpp-node-test.c
147
148wocky_node_tree_test_DEPENDENCIES = $(LIBWOCKY)
149wocky_node_tree_test_SOURCES = \
150  wocky-test-helper.c wocky-test-helper.h \
151  wocky-test-stream.c wocky-test-stream.h \
152  wocky-node-tree-test.c
153
154wocky_stanza_test_DEPENDENCIES = $(LIBWOCKY)
155wocky_stanza_test_SOURCES = \
156  wocky-test-helper.c wocky-test-helper.h \
157  wocky-test-stream.c wocky-test-stream.h \
158  wocky-stanza-test.c
159
160wocky_roster_test_SOURCES = \
161  wocky-roster-test.c \
162  wocky-test-helper.c wocky-test-helper.h \
163  wocky-test-stream.c wocky-test-stream.h
164
165wocky_bare_contact_test_DEPENDENCIES = $(LIBWOCKY)
166wocky_bare_contact_test_SOURCES = \
167  wocky-test-helper.c wocky-test-helper.h \
168  wocky-test-stream.c wocky-test-stream.h \
169  wocky-bare-contact-test.c
170
171wocky_resource_contact_test_DEPENDENCIES = $(LIBWOCKY)
172wocky_resource_contact_test_SOURCES = \
173  wocky-test-helper.c wocky-test-helper.h \
174  wocky-test-stream.c wocky-test-stream.h \
175  wocky-resource-contact-test.c
176
177wocky_contact_factory_test_DEPENDENCIES = $(LIBWOCKY)
178wocky_contact_factory_test_SOURCES = \
179  wocky-test-helper.c wocky-test-helper.h \
180  wocky-test-stream.c wocky-test-stream.h \
181  wocky-contact-factory-test.c
182
183wocky_session_test_DEPENDENCIES = $(LIBWOCKY)
184wocky_session_test_SOURCES = \
185  wocky-test-helper.c wocky-test-helper.h \
186  wocky-test-stream.c wocky-test-stream.h \
187  wocky-session-test.c
188
189wocky_pep_service_test_DEPENDENCIES = $(LIBWOCKY)
190wocky_pep_service_test_SOURCES = \
191  wocky-test-helper.c wocky-test-helper.h \
192  wocky-test-stream.c wocky-test-stream.h \
193  wocky-pep-service-test.c
194
195wocky_data_form_test_DEPENDENCIES = $(LIBWOCKY)
196wocky_data_form_test_SOURCES = \
197  wocky-test-helper.c wocky-test-helper.h \
198  wocky-test-stream.c wocky-test-stream.h \
199  wocky-data-form-test.c
200
201wocky_pubsub_service_test_DEPENDENCIES = $(LIBWOCKY)
202wocky_pubsub_service_test_SOURCES = \
203  wocky-test-helper.c wocky-test-helper.h \
204  wocky-test-stream.c wocky-test-stream.h \
205  wocky-pubsub-test-helpers.c wocky-pubsub-test-helpers.h \
206  wocky-pubsub-service-test.c
207
208wocky_pubsub_node_test_DEPENDENCIES = $(LIBWOCKY)
209wocky_pubsub_node_test_SOURCES = \
210  wocky-test-helper.c wocky-test-helper.h \
211  wocky-test-stream.c wocky-test-stream.h \
212  wocky-pubsub-test-helpers.c wocky-pubsub-test-helpers.h \
213  wocky-pubsub-node-test.c
214
215wocky_ping_test_DEPENDENCIES = $(LIBWOCKY)
216wocky_ping_test_SOURCES = \
217  wocky-ping-test.c \
218  wocky-test-helper.c wocky-test-helper.h \
219  wocky-test-stream.c wocky-test-stream.h
220
221wocky_jid_validation_test_DEPENDENCIES = $(LIBWOCKY)
222wocky_jid_validation_test_SOURCES = \
223  wocky-jid-validation-test.c \
224  wocky-test-helper.c wocky-test-helper.h \
225  wocky-test-stream.c wocky-test-stream.h
226
227wocky_utils_test_DEPENDENCIES = $(LIBWOCKY)
228wocky_utils_test_SOURCES = wocky-utils-test.c
229
230wocky_scram_sha1_test_DEPENDENCIES = $(LIBWOCKY)
231wocky_scram_sha1_test_SOURCES = wocky-scram-sha1-test.c \
232  wocky-test-helper.c wocky-test-helper.h \
233  wocky-test-stream.c wocky-test-stream.h
234
235wocky_http_proxy_test_DEPENDENCIES = $(LIBWOCKY)
236wocky_http_proxy_test_SOURCES = wocky-http-proxy-test.c \
237  wocky-test-helper.c wocky-test-helper.h \
238  wocky-test-stream.c wocky-test-stream.h
239
240wocky_dummy_xmpp_server_DEPENDENCIES = $(LIBWOCKY)
241wocky_dummy_xmpp_server_SOURCES = wocky-dummy-xmpp-server.c \
242   wocky-test-connector-server.c wocky-test-connector-server.h \
243   wocky-test-sasl-auth-server.c wocky-test-sasl-auth-server.h
244wocky_dummy_xmpp_server_LDADD = $(LDADD) @LIBSASL2_LIBS@
245wocky_dummy_xmpp_server_CFLAGS = $(AM_CFLAGS) @LIBSASL2_CFLAGS@ $(TLSDEFS)
246
247if HAVE_LIBSASL2
248  noinst_PROGRAMS += wocky-dummy-xmpp-server
249endif
250
251wocky_caps_hash_test_DEPENDENCIES = $(LIBWOCKY)
252wocky_caps_hash_test_SOURCES = wocky-caps-hash-test.c \
253  wocky-test-helper.c wocky-test-helper.h \
254  wocky-test-stream.c wocky-test-stream.h
255
256if HAVE_GIO_PROXY
257  TEST_PROGS += wocky-http-proxy-test
258endif
259
260AM_CFLAGS = $(ERROR_CFLAGS) $(GCOV_CFLAGS) @GLIB_CFLAGS@ \
261  @LIBXML2_CFLAGS@ @TLS_CFLAGS@ @WOCKY_CFLAGS@
262
263AM_LDFLAGS = $(GCOV_LIBS) @GLIB_LIBS@ @LIBXML2_LIBS@ @TLS_LIBS@
264LDADD = $(top_builddir)/wocky/libwocky.la
265
266check_PROGRAMS = $(TEST_PROGS)
267
268check_c_sources = $(notdir $(wildcard $(srcdir)/*.c) $(wildcard $(srcdir)/*.h))
269
270noinst_PROGRAMS = $(TEST_PROGS)
271
272test-report: test-report.xml
273	gtester-report $(top_builddir)/tests/$@.xml > \
274	  $(top_builddir)/tests/$@.html
275
276test-report.xml: ${TEST_PROGS} test
277
278test: ${TEST_PROGS}
279	gtester -o test-report.xml -k --verbose ${TEST_PROGS}
280	@if [ -x $(which python) ] ; then \
281		$(SUMMARY) $@-report.xml ; \
282	else \
283		echo "No python available, not summarizing test results" ; \
284	fi
285
286test-%: wocky-%-test
287	gtester -o $@-report.xml -k --verbose $<
288	@if [ -x $(which python) ] ; then \
289		$(SUMMARY) $@-report.xml ; \
290	else \
291		echo "No python available, not summarizing test results" ; \
292	fi
293
294.PHONY: test test-report
295
296include $(top_srcdir)/tools/check-coding-style.mk
297check-local: test check-coding-style
298
299############################################################################
300
301SUPPRESSIONS = \
302	threadlocal.supp \
303	gabble.supp \
304	tp-glib.supp
305
306CLEANFILES = test-report.xml \
307	sasl-test.db
308
309# valgrind any given test by running make test.valgrind
310%.valgrind: %
311	G_SLICE=always-malloc               \
312	G_DEBUG=gc-friendly              \
313	valgrind -q \
314	$(foreach s,$(SUPPRESSIONS),--suppressions=$(srcdir)/$(s))   \
315	--tool=memcheck --leak-check=full --trace-children=yes   \
316	--leak-resolution=high --num-callers=20         \
317	./$* $(TEST_ARGS) 2>&1 | tee "valgrind.$*.log"
318	@if grep "==" "valgrind.$*.log" > /dev/null 2>&1; then   \
319		exit 1;                \
320	fi
321
322valgrind: $(TEST_PROGS)
323	@echo "Valgrinding tests ..."
324	@failed=0;                    \
325	for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TEST_PROGS)); do  \
326		$(MAKE) $$t.valgrind;               \
327		if test "$$?" -ne 0; then                               \
328			echo "Valgrind error for test $$t";    \
329			failed=`expr $$failed + 1`;         \
330			whicht="$$whicht $$t";           \
331		fi;                    \
332	done;                      \
333	if test "$$failed" -ne 0; then               \
334		echo "$$failed tests had leaks or errors under valgrind:";  \
335		echo "$$whicht";              \
336		false;                     \
337	fi
338
339EXTRA_DIST = $(SUPPRESSIONS)     \
340	README \
341	connector-test-plan.txt \
342	summarise-tests.py \
343	wocky-dummy-xmpp-server.c \
344	$(wildcard $(srcdir)/certs/*.cfg)      \
345	$(wildcard $(srcdir)/certs/*.pem)      \
346	$(wildcard $(srcdir)/certs/cas/*.pem)  \
347	$(wildcard $(srcdir)/certs/cas/*.0)    \
348	$(wildcard $(srcdir)/certs/crl/*.pem)  \
349	$(wildcard $(srcdir)/certs/crl/*.r0)
350
351