2 # Part of SDCC - http://sdcc.sourceforge.net/
3 # Michael Hope <michaelh@juju.net.nz> 2001
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.
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
18 # * The sdcc-extra package, available from CVS.
19 # o cvs -d cvs.sdcc.sourceforge.net:/cvsroot/sdcc co 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
27 # The paths below assume that sdcc, sdcc-extra, and gbdk-lib all reside in
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.
39 # Uncomment this to show only errors and the summary.
40 # Comment this out for debugging.
43 # All original tests live in TESTS_DIR and below
45 TESTS_NAME = $(TESTS_DIR)
46 # All suite results go in RESULTS_DIR
48 # All data relating to supported ports live in their own directory
52 # Itermediate data directories
53 # Directory that generated cases and the related object code go.
56 # Script that takes a source test suite and generates the iterations
57 GENERATE_CASES = generate-cases.py
59 # Magically generate the list of configured ports to test.
60 # Each directory under ports/ is used as a port name. Each port is tested.
61 # The port name must be the same as the one used in the SDCC '-mxxx' argument.
62 # Each port must have a spec.mk which describes how to build the object
63 # files and how to run the emulator.
64 ALL_PORTS = $(filter-out CVS mcs51 gbz80,$(notdir $(wildcard $(PORTS_DIR)/*)))
68 # Test all of the ports
70 for i in $(ALL_PORTS); do $(MAKE) inter-port-clean test-port PORT=$$i; done
72 # Helper rule for testing the z80 port only
74 $(MAKE) inter-port-clean test-port PORT=z80
76 # Helper rule for testing the z80 port only
78 $(MAKE) inter-port-clean test-port PORT=gbz80
80 # Helper rule for testing the mcs51 small model port only
82 $(MAKE) inter-port-clean test-port PORT=mcs51
84 # Helper rule for testing the host cc only
86 $(MAKE) inter-port-clean clean test-port PORT=host
89 $(MAKE) test-port PORT=host
91 # Begin per-port rules
92 # List of all of the known source test suites.
93 ALL_TESTS = $(shell find $(TESTS_DIR) -name "*.c")
95 # Intermediate directory
96 PORT_CASES_DIR = $(CASES_DIR)/$(PORT)
97 PORT_RESULTS_DIR = $(RESULTS_DIR)/$(PORT)
98 # Each test generates a result log file
99 PORT_RESULTS = $(ALL_TESTS:$(TESTS_DIR)/%.c=$(PORT_RESULTS_DIR)/%.out)
102 SDCC_EXTRA_DIR = ../../../sdcc-extra
104 # Defaults. Override in spec.mk if required.
106 SDCC = $(SDCC_DIR)/bin/sdcc
108 SDCCFLAGS = -m$(PORT)
109 # Extension of object intermediate files
111 # Extension of files that can be run in the emulator
113 # Currently unused. Extension to append to intermediate directories.
116 # Only include if we're in a per-port call.
118 include $(PORTS_DIR)/$(PORT)/spec.mk
121 SDCCFLAGS += -Ifwk/include -Itests
123 # List of intermediate files to keep. Pretty much keep everything as
124 # disk space is free.
125 .PRECIOUS: $(PORT_CASES_DIR)/% %$(OBJEXT) %$(EXEEXT)
127 # Rule to generate the iterations of a test suite off the soure suite.
128 $(PORT_CASES_DIR)/%/iterations.stamp: $(TESTS_DIR)/%.c $(GENERATE_CASES)
130 rm -rf $(CASES_DIR)/$(TESTS_NAME)
131 mkdir -p $(CASES_DIR)/$(TESTS_NAME)
132 mkdir -p `dirname $@`
133 python $(GENERATE_CASES) $< > /dev/null
134 cp $(CASES_DIR)/$(TESTS_NAME)/*.c `dirname $@`
137 # Rule linking the combined results log to all of the files in the
138 # iteration directory.
139 $(PORT_RESULTS_DIR)/%.out: $(PORT_CASES_DIR)/%/iterations.stamp
140 $(MAKE) iterations PORT=$(PORT) CASES=`dirname $<`
142 # Rule to summaries the results for one port after all of the tests
144 port-results: port-dirs $(PORT_RESULTS)
145 echo Summary for \'$(PORT)\': `cat $(PORT_RESULTS) | python collate-results.py`
148 mkdir -p $(PORT_CASES_DIR) $(PORT_RESULTS_DIR)
150 test-port: port-results
152 # Begin rules that process each iteration generated from the source
155 # List of all of the generated iteration source files.
156 SUB_CASES = $(sort $(wildcard $(CASES)/*.c))
157 # List of all the sub result logs generated from the iterations.
158 SUB_RESULTS = $(SUB_CASES:%.c=%.out)
159 # Overall target. Concatenation of all of the sub results.
160 RESULTS = $(CASES:$(CASES_DIR)/%$(DIREXT)=$(RESULTS_DIR)/%.out)
162 iterations: $(RESULTS)
164 # Rule to generate the overall target from the sub results.
165 $(RESULTS): $(SUB_RESULTS)
166 cat $(SUB_RESULTS) > $@
168 # The remainder of the rules are in $PORT/spec.mak. The port needs to
169 # be able to turn an iterated test suite into a sub result, normally
171 # 1. Compile the required library files
172 # 2. Compile this test suite.
173 # 3. Link 1, 2, and any required stdlib into an executable.
174 # 4. Run the executable inside an emulator, and capture the text
177 # The emulator must exit when main() returns.
182 rm -rf $(CASES_DIR) $(RESULTS_DIR) *.pyc
185 rm -f fwk/lib/*.o fwk/lib/*.asm