fe163c64b8ed8d5961daea2f4f66e39421ff302a
[platform/upstream/dbus.git] / test / Makefile.am
1 ## the "name-test" subdir in fact contains a bunch of tests now that need a temporary bus 
2 ## to be running to do stuff with. The directory should be renamed.
3 ## We want to build the current directory first to pick up the testutils lib
4 SUBDIRS= . name-test 
5 DIST_SUBDIRS=name-test
6
7 # CPPFLAGS for binaries that are normally dynamic
8 AM_CPPFLAGS = \
9         -I$(top_srcdir) \
10         $(DBUS_STATIC_BUILD_CPPFLAGS) \
11         $(GLIB_CFLAGS) \
12         $(DBUS_GLIB_CFLAGS) \
13         $(NULL)
14
15 # improve backtraces from test stuff
16 AM_LDFLAGS = @R_DYNAMIC_LDFLAG@
17
18 # CPPFLAGS for binaries that are always static
19 static_cppflags = \
20         $(AM_CPPFLAGS) \
21         -DDBUS_STATIC_BUILD \
22         -DDBUS_COMPILATION \
23         $(NULL)
24
25 libdbus_testutils_la_CPPFLAGS = \
26         $(static_cppflags)
27 libdbus_testutils_la_SOURCES = \
28         test-utils.c \
29         test-utils.h \
30         $(NULL)
31 libdbus_testutils_la_LIBADD = \
32         $(top_builddir)/dbus/libdbus-internal.la \
33         $(NULL)
34
35 noinst_LTLIBRARIES = libdbus-testutils.la
36
37 if DBUS_ENABLE_EMBEDDED_TESTS
38 ## break-loader removed for now
39 ## these binaries are used in tests but are not themselves tests
40 TEST_BINARIES = \
41         spawn-test \
42         test-exit \
43         test-names \
44         test-segfault \
45         test-service \
46         test-shell-service \
47         test-sleep-forever \
48         $(NULL)
49
50 ## These are conceptually part of directories that come earlier in SUBDIRS
51 ## order, but we don't want to run them til we arrive in this directory,
52 ## since they depend on stuff from this directory
53 TESTS = \
54         ../bus/bus-test$(EXEEXT) \
55         ../bus/bus-test-system$(EXEEXT) \
56         ../dbus/dbus-test$(EXEEXT) \
57         $(NULL)
58
59 if DBUS_UNIX
60 TESTS += ../bus/bus-test-launch-helper$(EXEEXT)
61 endif
62
63 else !DBUS_ENABLE_EMBEDDED_TESTS
64
65 TEST_BINARIES=
66 TESTS=
67
68 endif !DBUS_ENABLE_EMBEDDED_TESTS
69
70 noinst_PROGRAMS= $(TEST_BINARIES)
71
72 test_service_CPPFLAGS = $(static_cppflags)
73 test_service_LDADD = libdbus-testutils.la
74 test_names_CPPFLAGS = $(static_cppflags)
75 test_names_LDADD = libdbus-testutils.la
76 ## break_loader_CPPFLAGS = $(static_cppflags)
77 ## break_loader_LDADD = $(top_builddir)/dbus/libdbus-internal.la
78 test_shell_service_CPPFLAGS = $(static_cppflags)
79 test_shell_service_LDADD = libdbus-testutils.la
80 shell_test_CPPFLAGS = $(static_cppflags)
81 shell_test_LDADD = libdbus-testutils.la
82 spawn_test_CPPFLAGS = $(static_cppflags)
83 spawn_test_LDADD = $(top_builddir)/dbus/libdbus-internal.la
84
85 test_printf_SOURCES = internals/printf.c
86 test_printf_CPPFLAGS = $(static_cppflags)
87 test_printf_LDADD = $(top_builddir)/dbus/libdbus-internal.la
88
89 test_refs_SOURCES = internals/refs.c
90 test_refs_CPPFLAGS = $(static_cppflags)
91 test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS)
92
93 test_syslog_SOURCES = internals/syslog.c
94 test_syslog_CPPFLAGS = $(static_cppflags)
95 test_syslog_LDADD = libdbus-testutils.la $(GLIB_LIBS)
96
97 EXTRA_DIST = dbus-test-runner
98
99 testexecdir = $(libdir)/dbus-1.0/test
100
101 testexec_PROGRAMS =
102
103 installable_tests = \
104         shell-test \
105         test-printf \
106         $(NULL)
107 installable_manual_tests = \
108         $(NULL)
109
110 if DBUS_WITH_GLIB
111 installable_tests += \
112         test-corrupt \
113         test-dbus-daemon \
114         test-dbus-daemon-eavesdrop \
115         test-loopback \
116         test-marshal \
117         test-refs \
118         test-relay \
119         test-syntax \
120         test-syslog \
121         $(NULL)
122 installable_manual_tests += \
123         manual-authz \
124         $(NULL)
125 endif DBUS_WITH_GLIB
126
127 installcheck_tests =
128 installcheck_environment = \
129         DBUS_TEST_DAEMON=$(DESTDIR)$(DBUS_DAEMONDIR)/dbus-daemon$(EXEEXT) \
130         DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus \
131         DBUS_TEST_SYSCONFDIR=$(DESTDIR)$(sysconfdir)
132
133 TESTS_ENVIRONMENT = \
134         DBUS_BLOCK_ON_ABORT=1 \
135         DBUS_FATAL_WARNINGS=1 \
136         DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT) \
137         DBUS_TEST_DATA=@abs_top_builddir@/test/data \
138         DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus \
139         $(NULL)
140
141 manual_authz_SOURCES = manual-authz.c
142 manual_authz_LDADD = $(top_builddir)/dbus/libdbus-1.la \
143     $(GLIB_LIBS) \
144     $(DBUS_GLIB_LIBS)
145
146 test_corrupt_SOURCES = corrupt.c
147 test_corrupt_LDADD = $(top_builddir)/dbus/libdbus-1.la \
148     $(GLIB_LIBS) \
149     $(DBUS_GLIB_LIBS)
150
151 test_loopback_SOURCES = loopback.c
152 test_loopback_LDADD = $(top_builddir)/dbus/libdbus-1.la \
153     $(GLIB_LIBS) \
154     $(DBUS_GLIB_LIBS)
155
156 test_relay_SOURCES = relay.c
157 test_relay_LDADD = $(top_builddir)/dbus/libdbus-1.la \
158     $(GLIB_LIBS) \
159     $(DBUS_GLIB_LIBS)
160
161 test_dbus_daemon_SOURCES = dbus-daemon.c
162 test_dbus_daemon_LDADD = $(top_builddir)/dbus/libdbus-1.la \
163     $(GLIB_LIBS) \
164     $(DBUS_GLIB_LIBS)
165
166 test_dbus_daemon_eavesdrop_SOURCES = dbus-daemon-eavesdrop.c
167 test_dbus_daemon_eavesdrop_CPPFLAGS = $(GLIB_CFLAGS) $(DBUS_GLIB_CFLAGS)
168 test_dbus_daemon_eavesdrop_LDFLAGS = @R_DYNAMIC_LDFLAG@
169 test_dbus_daemon_eavesdrop_LDADD = $(top_builddir)/dbus/libdbus-1.la \
170     $(GLIB_LIBS) \
171     $(DBUS_GLIB_LIBS)
172
173 test_marshal_SOURCES = marshal.c
174 test_marshal_LDADD = $(top_builddir)/dbus/libdbus-1.la \
175     $(GLIB_LIBS) \
176     $(DBUS_GLIB_LIBS)
177
178 test_syntax_SOURCES = syntax.c
179 test_syntax_LDADD = $(top_builddir)/dbus/libdbus-1.la \
180     $(GLIB_LIBS)
181
182 if DBUS_ENABLE_MODULAR_TESTS
183 TESTS += $(installable_tests)
184 installcheck_tests += $(installable_tests)
185
186 if DBUS_ENABLE_INSTALLED_TESTS
187   testexec_PROGRAMS += $(installable_tests) $(installable_manual_tests)
188 else !DBUS_ENABLE_INSTALLED_TESTS
189   noinst_PROGRAMS += $(installable_tests) $(installable_manual_tests)
190 endif !DBUS_ENABLE_INSTALLED_TESTS
191
192 endif DBUS_ENABLE_MODULAR_TESTS
193
194 # If we're installing the tests into a DESTDIR we can't run them
195 # again using the installed copy, because we don't know how to
196 # do a portable equivalent of setting LD_LIBRARY_PATH.
197 installcheck-local:
198         $(MAKE) check-TESTS TESTS='$$(installcheck_tests)' \
199                 TESTS_ENVIRONMENT='$$(installcheck_environment)'
200 if DBUS_ENABLE_INSTALLED_TESTS
201         test -n "$(DESTDIR)" || \
202         $(installcheck_environment) \
203                 $(srcdir)/dbus-test-runner \
204                 $(testexecdir) \
205                 $(testexec_PROGRAMS)
206 endif DBUS_ENABLE_INSTALLED_TESTS
207
208 in_data = \
209         data/valid-config-files-system/debug-allow-all-fail.conf.in \
210         data/valid-config-files-system/debug-allow-all-pass.conf.in \
211         data/valid-config-files/debug-allow-all-sha1.conf.in \
212         data/valid-config-files/debug-allow-all.conf.in \
213         data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoExec.service.in \
214         data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoService.service.in \
215         data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoUser.service.in \
216         data/valid-service-files-system/org.freedesktop.DBus.TestSuiteEchoService.service.in \
217         data/valid-service-files-system/org.freedesktop.DBus.TestSuiteSegfaultService.service.in \
218         data/valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service.in \
219         data/valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service.in \
220         data/valid-service-files/org.freedesktop.DBus.TestSuite.PrivServer.service.in \
221         data/valid-service-files/org.freedesktop.DBus.TestSuiteEchoService.service.in \
222         data/valid-service-files/org.freedesktop.DBus.TestSuiteForkingEchoService.service.in \
223         data/valid-service-files/org.freedesktop.DBus.TestSuiteSegfaultService.service.in \
224         data/valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service.in \
225         data/valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service.in \
226         $(NULL)
227
228 EXTRA_DIST += $(in_data)
229
230 static_data = \
231         name-test/tmp-session-like-system.conf \
232         data/auth/anonymous-client-successful.auth-script \
233         data/auth/anonymous-server-successful.auth-script \
234         data/auth/cancel.auth-script \
235         data/auth/client-out-of-mechanisms.auth-script \
236         data/auth/external-failed.auth-script \
237         data/auth/external-root.auth-script \
238         data/auth/external-silly.auth-script \
239         data/auth/external-successful.auth-script \
240         data/auth/extra-bytes.auth-script \
241         data/auth/fail-after-n-attempts.auth-script \
242         data/auth/fallback.auth-script \
243         data/auth/invalid-command-client.auth-script \
244         data/auth/invalid-command.auth-script \
245         data/auth/invalid-hex-encoding.auth-script \
246         data/auth/mechanisms.auth-script \
247         data/equiv-config-files/basic/basic-1.conf \
248         data/equiv-config-files/basic/basic-2.conf \
249         data/equiv-config-files/basic/basic.d/basic.conf \
250         data/equiv-config-files/entities/basic.d/basic.conf \
251         data/equiv-config-files/entities/entities-1.conf \
252         data/equiv-config-files/entities/entities-2.conf \
253         data/incomplete-messages/missing-body.message \
254         data/invalid-config-files/badselinux-1.conf \
255         data/invalid-config-files/badselinux-2.conf \
256         data/invalid-config-files/circular-1.conf \
257         data/invalid-config-files/circular-2.conf \
258         data/invalid-config-files/circular-3.conf \
259         data/invalid-config-files/not-well-formed.conf \
260         data/invalid-config-files/truncated-file.conf \
261         data/invalid-messages/array-of-nil.message \
262         data/invalid-messages/array-with-mixed-types.message \
263         data/invalid-messages/bad-boolean-array.message \
264         data/invalid-messages/bad-boolean.message \
265         data/invalid-messages/bad-endian.message \
266         data/invalid-messages/bad-header-field-alignment.message \
267         data/invalid-messages/boolean-has-no-value.message-raw \
268         data/invalid-messages/local-namespace.message \
269         data/invalid-messages/no-dot-in-name.message \
270         data/invalid-messages/not-nul-header-padding.message \
271         data/invalid-messages/overlong-name.message \
272         data/invalid-messages/too-little-header-padding.message \
273         data/invalid-messages/too-much-header-padding-by-far.message \
274         data/invalid-messages/too-much-header-padding.message \
275         data/invalid-messages/too-short-dict.message \
276         data/sha-1/Readme.txt \
277         data/sha-1/bit-hashes.sha1 \
278         data/sha-1/bit-messages.sha1 \
279         data/sha-1/byte-hashes.sha1 \
280         data/sha-1/byte-messages.sha1 \
281         data/valid-config-files/basic.conf \
282         data/valid-config-files/basic.d/basic.conf \
283         data/valid-config-files/entities.conf \
284         data/valid-config-files/incoming-limit.conf \
285         data/valid-config-files/many-rules.conf \
286         data/valid-config-files/system.d/test.conf \
287         data/valid-messages/array-of-array-of-uint32.message \
288         data/valid-messages/dict-simple.message \
289         data/valid-messages/dict.message \
290         data/valid-messages/emptiness.message \
291         data/valid-messages/lots-of-arguments.message \
292         data/valid-messages/no-padding.message \
293         data/valid-messages/opposite-endian.message \
294         data/valid-messages/recursive-types.message \
295         data/valid-messages/simplest-manual.message \
296         data/valid-messages/simplest.message \
297         data/valid-messages/standard-acquire-service.message \
298         data/valid-messages/standard-hello.message \
299         data/valid-messages/standard-list-services.message \
300         data/valid-messages/standard-service-exists.message \
301         data/valid-messages/unknown-header-field.message \
302         $(NULL)
303
304 EXTRA_DIST += $(static_data)
305
306 ## copy tests to builddir so that generated tests and static tests
307 ## are all in one place.
308 all-local:
309         $(AM_V_at)$(MKDIR_P) data/valid-config-files/session.d
310         $(AM_V_at)set -e && \
311         if test $(srcdir) = . || test $(srcdir) -ef .; then \
312                 echo '-- No need to copy test data as srcdir = builddir'; \
313         else \
314                 for F in $(static_data); do \
315                         $(MKDIR_P) $${F%/*}; \
316                         rm -f $$F; \
317                         cp $(srcdir)/$$F $$F; \
318                 done; \
319         fi
320
321 ## this doesn't clean most copied test data files when srcdir=builddir
322 clean-local:
323         $(AM_V_at)if test $(srcdir) = . || test $(srcdir) -ef .; then \
324                 echo '-- No need to clean test data as srcdir = builddir'; \
325         else \
326                 rm -f $(static_data); \
327         fi
328
329 imported_data = \
330         data/valid-config-files/session.conf \
331         data/valid-config-files/system.conf \
332         $(NULL)
333
334 noinst_DATA = $(imported_data)
335 CLEANFILES = $(noinst_DATA)
336
337 data/valid-config-files/session.conf: $(top_builddir)/bus/session.conf
338         $(AM_V_at)$(MKDIR_P) data/valid-config-files
339         $(AM_V_GEN)cp $< $@
340
341 data/valid-config-files/system.conf: $(top_builddir)/bus/system.conf
342         $(AM_V_at)$(MKDIR_P) data/valid-config-files
343         $(AM_V_GEN)cp $< $@