1 | # ---------------------------------------------------------- |
---|
2 | # _ _ __ _ __ ____ ____ ____ ____ ____ ____ |
---|
3 | # / )( \( ( \( )(_ _) (_ _)( __)/ ___)(_ _)/ ___) |
---|
4 | # ) \/ (/ / )( )( )( ) _) \___ \ )( \___ \ |
---|
5 | # \____/\_)__)(__) (__) (__) (____)(____/ (__) (____/ |
---|
6 | # |
---|
7 | # ---------------------------------------------------------- |
---|
8 | |
---|
9 | |
---|
10 | .SUFFIXES: .cxx .o .sym .done |
---|
11 | |
---|
12 | dummy: |
---|
13 | false |
---|
14 | |
---|
15 | include Makefile.setup.include |
---|
16 | |
---|
17 | |
---|
18 | RELUNITDIR=../$(UNITDIR) |
---|
19 | FULLUNITDIR=$(ARBHOME)/$(UNITDIR) |
---|
20 | |
---|
21 | # Note: whitespace is important for the following tests! |
---|
22 | |
---|
23 | SHAREDLIBS= \ |
---|
24 | CORE \ |
---|
25 | ARBDB \ |
---|
26 | AWT \ |
---|
27 | WINDOW \ |
---|
28 | |
---|
29 | EXEOBJDIRS= \ |
---|
30 | TOOLS \ |
---|
31 | PERLTOOLS \ |
---|
32 | HELP_SOURCE \ |
---|
33 | AISC_MKPTPS \ |
---|
34 | PROBE_SET \ |
---|
35 | |
---|
36 | ISSHAREDLIB=$(findstring $(UNITDIR) , $(SHAREDLIBS) ) |
---|
37 | ISEXEOBJECT=$(findstring $(UNITDIR) , $(EXEOBJDIRS) ) |
---|
38 | |
---|
39 | ifneq ($(ISSHAREDLIB),) |
---|
40 | UNITLIB=$(UNITLIBNAME).$(SHARED_LIB_SUFFIX) |
---|
41 | else |
---|
42 | ifneq ($(ISEXEOBJECT),) |
---|
43 | UNITLIB=$(UNITLIBNAME).o |
---|
44 | else |
---|
45 | UNITLIB=$(UNITLIBNAME).a |
---|
46 | endif |
---|
47 | endif |
---|
48 | |
---|
49 | UNIQUE_NAME=test_$(subst /,_,$(subst .,_,$(UNITDIR)_$(UNITLIB))) |
---|
50 | |
---|
51 | ifneq ($(ISSHAREDLIB),) |
---|
52 | FULLLIB=$(ARBHOME)/lib/$(UNITLIB) |
---|
53 | else |
---|
54 | FULLLIB=$(FULLUNITDIR)/$(UNITLIB) |
---|
55 | endif |
---|
56 | |
---|
57 | RUNDIR=run# see also UnitTester.cxx@chdir |
---|
58 | |
---|
59 | SKIPPING_SLOW_TEST=$(wildcard skipslow.stamp) |
---|
60 | ifeq ($(SKIPPING_SLOW_TEST),) |
---|
61 | DESTDIR=tests.slow |
---|
62 | else |
---|
63 | DESTDIR=tests |
---|
64 | endif |
---|
65 | |
---|
66 | TEST_BASE=$(DESTDIR)/$(UNIQUE_NAME) |
---|
67 | |
---|
68 | SYMLIST=$(TEST_BASE).sym |
---|
69 | TEST_CODE=$(TEST_BASE).cxx |
---|
70 | TEST_OBJ=$(TEST_BASE).o |
---|
71 | TEST_EXE=$(TEST_BASE) |
---|
72 | TEST_DONE=$(TEST_BASE).done |
---|
73 | |
---|
74 | MAKESYMLIST=./make_symlist.sh |
---|
75 | SYM2TESTCODE=./sym2testcode.pl |
---|
76 | DUMPTESTLOCATIONS=./dumpTestLocations.pl |
---|
77 | |
---|
78 | INCDIR=../INCLUDE |
---|
79 | |
---|
80 | INCLUDES= \ |
---|
81 | UnitTester.hxx \ |
---|
82 | $(INCDIR)/arb_assert.h \ |
---|
83 | |
---|
84 | UNIT_TESTER_LIB=./UNIT_TESTER.a |
---|
85 | |
---|
86 | ifeq ($(UNITLIB),.a) |
---|
87 | # nothing given (only avoids undefined symbols) |
---|
88 | LINKLIST= |
---|
89 | LINKDEPS= |
---|
90 | else |
---|
91 | LINKLIST=$(shell ../SOURCE_TOOLS/needed_libs.pl -S -A .. -l $(FULLLIB)) |
---|
92 | LINKDEPS=$(shell ../SOURCE_TOOLS/needed_libs.pl -S -A .. -F $(FULLLIB)) |
---|
93 | endif |
---|
94 | |
---|
95 | ifeq ($(CHECK_LEAKS),0) |
---|
96 | LEAKS:= |
---|
97 | else |
---|
98 | ifeq ($(CHECK_LEAKS),1) |
---|
99 | LEAKS:=-l |
---|
100 | else |
---|
101 | LEAKS:=-l -r |
---|
102 | endif |
---|
103 | endif |
---|
104 | |
---|
105 | # -------------------------------------------------------------------------------- |
---|
106 | |
---|
107 | clean: |
---|
108 | rm -f $(DESTDIR)/* |
---|
109 | |
---|
110 | # -------------------------------------------------------------------------------- |
---|
111 | |
---|
112 | $(DESTDIR): |
---|
113 | test -d $(DESTDIR) || mkdir -p $(DESTDIR) |
---|
114 | |
---|
115 | $(RUNDIR): |
---|
116 | test -d $(RUNDIR) || mkdir -p $(RUNDIR) |
---|
117 | |
---|
118 | makedirs: $(DESTDIR) $(RUNDIR) |
---|
119 | |
---|
120 | $(SYMLIST) : $(FULLLIB) Makefile makedirs show_test_header $(MAKESYMLIST) |
---|
121 | $(MAKESYMLIST) $(FULLLIB) $(SYMLIST) |
---|
122 | |
---|
123 | $(TEST_CODE) : $(SYMLIST) $(SYM2TESTCODE) Makefile.test Makefile.setup.local |
---|
124 | $(SYM2TESTCODE) $(UNITLIB) $(RESTRICT_MODULE) $(RESTRICT_FUN) $< $@.tmp $(WARN_LEVEL) |
---|
125 | ../SOURCE_TOOLS/mv_if_diff $@.tmp $@ |
---|
126 | |
---|
127 | $(TEST_OBJ) : $(TEST_CODE) $(INCLUDES) |
---|
128 | $(A_CXX) $(cflags) $(cxxflags) -c $< -o $@ $(CXX_INCLUDES) $(POST_COMPILE) $< |
---|
129 | |
---|
130 | $(TEST_EXE) : $(TEST_OBJ) $(UNIT_TESTER_LIB) $(LINKDEPS) |
---|
131 | $(LINK_EXECUTABLE) $@ $< $(UNIT_TESTER_LIB) -L../lib $(LINKLIST) |
---|
132 | |
---|
133 | dump: |
---|
134 | @echo "$(SEP) dump $(UNITLIBNAME)" |
---|
135 | @echo "UNITDIR ='$(UNITDIR)'" |
---|
136 | @echo "UNITLIBNAME ='$(UNITLIBNAME)'" |
---|
137 | @echo "FULLUNITDIR ='$(FULLUNITDIR)'" |
---|
138 | @echo "ISSHAREDLIB ='$(ISSHAREDLIB)'" |
---|
139 | @echo "UNITLIB ='$(UNITLIB)'" |
---|
140 | @echo "FULLLIB ='$(FULLLIB)'" |
---|
141 | @echo "UNIQUE_NAME ='$(UNIQUE_NAME)'" |
---|
142 | @echo "SYMLIST ='$(SYMLIST)'" |
---|
143 | @echo "TEST_CODE ='$(TEST_CODE)'" |
---|
144 | @echo "TEST_OBJ ='$(TEST_OBJ)'" |
---|
145 | @echo "TEST_EXE ='$(TEST_EXE)'" |
---|
146 | @echo "INCLUDES ='$(INCLUDES)'" |
---|
147 | @echo "LINKLIST ='$(LINKLIST)'" |
---|
148 | @echo "LINKDEPS ='$(LINKDEPS)'" |
---|
149 | |
---|
150 | do_valgrind: |
---|
151 | @echo "Valgrinding $(TEST_EXE)" |
---|
152 | $(ARBHOME)/SOURCE_TOOLS/arb_valgrind -e -q $(LEAKS) -c 40 $(TEST_EXE) || \ |
---|
153 | echo "UnitTester: $(UNITLIBNAME) valgrind reports error(s)" |
---|
154 | |
---|
155 | show_test_header: |
---|
156 | @echo "" |
---|
157 | @echo "-------------------- [ Test $(UNITLIBNAME) ] --------------------" |
---|
158 | |
---|
159 | |
---|
160 | $(TEST_DONE) : $(TEST_EXE) |
---|
161 | @echo "fake[2]: Entering directory \`$(FULLUNITDIR)'" |
---|
162 | ifeq ($(findstring B,$(VALGRIND)),B) |
---|
163 | $(MAKE) -f Makefile.test do_valgrind |
---|
164 | endif |
---|
165 | $(TEST_EXE) |
---|
166 | ifeq ($(COVERAGE),1) |
---|
167 | @echo "UnitTester: coverage" # do not remove (used as trigger) |
---|
168 | @echo "-------------------- test-coverage for $(UNITLIBNAME)" |
---|
169 | ./gcov2msg.sh $(FULLUNITDIR) $(UNITLIBNAME) |
---|
170 | @echo "-------------------- test-coverage for $(UNITLIBNAME) [end]" |
---|
171 | endif |
---|
172 | ifeq ($(findstring A,$(VALGRIND)),A) |
---|
173 | $(MAKE) -f Makefile.test do_valgrind |
---|
174 | endif |
---|
175 | @echo "fake[2]: Leaving directory \`$(FULLUNITDIR)'" |
---|
176 | touch $@ |
---|
177 | |
---|
178 | perform_test: $(TEST_DONE) |
---|
179 | @echo "UnitTester: target=$(UNITLIBNAME) tests=0 (possibly skipped because unchanged)" |
---|
180 | |
---|
181 | skip_test: |
---|
182 | @echo "UnitTester: target=$(UNITLIBNAME) tests=0 (skipped via RESTRICT_LIB)" |
---|
183 | |
---|
184 | # -------------------- |
---|
185 | |
---|
186 | try_create_test_code: |
---|
187 | @rm -f $(TEST_CODE) |
---|
188 | ( $(MAKE) -f Makefile.test $(TEST_CODE) || true ) |
---|
189 | # always reports success. either create TEST_CODE or not. |
---|
190 | |
---|
191 | check_no_test: try_create_test_code |
---|
192 | @( \ |
---|
193 | ( \ |
---|
194 | test -f $(TEST_CODE) \ |
---|
195 | && \ |
---|
196 | ( \ |
---|
197 | echo "Error: inactive testunit $(UNITLIBNAME) seems to contain tests -- please activate that unit"; \ |
---|
198 | echo "UnitTester: target=$(UNITLIBNAME) tests=1 failed=1 (testunit has to be activated)"; \ |
---|
199 | ) \ |
---|
200 | ) \ |
---|
201 | || \ |
---|
202 | echo "UnitTester: target=$(UNITLIBNAME) tests=0 (proper inactive testunit)" \ |
---|
203 | ) |
---|
204 | @( test \! -f $(TEST_CODE) || ($(DUMPTESTLOCATIONS) $(TEST_CODE) ; false) ) |
---|
205 | # @( test \! -f $(TEST_CODE) || (dumpTestLocations.pl $(TEST_CODE) ; rm -f $(TEST_CODE) ; false) ) |
---|
206 | # if TEST_CODE exists => report failure |
---|
207 | |
---|
208 | # -------------------- |
---|
209 | |
---|
210 | RUN:=perform_test |
---|
211 | |
---|
212 | ifneq ('$(RESTRICT_LIB)','') |
---|
213 | IS_RESTRICTED_TO=$(findstring :$(UNITLIBNAME):,:$(RESTRICT_LIB):) |
---|
214 | ifeq ('$(IS_RESTRICTED_TO)','') |
---|
215 | RUN:=skip_test |
---|
216 | endif |
---|
217 | endif |
---|
218 | |
---|
219 | # -------------------- |
---|
220 | |
---|
221 | ifeq ($(ONLY_CHANGED_TESTS),0) |
---|
222 | |
---|
223 | always: |
---|
224 | @echo forcing target $(TEST_DONE) |
---|
225 | |
---|
226 | $(TEST_DONE) : always |
---|
227 | |
---|
228 | else |
---|
229 | |
---|
230 | # declare some EXTRA_TEST_DEPENDENCIES |
---|
231 | |
---|
232 | TOOLDIR=../bin |
---|
233 | |
---|
234 | # tests in arb_test.o call several command-line-tools: |
---|
235 | $(DESTDIR)/test_TOOLS_arb_test_o.done : \ |
---|
236 | $(TOOLDIR)/arb_calc_pvp \ |
---|
237 | $(TOOLDIR)/arb_export_newick \ |
---|
238 | $(TOOLDIR)/arb_export_tree \ |
---|
239 | $(TOOLDIR)/arb_export_rates \ |
---|
240 | $(TOOLDIR)/arb_export_sequences \ |
---|
241 | $(TOOLDIR)/arb_export_seq_filtered \ |
---|
242 | $(TOOLDIR)/arb_probe \ |
---|
243 | $(TOOLDIR)/arb_probe_match \ |
---|
244 | $(TOOLDIR)/arb_dnarates \ |
---|
245 | |
---|
246 | # force tests affected by changed pt-server: |
---|
247 | $(DESTDIR)/test_MULTI_PROBE_MULTI_PROBE_a.done : $(TOOLDIR)/arb_pt_server |
---|
248 | $(DESTDIR)/test_AWTC_AWTC_a.done : $(TOOLDIR)/arb_pt_server |
---|
249 | $(DESTDIR)/test_TOOLS_arb_probe_o.done : $(TOOLDIR)/arb_pt_server |
---|
250 | $(DESTDIR)/test_TOOLS_arb_test_o.done : $(TOOLDIR)/arb_pt_server |
---|
251 | |
---|
252 | # help test depends on xslt processing |
---|
253 | XSLTDIR=../HELP_SOURCE |
---|
254 | $(DESTDIR)/test_HELP_SOURCE_arb_help2xml_o.done : $(XSLTDIR)/to_help.xsl $(XSLTDIR)/to_html.xsl |
---|
255 | |
---|
256 | endif |
---|
257 | |
---|
258 | # -------------------- |
---|
259 | |
---|
260 | runtest: $(RUN) |
---|
261 | #runtest: dump |
---|
262 | |
---|