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