Merge branch 'dbus-1.4' and update NEWS further
[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 AM_CPPFLAGS = \
8         -I$(top_srcdir) \
9         $(GLIB_CFLAGS) \
10         $(DBUS_GLIB_CFLAGS) \
11         $(NULL)
12
13 # improve backtraces from test stuff
14 AM_LDFLAGS = @R_DYNAMIC_LDFLAG@
15
16 libdbus_testutils_la_SOURCES = \
17         test-utils.c \
18         test-utils.h \
19         $(NULL)
20 libdbus_testutils_la_LIBADD = \
21         $(top_builddir)/dbus/libdbus-internal.la \
22         $(NULL)
23
24 noinst_LTLIBRARIES = libdbus-testutils.la
25
26 if DBUS_BUILD_TESTS
27 ## break-loader removed for now
28 ## most of these binaries are used in tests but are not themselves tests
29 TEST_BINARIES = \
30         shell-test \
31         spawn-test \
32         test-exit \
33         test-names \
34         test-segfault \
35         test-service \
36         test-shell-service \
37         test-sleep-forever \
38         $(NULL)
39
40 ## these are the things to run in make check (i.e. they are actual tests)
41 ## (binaries in here must also be in TEST_BINARIES)
42 TESTS = \
43         shell-test \
44         $(NULL)
45
46 ## These are conceptually part of directories that come earlier in SUBDIRS
47 ## order, but we don't want to run them til we arrive in this directory,
48 ## since they depend on stuff from this directory
49 TESTS += \
50         ../bus/bus-test$(EXEEXT) \
51         ../bus/bus-test-system$(EXEEXT) \
52         ../dbus/dbus-test$(EXEEXT) \
53         $(NULL)
54
55 if DBUS_UNIX
56 TESTS += ../bus/bus-test-launch-helper$(EXEEXT)
57 endif
58
59 else !DBUS_BUILD_TESTS
60
61 TEST_BINARIES=
62 TESTS=
63
64 endif !DBUS_BUILD_TESTS
65
66 noinst_PROGRAMS= $(TEST_BINARIES)
67
68 static_cppflags = \
69         $(AM_CPPFLAGS) \
70         -DDBUS_STATIC_BUILD \
71         $(NULL)
72
73 test_service_CPPFLAGS = $(static_cppflags)
74 test_service_LDADD = libdbus-testutils.la
75 test_names_CPPFLAGS = $(static_cppflags)
76 test_names_LDADD = libdbus-testutils.la
77 ## break_loader_CPPFLAGS = $(static_cppflags)
78 ## break_loader_LDADD = $(top_builddir)/dbus/libdbus-internal.la
79 test_shell_service_CPPFLAGS = $(static_cppflags)
80 test_shell_service_LDADD = libdbus-testutils.la
81 shell_test_CPPFLAGS = $(static_cppflags)
82 shell_test_LDADD = libdbus-testutils.la
83 spawn_test_CPPFLAGS = $(static_cppflags)
84 spawn_test_LDADD = $(top_builddir)/dbus/libdbus-internal.la
85
86 test_refs_SOURCES = internals/refs.c
87 test_refs_CPPFLAGS = $(static_cppflags)
88 test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS)
89
90 EXTRA_DIST = dbus-test-runner
91
92 testexecdir = $(libdir)/dbus-1.0/test
93
94 testexec_PROGRAMS =
95
96 installable_tests = \
97         test-corrupt \
98         test-dbus-daemon \
99         test-dbus-daemon-eavesdrop \
100         test-loopback \
101         test-marshal \
102         test-refs \
103         test-relay \
104         $(NULL)
105
106 installcheck_tests =
107 installcheck_environment = \
108         DBUS_TEST_DAEMON=$(DESTDIR)$(DBUS_DAEMONDIR)/dbus-daemon$(EXEEXT) \
109         DBUS_TEST_SYSCONFDIR=$(DESTDIR)$(sysconfdir)
110
111 TESTS_ENVIRONMENT = \
112         DBUS_BLOCK_ON_ABORT=1 \
113         DBUS_FATAL_WARNINGS=1 \
114         DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT) \
115         DBUS_TEST_DATA=@abs_top_builddir@/test/data \
116         DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus \
117         $(NULL)
118
119 test_corrupt_SOURCES = corrupt.c
120 test_corrupt_LDADD = $(top_builddir)/dbus/libdbus-1.la \
121     $(GLIB_LIBS) \
122     $(DBUS_GLIB_LIBS)
123
124 test_loopback_SOURCES = loopback.c
125 test_loopback_LDADD = $(top_builddir)/dbus/libdbus-1.la \
126     $(GLIB_LIBS) \
127     $(DBUS_GLIB_LIBS)
128
129 test_relay_SOURCES = relay.c
130 test_relay_LDADD = $(top_builddir)/dbus/libdbus-1.la \
131     $(GLIB_LIBS) \
132     $(DBUS_GLIB_LIBS)
133
134 test_dbus_daemon_SOURCES = dbus-daemon.c
135 test_dbus_daemon_LDADD = $(top_builddir)/dbus/libdbus-1.la \
136     $(GLIB_LIBS) \
137     $(DBUS_GLIB_LIBS)
138
139 test_dbus_daemon_eavesdrop_SOURCES = dbus-daemon-eavesdrop.c
140 test_dbus_daemon_eavesdrop_CPPFLAGS = $(GLIB_CFLAGS) $(DBUS_GLIB_CFLAGS)
141 test_dbus_daemon_eavesdrop_LDFLAGS = @R_DYNAMIC_LDFLAG@
142 test_dbus_daemon_eavesdrop_LDADD = $(top_builddir)/dbus/libdbus-1.la \
143     $(GLIB_LIBS) \
144     $(DBUS_GLIB_LIBS)
145
146 test_marshal_SOURCES = marshal.c
147 test_marshal_LDADD = $(top_builddir)/dbus/libdbus-1.la \
148     $(GLIB_LIBS) \
149     $(DBUS_GLIB_LIBS)
150
151 if DBUS_ENABLE_MODULAR_TESTS
152 TESTS += $(installable_tests)
153 installcheck_tests += $(installable_tests)
154
155 if DBUS_ENABLE_INSTALLED_TESTS
156   testexec_PROGRAMS += $(installable_tests)
157 else !DBUS_ENABLE_INSTALLED_TESTS
158   noinst_PROGRAMS += $(installable_tests)
159 endif !DBUS_ENABLE_INSTALLED_TESTS
160
161 endif DBUS_ENABLE_MODULAR_TESTS
162
163 # If we're installing the tests into a DESTDIR we can't run them
164 # again using the installed copy, because we don't know how to
165 # do a portable equivalent of setting LD_LIBRARY_PATH.
166 installcheck-local:
167         $(MAKE) check-TESTS TESTS='$$(installcheck_tests)' \
168                 TESTS_ENVIRONMENT='$$(installcheck_environment)'
169 if DBUS_ENABLE_INSTALLED_TESTS
170         test -n "$(DESTDIR)" || \
171         $(installcheck_environment) \
172                 $(srcdir)/dbus-test-runner \
173                 $(testexecdir) \
174                 $(testexec_PROGRAMS)
175 endif DBUS_ENABLE_INSTALLED_TESTS
176
177 ## keep these in creation order, i.e. uppermost dirs first 
178 TESTDIRS=                                       \
179         data                                    \
180         data/valid-messages                     \
181         data/invalid-messages                   \
182         data/incomplete-messages                \
183         data/auth                               \
184         data/sha-1                              \
185         data/valid-config-files                 \
186         data/valid-config-files-system          \
187         data/valid-config-files/basic.d         \
188         data/valid-config-files/session.d       \
189         data/valid-config-files/system.d        \
190         data/valid-service-files                \
191         data/valid-service-files-system         \
192         data/invalid-service-files-system       \
193         data/invalid-config-files               \
194         data/invalid-config-files-system        \
195         data/equiv-config-files                 \
196         data/equiv-config-files/basic           \
197         data/equiv-config-files/basic/basic.d   \
198         data/equiv-config-files/entities        \
199         data/equiv-config-files/entities/basic.d
200
201
202 FIND_TESTS=find . -type f -a \( -name "*.message" -o -name "*.message-raw" -o -name "*.auth-script" -o -name "*.sha1" -o -name "*.txt" -o -name "*.conf" -o -name "*.service" \)
203
204 dist-hook:
205         for D in $(TESTDIRS); do                                                \
206                 test -d $(distdir)/$$D || mkdir $(distdir)/$$D || exit 1 ;      \
207         done ;                                                                  \
208         FILES=`(cd $(srcdir) && $(FIND_TESTS) -o -name "*.in" -a -not -name Makefile.in | grep -Ev "(.svn|CVS)" )` ;                                    \
209         for F in $$FILES; do                                                    \
210                 B=`basename $$F`; \
211                 if test -e $$F.in; then \
212                         echo "-- Skipping file $$F (.in version exists)"; \
213                 elif test "x$$B" = xrun-with-tmp-session-bus.conf; then \
214                         echo "-- Skipping file $$F (generated)"; \
215                 elif test -e "$(top_srcdir)/bus/$$B"; then \
216                         echo "-- Skipping file $$F (from /bus/)"; \
217                 else \
218                         echo '-- Disting file '$$F ; \
219                         cp -f $(srcdir)/$$F $(distdir)/$$F || exit 1; \
220                 fi; \
221         done
222
223 ## copy tests to builddir so that generated tests and static tests 
224 ## are all in one place.
225 all-local:
226         $(AM_V_at)for D in $(TESTDIRS); do                                                              \
227                 test -d $(top_builddir)/test/$$D || mkdir $(top_builddir)/test/$$D || exit 1 ;  \
228         done ;                                                                                  \
229         if ! (test $(srcdir) = . || test $(srcdir) -ef .) ; then                                                                \
230                 FILES=`(cd $(srcdir) && $(FIND_TESTS) | grep -Ev "(.svn|CVS)" )` ;                                      \
231                 for F in $$FILES; do                                                            \
232                         SRC=$(srcdir)/$$F ;                                                     \
233                         DEST=$(top_builddir)/test/$$F ;                                         \
234                         echo '-- Copying test file '$$F ;                                       \
235                         cp $$SRC $$DEST || exit 1 ;                                             \
236                         chmod u+w $$DEST || exit 1 ;                                            \
237                 done ;                                                                          \
238         else                                                                                    \
239                 echo '-- No need to copy test data as srcdir = builddir' ;                      \
240         fi ;                                                                                    \
241         echo '-- Copying' $(top_builddir)/bus/*.conf 'to test directory' ;                      \
242         cp $(top_builddir)/bus/*.conf $(top_builddir)/test/data/valid-config-files || exit 1 ;  \
243         chmod u+w $(top_builddir)/test/data/valid-config-files/*.conf || exit 1
244
245 ## this doesn't clean generated test data files when srcdir=builddir
246 clean-local:
247         if test $(srcdir) != . ; then                                   \
248                 FILES=`(cd $(top_builddir)/test && $(FIND_TESTS) | grep -Ev "(.svn|CVS)" )` ;   \
249                 for F in $$FILES; do                                    \
250                         DEST=$(top_builddir)/test/$$F ;                 \
251                         echo '-- Deleting test file '$$F ;              \
252                         rm $$DEST || exit 1 ;                           \
253                 done ;                                                  \
254                 REVERSEDIRS= ;                                          \
255                 for D in $(TESTDIRS); do                                \
256                         REVERSEDIRS="$$D $$REVERSEDIRS" ;               \
257                 done ;                                                  \
258                 for D in $$REVERSEDIRS; do                              \
259                         rmdir $(top_builddir)/test/$$D || exit 1 ;      \
260                 done ;                                                  \
261         fi