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