Merge branch 'dbus-1.4'
[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 EXTRA_DIST = dbus-test-runner
87
88 testexecdir = $(libdir)/dbus-1.0/test
89
90 testexec_PROGRAMS =
91
92 installable_tests = \
93         test-corrupt \
94         test-dbus-daemon \
95         test-dbus-daemon-eavesdrop \
96         test-loopback \
97         test-marshal \
98         test-relay \
99         $(NULL)
100
101 installcheck_tests =
102 installcheck_environment = \
103         DBUS_TEST_DAEMON=$(DESTDIR)$(DBUS_DAEMONDIR)/dbus-daemon$(EXEEXT) \
104         DBUS_TEST_SYSCONFDIR=$(DESTDIR)$(sysconfdir)
105
106 TESTS_ENVIRONMENT = \
107         DBUS_BLOCK_ON_ABORT=1 \
108         DBUS_FATAL_WARNINGS=1 \
109         DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT) \
110         DBUS_TEST_DATA=@abs_top_builddir@/test/data \
111         DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus \
112         $(NULL)
113
114 test_corrupt_SOURCES = corrupt.c
115 test_corrupt_LDADD = $(top_builddir)/dbus/libdbus-1.la \
116     $(GLIB_LIBS) \
117     $(DBUS_GLIB_LIBS)
118
119 test_loopback_SOURCES = loopback.c
120 test_loopback_LDADD = $(top_builddir)/dbus/libdbus-1.la \
121     $(GLIB_LIBS) \
122     $(DBUS_GLIB_LIBS)
123
124 test_relay_SOURCES = relay.c
125 test_relay_LDADD = $(top_builddir)/dbus/libdbus-1.la \
126     $(GLIB_LIBS) \
127     $(DBUS_GLIB_LIBS)
128
129 test_dbus_daemon_SOURCES = dbus-daemon.c
130 test_dbus_daemon_LDADD = $(top_builddir)/dbus/libdbus-1.la \
131     $(GLIB_LIBS) \
132     $(DBUS_GLIB_LIBS)
133
134 test_dbus_daemon_eavesdrop_SOURCES = dbus-daemon-eavesdrop.c
135 test_dbus_daemon_eavesdrop_CPPFLAGS = $(GLIB_CFLAGS) $(DBUS_GLIB_CFLAGS)
136 test_dbus_daemon_eavesdrop_LDFLAGS = @R_DYNAMIC_LDFLAG@
137 test_dbus_daemon_eavesdrop_LDADD = $(top_builddir)/dbus/libdbus-1.la \
138     $(GLIB_LIBS) \
139     $(DBUS_GLIB_LIBS)
140
141 test_marshal_SOURCES = marshal.c
142 test_marshal_LDADD = $(top_builddir)/dbus/libdbus-1.la \
143     $(GLIB_LIBS) \
144     $(DBUS_GLIB_LIBS)
145
146 if DBUS_ENABLE_MODULAR_TESTS
147 TESTS += $(installable_tests)
148 installcheck_tests += $(installable_tests)
149
150 if DBUS_ENABLE_INSTALLED_TESTS
151   testexec_PROGRAMS += $(installable_tests)
152 else !DBUS_ENABLE_INSTALLED_TESTS
153   noinst_PROGRAMS += $(installable_tests)
154 endif !DBUS_ENABLE_INSTALLED_TESTS
155
156 endif DBUS_ENABLE_MODULAR_TESTS
157
158 # If we're installing the tests into a DESTDIR we can't run them
159 # again using the installed copy, because we don't know how to
160 # do a portable equivalent of setting LD_LIBRARY_PATH.
161 installcheck-local:
162         $(MAKE) check-TESTS TESTS='$$(installcheck_tests)' \
163                 TESTS_ENVIRONMENT='$$(installcheck_environment)'
164 if DBUS_ENABLE_INSTALLED_TESTS
165         test -n "$(DESTDIR)" || \
166         $(installcheck_environment) \
167                 $(srcdir)/dbus-test-runner \
168                 $(testexecdir) \
169                 $(testexec_PROGRAMS)
170 endif DBUS_ENABLE_INSTALLED_TESTS
171
172 ## keep these in creation order, i.e. uppermost dirs first 
173 TESTDIRS=                                       \
174         data                                    \
175         data/valid-messages                     \
176         data/invalid-messages                   \
177         data/incomplete-messages                \
178         data/auth                               \
179         data/sha-1                              \
180         data/valid-config-files                 \
181         data/valid-config-files-system          \
182         data/valid-config-files/basic.d         \
183         data/valid-config-files/session.d       \
184         data/valid-config-files/system.d        \
185         data/valid-service-files                \
186         data/valid-service-files-system         \
187         data/invalid-service-files-system       \
188         data/invalid-config-files               \
189         data/invalid-config-files-system        \
190         data/equiv-config-files                 \
191         data/equiv-config-files/basic           \
192         data/equiv-config-files/basic/basic.d   \
193         data/equiv-config-files/entities        \
194         data/equiv-config-files/entities/basic.d
195
196
197 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" \)
198
199 dist-hook:
200         for D in $(TESTDIRS); do                                                \
201                 test -d $(distdir)/$$D || mkdir $(distdir)/$$D || exit 1 ;      \
202         done ;                                                                  \
203         FILES=`(cd $(srcdir) && $(FIND_TESTS) -o -name "*.in" -a -not -name Makefile.in | grep -Ev "(.svn|CVS)" )` ;                                    \
204         for F in $$FILES; do                                                    \
205                 B=`basename $$F`; \
206                 if test -e $$F.in; then \
207                         echo "-- Skipping file $$F (.in version exists)"; \
208                 elif test "x$$B" = xrun-with-tmp-session-bus.conf; then \
209                         echo "-- Skipping file $$F (generated)"; \
210                 elif test -e "$(top_srcdir)/bus/$$B"; then \
211                         echo "-- Skipping file $$F (from /bus/)"; \
212                 else \
213                         echo '-- Disting file '$$F ; \
214                         cp -f $(srcdir)/$$F $(distdir)/$$F || exit 1; \
215                 fi; \
216         done
217
218 ## copy tests to builddir so that generated tests and static tests 
219 ## are all in one place.
220 all-local:
221         $(AM_V_at)for D in $(TESTDIRS); do                                                              \
222                 test -d $(top_builddir)/test/$$D || mkdir $(top_builddir)/test/$$D || exit 1 ;  \
223         done ;                                                                                  \
224         if ! (test $(srcdir) = . || test $(srcdir) -ef .) ; then                                                                \
225                 FILES=`(cd $(srcdir) && $(FIND_TESTS) | grep -Ev "(.svn|CVS)" )` ;                                      \
226                 for F in $$FILES; do                                                            \
227                         SRC=$(srcdir)/$$F ;                                                     \
228                         DEST=$(top_builddir)/test/$$F ;                                         \
229                         echo '-- Copying test file '$$F ;                                       \
230                         cp $$SRC $$DEST || exit 1 ;                                             \
231                         chmod u+w $$DEST || exit 1 ;                                            \
232                 done ;                                                                          \
233         else                                                                                    \
234                 echo '-- No need to copy test data as srcdir = builddir' ;                      \
235         fi ;                                                                                    \
236         echo '-- Copying' $(top_builddir)/bus/*.conf 'to test directory' ;                      \
237         cp $(top_builddir)/bus/*.conf $(top_builddir)/test/data/valid-config-files || exit 1 ;  \
238         chmod u+w $(top_builddir)/test/data/valid-config-files/*.conf || exit 1
239
240 ## this doesn't clean generated test data files when srcdir=builddir
241 clean-local:
242         if test $(srcdir) != . ; then                                   \
243                 FILES=`(cd $(top_builddir)/test && $(FIND_TESTS) | grep -Ev "(.svn|CVS)" )` ;   \
244                 for F in $$FILES; do                                    \
245                         DEST=$(top_builddir)/test/$$F ;                 \
246                         echo '-- Deleting test file '$$F ;              \
247                         rm $$DEST || exit 1 ;                           \
248                 done ;                                                  \
249                 REVERSEDIRS= ;                                          \
250                 for D in $(TESTDIRS); do                                \
251                         REVERSEDIRS="$$D $$REVERSEDIRS" ;               \
252                 done ;                                                  \
253                 for D in $$REVERSEDIRS; do                              \
254                         rmdir $(top_builddir)/test/$$D || exit 1 ;      \
255                 done ;                                                  \
256         fi