2003-06-29 Miloslav Trmac <mitr@volny.cz>
[platform/upstream/dbus.git] / test / Makefile.am
1
2 INCLUDES=-I$(top_srcdir) $(DBUS_TEST_CFLAGS) 
3
4 if DBUS_BUILD_TESTS
5 TEST_BINARIES=test-service unbase64 break-loader spawn-test test-segfault test-exit test-sleep-forever
6 else
7 TEST_BINARIES=
8 endif
9
10 if DBUS_GCOV_ENABLED
11 GCOV_BINARIES=decode-gcov
12 else
13 GCOV_BINARIES=
14 endif
15
16 noinst_PROGRAMS= $(TEST_BINARIES) $(GCOV_BINARIES)
17
18 test_service_SOURCES=                           \
19         test-service.c                          \
20         test-utils.c                            \
21         test-utils.h
22
23 unbase64_SOURCES=                               \
24         unbase64.c
25
26 break_loader_SOURCES=                           \
27         break-loader.c
28
29 spawn_test_SOURCES=                             \
30         spawn-test.c
31
32 test_exit_SOURCES =                             \
33         test-exit.c
34
35 test_segfault_SOURCES =                         \
36         test-segfault.c
37
38 test_sleep_forever_SOURCES =                    \
39         test-sleep-forever.c
40
41 decode_gcov_SOURCES=                            \
42         decode-gcov.c
43
44 TEST_LIBS=$(DBUS_TEST_LIBS) $(top_builddir)/dbus/libdbus-convenience.la
45
46 test_service_LDADD=$(TEST_LIBS)
47 unbase64_LDADD=$(TEST_LIBS)
48 break_loader_LDADD= $(TEST_LIBS)
49 spawn_test_LDADD=$(TEST_LIBS)
50 decode_gcov_LDADD=$(TEST_LIBS)
51
52 EXTRA_DIST=
53
54 ## keep these in creation order, i.e. uppermost dirs first 
55 TESTDIRS=                                       \
56         data                                    \
57         data/valid-messages                     \
58         data/invalid-messages                   \
59         data/incomplete-messages                \
60         data/auth                               \
61         data/sha-1                              \
62         data/valid-config-files                 \
63         data/valid-config-files/basic.d         \
64         data/valid-config-files/system.d        \
65         data/valid-service-files
66
67 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"
68
69 dist-hook:
70         for D in $(TESTDIRS); do                                                \
71                 test -d $(distdir)/$$D || mkdir $(distdir)/$$D || exit 1 ;      \
72         done ;                                                                  \
73         FILES=`(cd $(srcdir) && $(FIND_TESTS) -o -name "*.in" -a -not -name Makefile.in)` ;                                     \
74         for F in $$FILES; do                                                    \
75                 echo '-- Disting file '$$F ;                                    \
76                 cp $(srcdir)/$$F $(distdir)/$$F || exit 1 ;                             \
77         done
78
79 ## copy tests to builddir so that generated tests and static tests 
80 ## are all in one place.
81 all-local:
82         for D in $(TESTDIRS); do                                                                \
83                 test -d $(top_builddir)/test/$$D || mkdir $(top_builddir)/test/$$D || exit 1 ;  \
84         done ;                                                                                  \
85         if test $(srcdir) != . ; then                                                           \
86                 FILES=`(cd $(srcdir) && $(FIND_TESTS))` ;                                       \
87                 for F in $$FILES; do                                                            \
88                         SRC=$(srcdir)/$$F ;                                                     \
89                         DEST=$(top_builddir)/test/$$F ;                                         \
90                         echo '-- Copying test file '$$F ;                                       \
91                         cp $$SRC $$DEST || exit 1 ;                                             \
92                         chmod u+w $$DEST || exit 1 ;                                            \
93                 done ;                                                                          \
94         else                                                                                    \
95                 echo '-- No need to copy test data as srcdir = builddir' ;                      \
96         fi ;                                                                                    \
97         echo '-- Copying' $(top_builddir)/bus/*.conf 'to test directory' ;                      \
98         cp $(top_builddir)/bus/*.conf $(top_builddir)/test/data/valid-config-files || exit 1 ;  \
99         chmod u+w $(top_builddir)/test/data/valid-config-files/*.conf || exit 1
100
101 ## this doesn't clean generated test data files when srcdir=builddir
102 clean-local:
103         if test $(srcdir) != . ; then                                   \
104                 FILES=`(cd $(top_builddir)/test && $(FIND_TESTS))` ;    \
105                 for F in $$FILES; do                                    \
106                         DEST=$(top_builddir)/test/$$F ;                 \
107                         echo '-- Deleting test file '$$F ;              \
108                         rm $$DEST || exit 1 ;                           \
109                 done ;                                                  \
110                 REVERSEDIRS= ;                                          \
111                 for D in $(TESTDIRS); do                                \
112                         REVERSEDIRS="$$D $$REVERSEDIRS" ;               \
113                 done ;                                                  \
114                 for D in $$REVERSEDIRS; do                              \
115                         rmdir $(top_builddir)/test/$$D || exit 1 ;      \
116                 done ;                                                  \
117         fi