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