Checking in Rodrigo's patch along with my fixes to the patch
[platform/upstream/dbus.git] / test / Makefile.am
1
2 if HAVE_GLIB
3     GLIB_SUBDIR=glib
4 endif
5
6 SUBDIRS=$(GLIB_SUBDIR)
7 DIST_SUBDIRS=glib
8
9 INCLUDES=-I$(top_srcdir) $(DBUS_TEST_CFLAGS) 
10
11
12 if DBUS_BUILD_TESTS
13 ## break-loader removed for now
14 TEST_BINARIES=test-service test-shell-service shell-test spawn-test test-segfault test-exit test-sleep-forever
15
16 #enable stand alone make check test
17 TESTS=shell-test
18 else
19 TEST_BINARIES=
20 TESTS=
21 endif
22
23 if DBUS_GCOV_ENABLED
24 GCOV_BINARIES=decode-gcov
25 else
26 GCOV_BINARIES=
27 endif
28
29 noinst_PROGRAMS= $(TEST_BINARIES) $(GCOV_BINARIES)
30
31 test_service_SOURCES=                           \
32         test-service.c                          \
33         test-utils.c                            \
34         test-utils.h
35
36 ##break_loader_SOURCES=                         \
37 ##      break-loader.c
38
39 test_shell_service_SOURCES =                    \
40         test-shell-service.c                    \
41         test-utils.c                            \
42         test-utils.h
43
44 shell_test_SOURCES=                             \
45         shell-test.c
46
47 spawn_test_SOURCES=                             \
48         spawn-test.c
49
50 test_exit_SOURCES =                             \
51         test-exit.c
52
53 test_segfault_SOURCES =                         \
54         test-segfault.c
55
56 test_sleep_forever_SOURCES =                    \
57         test-sleep-forever.c
58
59 decode_gcov_SOURCES=                            \
60         decode-gcov.c
61
62 TEST_LIBS=$(DBUS_TEST_LIBS) $(top_builddir)/dbus/libdbus-convenience.la
63
64 test_service_LDADD=$(TEST_LIBS)
65 ## break_loader_LDADD= $(TEST_LIBS)
66 test_shell_service_LDADD=$(TEST_LIBS)
67 shell_test_LDADD=$(TEST_LIBS)
68 spawn_test_LDADD=$(TEST_LIBS)
69 decode_gcov_LDADD=$(TEST_LIBS)
70
71 EXTRA_DIST=
72
73 ## keep these in creation order, i.e. uppermost dirs first 
74 TESTDIRS=                                       \
75         data                                    \
76         data/valid-messages                     \
77         data/invalid-messages                   \
78         data/incomplete-messages                \
79         data/auth                               \
80         data/sha-1                              \
81         data/valid-config-files                 \
82         data/valid-config-files/basic.d         \
83         data/valid-config-files/system.d        \
84         data/valid-service-files                \
85         data/invalid-config-files               \
86         data/equiv-config-files                 \
87         data/equiv-config-files/basic           \
88         data/equiv-config-files/basic/basic.d   \
89         data/equiv-config-files/entities        \
90         data/equiv-config-files/entities/basic.d
91
92
93 FIND_TESTS=find -name "*.message" -o -name "*.message-raw" -o -name "*.auth-script" -o -name "*.sha1" -o -name "*.txt" -o -name "*.conf" -o -name "*.service"
94
95 dist-hook:
96         for D in $(TESTDIRS); do                                                \
97                 test -d $(distdir)/$$D || mkdir $(distdir)/$$D || exit 1 ;      \
98         done ;                                                                  \
99         FILES=`(cd $(srcdir) && $(FIND_TESTS) -o -name "*.in" -a -not -name Makefile.in)` ;                                     \
100         for F in $$FILES; do                                                    \
101                 echo '-- Disting file '$$F ;                                    \
102                 cp -f $(srcdir)/$$F $(distdir)/$$F || exit 1 ;                          \
103         done
104
105 ## copy tests to builddir so that generated tests and static tests 
106 ## are all in one place.
107 all-local:
108         for D in $(TESTDIRS); do                                                                \
109                 test -d $(top_builddir)/test/$$D || mkdir $(top_builddir)/test/$$D || exit 1 ;  \
110         done ;                                                                                  \
111         if ! (test $(srcdir) = . || test $(srcdir) -ef .) ; then                                                                \
112                 FILES=`(cd $(srcdir) && $(FIND_TESTS))` ;                                       \
113                 for F in $$FILES; do                                                            \
114                         SRC=$(srcdir)/$$F ;                                                     \
115                         DEST=$(top_builddir)/test/$$F ;                                         \
116                         echo '-- Copying test file '$$F ;                                       \
117                         cp $$SRC $$DEST || exit 1 ;                                             \
118                         chmod u+w $$DEST || exit 1 ;                                            \
119                 done ;                                                                          \
120         else                                                                                    \
121                 echo '-- No need to copy test data as srcdir = builddir' ;                      \
122         fi ;                                                                                    \
123         echo '-- Copying' $(top_builddir)/bus/*.conf 'to test directory' ;                      \
124         cp $(top_builddir)/bus/*.conf $(top_builddir)/test/data/valid-config-files || exit 1 ;  \
125         chmod u+w $(top_builddir)/test/data/valid-config-files/*.conf || exit 1
126
127 ## this doesn't clean generated test data files when srcdir=builddir
128 clean-local:
129         if test $(srcdir) != . ; then                                   \
130                 FILES=`(cd $(top_builddir)/test && $(FIND_TESTS))` ;    \
131                 for F in $$FILES; do                                    \
132                         DEST=$(top_builddir)/test/$$F ;                 \
133                         echo '-- Deleting test file '$$F ;              \
134                         rm $$DEST || exit 1 ;                           \
135                 done ;                                                  \
136                 REVERSEDIRS= ;                                          \
137                 for D in $(TESTDIRS); do                                \
138                         REVERSEDIRS="$$D $$REVERSEDIRS" ;               \
139                 done ;                                                  \
140                 for D in $$REVERSEDIRS; do                              \
141                         rmdir $(top_builddir)/test/$$D || exit 1 ;      \
142                 done ;                                                  \
143         fi