08a1c0eefee0806c06fe0c0b6e7afcbf0089e579
[fw/sdcc] / support / regression / Makefile.in
1 # Test suite Makefile
2 # Part of SDCC - http://sdcc.sourceforge.net/
3 # Michael Hope <michaelh@juju.net.nz> 2001
4 #
5 # This Makefile builds and runs the test suites under tests/ for each
6 # one of the supported ports located under ports/.  The test suite
7 # results are summarised and individual test failures are logged.  The
8 # expected result is a single line per port summarising the number of
9 # failures, test points, and test cases.  The philosophy is that
10 # checked in code should always pass the suite with no failures, as
11 # then if there are failures then it is in the current developers code.
12 #
13 # Only the required suites are run.  Changing sdcc causes all to be
14 # re-run.  Changing one suite causes just that to be run.  Changing
15 # one of the library files should cause all to re-run
16
17 # Dependancies:
18 #   * The sdcc-extra package, available from svn.
19 #       o svn co https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc-extra
20 #       o Provides the emulators
21 #   * The gbdk-lib package from gbdk.
22 #       o cvs -d cvs.gbdk.sourceforge.net:/cvsroot/gbdk co gbdk-lib
23 #       o Proviles mul, div, and include files for the z80 tests.
24 #   * python 1.5 or above
25 #   * uCsim for the mcs51 port
26 #
27 # The paths below assume that sdcc, sdcc-extra, and gbdk-lib all reside in
28 # the same directory.
29
30 # Old notes:
31 # Starting at the bottom
32 # Set of source test suites
33 # Each source suite is processesd producing multiple device specific test suites.
34 # Each device specific test suite is compiled.
35 # Each device specific test suite is run, and the output recorded.
36 # The output from each device specific test suite derrived from a source
37 # test suite are collated.
38
39 # Uncomment this to show only errors and the summary.
40 # Comment this out for debugging.
41 .SILENT:
42
43 CC = @CC@
44 CPPFLAGS = @CPPFLAGS@ -DNO_VARARGS
45
46 # support VPATH:
47 VPATH        = @srcdir@
48 srcdir       = @srcdir@
49 top_srcdir   = @top_srcdir@
50 top_builddir = @top_builddir@
51
52 # All original tests live in TESTS_DIR and below
53 TESTS_DIR = $(srcdir)/tests
54 TESTS_NAME = $(TESTS_DIR)
55 # All suite results go in RESULTS_DIR
56 RESULTS_DIR = results
57 # All data relating to supported ports live in their own directory
58 # under PORTS_DIR.
59 PORTS_DIR = $(srcdir)/ports
60
61 # Itermediate data directories
62 # Directory that generated cases and the related object code go.
63 CASES_DIR = gen
64
65 # Script that takes a source test suite and generates the iterations
66 GENERATE_CASES = $(srcdir)/generate-cases.py
67
68 # Magically generate the list of configured ports to test.
69 # Each directory under ports/ is used as a port name.  Each port is tested.
70 # Each port must have a spec.mk which describes how to build the object
71 # files and how to run the emulator.
72 ALL_PORTS = $(filter-out .svn xa51 z80 gbz80 pic16 pic14 mcs51-common,$(notdir $(wildcard $(PORTS_DIR)/*)))
73
74 # These  ports will be cleaned with 'make clean'
75 CLEAN_PORTS = $(filter-out .svn mcs51-common,$(notdir $(wildcard $(PORTS_DIR)/*)))
76
77 MAKE_LIBRARY =
78
79 all: test-ports
80
81 # Test all of the ports
82 test-ports:
83         for i in $(ALL_PORTS); do $(MAKE) make_library test-port PORT=$$i; done
84
85 # Helper rule for testing the z80 port only
86 test-z80:
87         $(MAKE) test-port PORT=z80
88
89 # Helper rule for testing the z80 port only
90 test-gbz80:
91         $(MAKE) test-port PORT=gbz80
92
93 # Helper rule for testing the mcs51 port only
94 test-mcs51: test-mcs51-small test-mcs51-medium test-mcs51-large test-mcs51-stack-auto test-mcs51-xstack-auto
95
96 test-mcs51-small:
97         $(MAKE) test-port PORT=mcs51-small
98
99 test-mcs51-medium:
100         $(MAKE) test-port PORT=mcs51-medium
101
102 test-mcs51-large:
103         $(MAKE) test-port PORT=mcs51-large
104
105 test-mcs51-stack-auto:
106         $(MAKE) test-port PORT=mcs51-stack-auto
107
108 test-mcs51-xstack-auto:
109         $(MAKE) make_library test-port PORT=mcs51-xstack-auto
110
111 # Helper rule for testing the ds390 port only
112 test-ds390:
113         $(MAKE) test-port PORT=ds390
114
115 # Helper rule for testing the z80 port only(use ucSim simulator)
116 test-ucz80:
117         $(MAKE) test-port PORT=ucz80
118
119 # Helper rule for testing the hc08 port only(use ucSim simulator)
120 test-hc08:
121         $(MAKE) test-port PORT=hc08
122
123 # Helper rule for testing the xa51 port only(use ucSim simulator)
124 test-xa51:
125         $(MAKE) test-port PORT=xa51
126
127 # Helper rule for testing the pic16 port only(use gpsim simulator)
128 test-pic16:
129         $(MAKE) test-port PORT=pic16
130
131 # Helper rule for testing the pic14 port only(use gpsim simulator)
132 test-pic14:
133         $(MAKE) test-port PORT=pic14
134
135 ### Helper rule for testing the host cc only
136 test-host:
137         $(MAKE) test-port PORT=host
138
139 test-host2:
140         $(MAKE) test-port PORT=host
141
142 # Begin per-port rules
143 # List of all of the known source test suites.
144 ALL_TESTS = $(shell find $(TESTS_DIR) -name "*.c" | sort)
145
146 # Intermediate directory
147 PORT_CASES_DIR = $(CASES_DIR)/$(PORT)
148 PORT_RESULTS_DIR = $(RESULTS_DIR)/$(PORT)
149 # Each test generates a result log file
150 PORT_RESULTS = $(ALL_TESTS:$(TESTS_DIR)/%.c=$(PORT_RESULTS_DIR)/%.out)
151
152 SDCC_EXTRA_DIR = $(top_builddir)/../sdcc-extra
153 INC_DIR = $(top_srcdir)/device/include
154
155 # Defaults.  Override in spec.mk if required.
156 # Path to SDCC
157 SDCC = $(top_builddir)/bin/sdcc
158 # Base flags.
159 SDCCFLAGS += --fverbose-asm -DNO_VARARGS
160 # Extension of object intermediate files
161 OBJEXT = .o
162 # Extension of files that can be run in the emulator
163 EXEEXT = .bin
164 # Currently unused.  Extension to append to intermediate directories.
165 DIREXT =
166
167 # Only include if we're in a per-port call.
168 ifdef PORT
169 include $(PORTS_DIR)/$(PORT)/spec.mk
170 endif
171
172 make_library: $(MAKE_LIBRARY)
173
174 SDCCFLAGS += -I$(srcdir)/fwk/include -I$(srcdir)/tests -I$(INC_DIR)
175
176 # List of intermediate files to keep.  Pretty much keep everything as
177 # disk space is free.
178 .PRECIOUS: $(PORT_CASES_DIR)/% %$(OBJEXT) %$(EXEEXT)
179
180 # Rule to generate the iterations of a test suite off the soure suite.
181 $(PORT_CASES_DIR)/%/iterations.stamp: $(TESTS_DIR)/%.c $(GENERATE_CASES)
182         echo Processing $(notdir $<)
183         rm -rf $(dir $@)
184         mkdir -p $(dir $@)
185         python $(GENERATE_CASES) $< $(dir $@) > /dev/null
186         touch $@
187
188 # Rule linking the combined results log to all of the files in the
189 # iteration directory.
190 $(PORT_RESULTS_DIR)/%.out: $(PORT_CASES_DIR)/%/iterations.stamp
191         $(MAKE) iterations PORT=$(PORT) CASES=$(dir $<)
192
193 # Rule to summaries the results for one port after all of the tests
194 # have been run.
195 port-results: port-dirs $(PORT_RESULTS)
196         echo Summary for \'$(PORT)\': `cat $(PORT_RESULTS) | python $(srcdir)/collate-results.py`
197         echo
198
199 port-dirs:
200         mkdir -p $(PORT_CASES_DIR) $(PORT_RESULTS_DIR)
201         echo Running $(PORT) regression tests
202
203 test-port: port-results
204
205 # Begin rules that process each iteration generated from the source
206 # test
207
208 # List of all of the generated iteration source files.
209 SUB_CASES = $(sort $(wildcard $(CASES)*.c))
210 # List of all the sub result logs generated from the iterations.
211 SUB_RESULTS = $(SUB_CASES:%.c=%.out)
212 # Overall target.  Concatenation of all of the sub results.
213 RESULTS = $(CASES:$(CASES_DIR)/%/$(DIREXT)=$(RESULTS_DIR)/%.out)
214
215 iterations: $(RESULTS)
216
217 # Rule to generate the overall target from the sub results.
218 $(RESULTS): $(SUB_RESULTS)
219         cat $(SUB_RESULTS) > $@
220
221 # The remainder of the rules are in $PORT/spec.mk.  The port needs to
222 # be able to turn an iterated test suite into a sub result, normally
223 # by:
224 #    1. Compile the required library files
225 #    2. Compile this test suite.
226 #    3. Link 1, 2, and any required stdlib into an executable.
227 #    4. Run the executable inside an emulator, and capture the text
228 #    output into %.out.
229 #
230 # The emulator must exit when main() returns.
231
232 # BeginGeneric rules
233
234 clean:
235         rm -rf $(CASES_DIR) $(RESULTS_DIR) *.pyc
236         for i in $(CLEAN_PORTS); do $(MAKE) -f $(PORTS_DIR)/$$i/spec.mk _clean PORTS_DIR=$(PORTS_DIR) PORT=$$i; done
237
238 distclean: clean
239         rm -f Makefile