source: trunk/UNIT_TESTER/Makefile.test

Last change on this file was 18437, checked in by westram, 5 years ago
File size: 6.5 KB
Line 
1# ----------------------------------------------------------
2#   _  _  __ _  __  ____    ____  ____  ____  ____  ____
3#  / )( \(  ( \(  )(_  _)  (_  _)(  __)/ ___)(_  _)/ ___)
4#  ) \/ (/    / )(   )(      )(   ) _) \___ \  )(  \___ \
5#  \____/\_)__)(__) (__)    (__) (____)(____/ (__) (____/
6#
7# ----------------------------------------------------------
8
9
10.SUFFIXES: .cxx .o .sym .done
11
12dummy:
13        false
14
15include Makefile.setup.include
16
17
18RELUNITDIR=../$(UNITDIR)
19FULLUNITDIR=$(ARBHOME)/$(UNITDIR)
20
21# Note: whitespace is important for the following tests!
22
23SHAREDLIBS= \
24        CORE \
25        ARBDB \
26        AWT \
27        WINDOW \
28
29EXEOBJDIRS= \
30        TOOLS \
31        PERLTOOLS \
32        HELP_SOURCE \
33        AISC_MKPTPS \
34        PROBE_SET \
35
36ISSHAREDLIB=$(findstring  $(UNITDIR) , $(SHAREDLIBS) )
37ISEXEOBJECT=$(findstring  $(UNITDIR) , $(EXEOBJDIRS) )
38
39ifneq ($(ISSHAREDLIB),)
40        UNITLIB=$(UNITLIBNAME).$(SHARED_LIB_SUFFIX)
41else
42ifneq ($(ISEXEOBJECT),)
43        UNITLIB=$(UNITLIBNAME).o
44else
45        UNITLIB=$(UNITLIBNAME).a
46endif
47endif
48
49UNIQUE_NAME=test_$(subst /,_,$(subst .,_,$(UNITDIR)_$(UNITLIB)))
50
51ifneq ($(ISSHAREDLIB),)
52FULLLIB=$(ARBHOME)/lib/$(UNITLIB)
53else
54FULLLIB=$(FULLUNITDIR)/$(UNITLIB)
55endif
56
57RUNDIR=run# see also UnitTester.cxx@chdir
58
59SKIPPING_SLOW_TEST=$(wildcard skipslow.stamp)
60ifeq ($(SKIPPING_SLOW_TEST),)
61        DESTDIR=tests.slow
62else
63        DESTDIR=tests
64endif
65
66TEST_BASE=$(DESTDIR)/$(UNIQUE_NAME)
67
68SYMLIST=$(TEST_BASE).sym
69TEST_CODE=$(TEST_BASE).cxx
70TEST_OBJ=$(TEST_BASE).o
71TEST_EXE=$(TEST_BASE)
72TEST_DONE=$(TEST_BASE).done
73
74MAKESYMLIST=./make_symlist.sh
75SYM2TESTCODE=./sym2testcode.pl
76DUMPTESTLOCATIONS=./dumpTestLocations.pl
77
78INCDIR=../INCLUDE
79
80INCLUDES= \
81        UnitTester.hxx \
82        $(INCDIR)/arb_assert.h \
83
84UNIT_TESTER_LIB=./UNIT_TESTER.a
85
86ifeq ($(UNITLIB),.a)
87# nothing given (only avoids undefined symbols)
88LINKLIST=
89LINKDEPS=
90else
91LINKLIST=$(shell ../SOURCE_TOOLS/needed_libs.pl -S -A .. -l $(FULLLIB))
92LINKDEPS=$(shell ../SOURCE_TOOLS/needed_libs.pl -S -A .. -F $(FULLLIB))
93endif
94
95ifeq ($(CHECK_LEAKS),0)
96        LEAKS:=
97else
98ifeq ($(CHECK_LEAKS),1)
99        LEAKS:=-l
100else
101        LEAKS:=-l -r
102endif
103endif
104
105# --------------------------------------------------------------------------------
106
107clean:
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
118makedirs: $(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
133dump:
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
150do_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
155show_test_header:
156        @echo ""
157        @echo "-------------------- [ Test $(UNITLIBNAME) ] --------------------"
158
159
160$(TEST_DONE) : $(TEST_EXE)
161        @echo "fake[2]: Entering directory \`$(FULLUNITDIR)'"
162ifeq ($(findstring B,$(VALGRIND)),B)
163        $(MAKE) -f Makefile.test do_valgrind
164endif
165        $(TEST_EXE)
166ifeq ($(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]"
171endif
172ifeq ($(findstring A,$(VALGRIND)),A)
173        $(MAKE) -f Makefile.test do_valgrind
174endif
175        @echo "fake[2]: Leaving directory \`$(FULLUNITDIR)'"
176        touch $@
177
178perform_test: $(TEST_DONE)
179        @echo "UnitTester: target=$(UNITLIBNAME) tests=0 (possibly skipped because unchanged)"
180
181skip_test:
182        @echo "UnitTester: target=$(UNITLIBNAME) tests=0 (skipped via RESTRICT_LIB)"
183
184# --------------------
185
186try_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
191check_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
210RUN:=perform_test
211
212ifneq ('$(RESTRICT_LIB)','')
213IS_RESTRICTED_TO=$(findstring :$(UNITLIBNAME):,:$(RESTRICT_LIB):)
214ifeq ('$(IS_RESTRICTED_TO)','')
215        RUN:=skip_test
216endif
217endif
218
219# --------------------
220
221ifeq ($(ONLY_CHANGED_TESTS),0)
222
223always:
224        @echo forcing target $(TEST_DONE)
225
226$(TEST_DONE) : always
227
228else
229
230# declare some EXTRA_TEST_DEPENDENCIES
231
232TOOLDIR=../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
253XSLTDIR=../HELP_SOURCE
254$(DESTDIR)/test_HELP_SOURCE_arb_help2xml_o.done : $(XSLTDIR)/to_help.xsl $(XSLTDIR)/to_html.xsl
255
256endif
257
258# --------------------
259
260runtest: $(RUN)
261#runtest: dump
262
Note: See TracBrowser for help on using the repository browser.