Commented everything; added 'volatile' to the mix; removed some unneeded itermediate...
[fw/sdcc] / support / regression / Makefile
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 # Old nores:
18 # Starting at the bottom
19 # Set of source test suites
20 # Each source suite is processesd producing multiple device specific test suites.
21 # Each device specific test suite is compiled.
22 # Each device specific test suite is run, and the output recorded.
23 # The output from each device specific test suite derrived from a source
24 # test suite are collated.
25
26 # Uncomment this to show only errors and the summary.
27 # Comment this out for debugging.
28 .SILENT:
29
30 # All original tests live in TESTS_DIR and below
31 TESTS_DIR = tests
32 # All suite results go in RESULTS_DIR
33 RESULTS_DIR = results
34 # All data relating to supported ports live in their own directory
35 # under PORTS_DIR.
36 PORTS_DIR = ports
37
38 # Itermediate data directories
39 # Directory that generated cases and the related object code go.
40 CASES_DIR = gen
41
42 # Script that takes a source test suite and generates the iterations
43 GENERATE_CASES = generate-cases.py
44
45 # Magically generate the list of configured ports to test.
46 # Each directory under ports/ is used as a port name.  Each port is tested.
47 # The port name must be the same as the one used in the SDCC '-mxxx' argument.
48 # Each port must have a spec.mk which describes how to build the object
49 # files and how to run the emulator.
50 ALL_PORTS = $(filter-out CVS,$(notdir $(wildcard $(PORTS_DIR)/*)))
51
52 # Test all of the ports
53 test-ports:
54         for i in $(ALL_PORTS); do $(MAKE) inter-port-clean test-port PORT=$$i; done
55
56 # Begin per-port rules
57 # List of all of the known source test suites.
58 ALL_TESTS = $(shell find $(TESTS_DIR) -name "*.c")
59
60 # Intermediate directory
61 PORT_CASES_DIR = $(CASES_DIR)/$(PORT)
62 PORT_RESULTS_DIR = $(RESULTS_DIR)/$(PORT)
63 # Each test generates a result log file
64 PORT_RESULTS = $(ALL_TESTS:$(TESTS_DIR)/%.c=$(PORT_RESULTS_DIR)/%.out)
65
66 # Defaults.  Override in spec.mk if required.
67 # Path to SDCC
68 SDCC = ../../bin/sdcc
69 # Base flags.
70 SDCCFLAGS = -m$(PORT)
71 # Extension of object intermediate files
72 OBJEXT = .o
73 # Extension of files that can be run in the emulator
74 EXEEXT = .bin
75 # Currently unused.  Extension to append to intermediate directories.
76 DIREXT = 
77
78 # Only include if we're in a per-port call.
79 ifdef PORT
80 include $(PORTS_DIR)/$(PORT)/spec.mk
81 endif
82
83 SDCCFLAGS += -Ifwk/include
84
85 # List of intermediate files to keep.  Pretty much keep everything as
86 # disk space is free.
87 .PRECIOUS: $(PORT_CASES_DIR)/% %$(OBJEXT) %$(EXEEXT)
88
89 # Rule to generate the iterations of a test suite off the soure suite.
90 $(PORT_CASES_DIR)/%$(DIREXT): $(TESTS_DIR)/%.c $(GENERATE_CASES)
91         rm -rf $(CASES_DIR)/tests
92         mkdir -p $(CASES_DIR)/tests
93         mkdir -p $@
94         python $(GENERATE_CASES) $< > /dev/null
95         cp $(CASES_DIR)/tests/*.c $@
96         touch $@
97
98 # Rule linking the combined results log to all of the files in the
99 # iteration directory.
100 $(PORT_RESULTS_DIR)/%.out: $(PORT_CASES_DIR)/%$(DIREXT)
101         $(MAKE) iterations PORT=$(PORT) CASES=$<
102
103 # Rule to summaries the results for one port after all of the tests
104 # have been run.
105 port-results: port-dirs $(PORT_RESULTS)
106         echo Summary for \'$(PORT)\': `cat $(PORT_RESULTS) | python collate-results.py`
107
108 port-dirs:
109         mkdir -p $(PORT_CASES_DIR) $(PORT_RESULTS_DIR)
110
111 test-port: port-results
112
113 # Begin rules that process each iteration generated from the source
114 # test
115
116 # List of all of the generated iteration source files.
117 SUB_CASES = $(wildcard $(CASES)/*.c)
118 # List of all the sub result logs generated from the iterations.
119 SUB_RESULTS = $(SUB_CASES:%.c=%.out)
120 # Overall target.  Concatenation of all of the sub results.
121 RESULTS = $(CASES:$(CASES_DIR)/%$(DIREXT)=$(RESULTS_DIR)/%.out)
122
123 iterations: $(RESULTS)
124
125 # Rule to generate the overall target from the sub results.
126 $(RESULTS): $(SUB_RESULTS)
127         cat $(SUB_RESULTS) > $@
128
129 # The remainder of the rules are in $PORT/spec.mak.  The port needs to
130 # be able to turn an iterated test suite into a sub result, normally
131 # by:
132 #    1. Compile the required library files
133 #    2. Compile this test suite.
134 #    3. Link 1, 2, and any required stdlib into an executable.
135 #    4. Run the executable inside an emulator, and capture the text
136 #    output into %.out.
137 #
138 # The emulator must exit when main() returns.
139
140 # BeginGeneric rules
141
142 clean:
143         rm -rf $(CASES_DIR) $(RESULTS_DIR)
144
145 inter-port-clean:
146         rm -f  fwk/lib/*.o