Mercurial > projects > dstress
annotate Makefile @ 273:68b883fe4fad
added *BSD support to the test framework
Anders F Bj?rklund <afb@algonet.se>
2005-02-06
mail:36b15bf19097bed2997cbed4a4fdb825@algonet.se
author | thomask |
---|---|
date | Mon, 07 Feb 2005 00:08:11 +0000 |
parents | 6cd84461e17b |
children | 368156152168 |
rev | line source |
---|---|
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
1 # $HeadURL$ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
2 # $Date$ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
3 # $Author$ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
4 # |
239 | 5 # GnuMakefile for DStress http://dstress.kuehne.cn/www/dstress.html |
6 # Copyright (C) 2004, 2005 Thomas Kuehne | |
46 | 7 # |
8 # This program is free software; you can redistribute it and/or modify | |
9 # it under the terms of the GNU General Public License as published by | |
10 # the Free Software Foundation; either version 2 of the License, or | |
11 # (at your option) any later version. | |
12 # | |
13 # This program is distributed in the hope that it will be useful, | |
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 # GNU General Public License for more details. | |
17 # | |
18 # You should have received a copy of the GNU General Public License | |
19 # along with this program; if not, write to the Free Software | |
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 # | |
0 | 22 |
46 | 23 # dir: temp objects will be placed there |
32 | 24 ifndef OBJ_DIR |
190 | 25 OBJ_DIR := obj |
32 | 26 endif |
27 | |
46 | 28 # file: append compiler messages and runtime assertions |
83 | 29 # NOTE: this has to be an absolut path (required for some complex.mak files) |
32 | 30 ifndef LOG |
190 | 31 LOG := $(PWD)/log.txt |
32 | 32 endif |
0 | 33 |
46 | 34 # executeable: the compiler |
0 | 35 ifndef DMD |
190 | 36 DMD := dmd |
0 | 37 endif |
38 | |
46 | 39 # executeable: a GNU findutils compatible find (e.g.: find path -regex "?\\.*something") |
0 | 40 ifndef FIND |
190 | 41 FIND := find |
0 | 42 endif |
43 | |
46 | 44 # executeable: remove zero or more files (e.g.: rm -f a b c) |
0 | 45 ifndef RM |
190 | 46 RM := rm -f |
0 | 47 endif |
48 | |
46 | 49 # executeable: change to a given dir (e.g. cd some/other/dir) |
50 ifndef CD | |
190 | 51 CD := cd |
46 | 52 endif |
53 | |
54 # executeable: display a message test (e.g. echo "something to say) | |
0 | 55 ifndef ECHO |
190 | 56 ECHO := echo |
0 | 57 endif |
58 | |
46 | 59 # executeable: update the timestamp of an existing file or create a new empty file |
0 | 60 ifndef TOUCH |
190 | 61 TOUCH := touch |
0 | 62 endif |
63 | |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
64 # executeable: detect if stdin contains "Internal error" (dmd) or "gcc.gnu.org/bugs" (gcd) |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
65 ifndef GREP |
190 | 66 GREP := grep -s '\(Internal error\)\|\(gcc.gnu.org/bugs\)' > /dev/null 2>&1 |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
67 endif |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
68 |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
69 # executeable: used to concat files |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
70 ifndef CAT |
190 | 71 CAT := cat |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
72 endif |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
73 |
46 | 74 ############################################################################### |
75 ############################################################################### | |
76 # | |
77 # nothing to customize below | |
78 # | |
79 ############################################################################### | |
80 ############################################################################### | |
6 | 81 |
83 | 82 # tools |
190 | 83 return__ := ./return__ |
84 ifeq__ := ./ifeq__ | |
85 extract__ := ./extract__ | |
251 | 86 dstress__ := ./dstress__ |
83 | 87 |
72 | 88 # settings |
190 | 89 to_log := >> $(LOG) 2>&1 |
90 ext_run := exe | |
91 ext_norun := bin | |
92 ext_nocompile := no | |
93 ext_compile := o | |
94 ext_source := d | |
95 ext_source_html := html | |
96 ext_log := log | |
97 complex_todo := complex.mak | |
98 complex_done := complex.done | |
99 flag_pattern := __DSTRESS_DFLAGS__ | |
0 | 100 |
251 | 101 .PHONY: all basic_tools compile nocompile run norun complex clean distclean clean_log |
190 | 102 |
103 .SUFFIXES: $(ext_run) $(ext_norun) $(ext_nocompile) $(ext_compile) | |
46 | 104 # |
105 # test everything | |
106 # | |
107 all : Makefile compile nocompile run norun complex | |
6 | 108 |
46 | 109 # |
72 | 110 # the tools |
111 # | |
83 | 112 $(return__) : return__.c Makefile |
113 $(CC) $(CFLAGS) $< -o $@ | |
114 | |
115 $(ifeq__) : ifeq__.c Makefile | |
72 | 116 $(CC) $(CFLAGS) $< -o $@ |
117 | |
83 | 118 $(extract__) : extract__.c Makefile |
72 | 119 $(CC) $(CFLAGS) $< -o $@ |
120 | |
251 | 121 $(dstress__) : dstress.c Makefile |
122 $(CC) $(CFLAGS) $< -o $@ | |
123 | |
124 basic_tools : $(ifeq__) $(return__) $(extract__) $(dstress__) | |
72 | 125 |
83 | 126 |
72 | 127 # |
46 | 128 # include complex test cases |
129 # | |
190 | 130 complex_makefiles := $(sort $(shell $(FIND) complex -regex ".*$(complex_todo)")) |
46 | 131 include $(complex_makefiles) |
6 | 132 |
83 | 133 # |
134 # extract potential compiling flags from the test case sources | |
135 # | |
136 define extract_z_flags | |
137 $(eval z_flags = $(shell $(extract__) $(flag_pattern) < $<)) | |
138 endef | |
139 | |
46 | 140 # |
141 # target should fail to compile | |
142 # | |
251 | 143 nocompile : $(dstress__) |
144 rm -f nocompile/*.o nocompile/*.$(ext_nocompile) | |
273 | 145 find nocompile/ -maxdepth 1 -name "?*.?*" | grep "." | sort | xargs -n 1 echo "$(dstress__) nocompile" > nocompile.sh |
251 | 146 chmod +x nocompile.sh |
147 ./nocompile.sh 2>> $(LOG) | |
17 | 148 |
251 | 149 # used in some complex test cases |
75 | 150 define analyse_nocompile |
72 | 151 @if $(ifeq__) $(z_return) 0 ; then \ |
46 | 152 $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \ |
153 else \ | |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
154 if $(CAT) $(z_log) | $(GREP) ; then \ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
155 $(ECHO) "ERROR: $(z_name) [Internal compiler error]"; $(RM) $@; \ |
72 | 156 else \ |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
157 if $(ifeq__) $(z_return) 256 ; then \ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
158 $(ECHO) "XFAIL: $(z_name)"; $(TOUCH) $@; \ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
159 else \ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
160 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; $(RM) $@; \ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
161 fi \ |
72 | 162 fi \ |
46 | 163 fi |
75 | 164 endef |
165 | |
46 | 166 # |
167 # target should compile (excludes linking) | |
168 # | |
251 | 169 compile : $(dstress__) |
170 rm -f compile/*.o compile/*.$(ext_compile) | |
273 | 171 find compile/ -maxdepth 1 -name "?*.?*" | grep "." | sort | xargs -n 1 echo "$(dstress__) compile" > compile.sh |
251 | 172 chmod +x compile.sh |
173 ./compile.sh 2>> $(LOG) | |
0 | 174 |
251 | 175 # used in some complex test cases |
75 | 176 define analyse_compile |
72 | 177 @if $(ifeq__) $(z_return) 0 ; then \ |
217 | 178 $(ECHO) "PASS: $(z_name)"; $(TOUCH) $@; \ |
46 | 179 else \ |
72 | 180 if $(ifeq__) $(z_return) 256 ; then \ |
181 $(ECHO) "FAIL: $(z_name)"; $(RM) $@; \ | |
182 else \ | |
75 | 183 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; $(RM) $@; \ |
72 | 184 fi \ |
46 | 185 fi |
75 | 186 endef |
187 | |
46 | 188 # |
189 # target should compile, link and run | |
190 # | |
251 | 191 run : $(dstress__) |
192 rm -f run/*.exe run/*.$(ext_run) | |
273 | 193 find run/ -maxdepth 1 -name "?*.?*" | grep "." | sort | xargs -n 1 echo "$(dstress__) run" > run.sh |
251 | 194 chmod +x run.sh |
195 ./run.sh 2>> $(LOG) | |
0 | 196 |
251 | 197 # used in some complex testcases |
75 | 198 define analyse_run |
72 | 199 @if $(ifeq__) $(z_return) 0 ; then \ |
80 | 200 $(eval z_return2 = $(shell $(return__) "./$@ $(to_log)")) \ |
201 if $(ifeq__) $(z_return2) 0 ; then \ | |
46 | 202 $(ECHO) "PASS: $(z_name)"; \ |
203 else \ | |
80 | 204 if $(ifeq__) $(z_return2) 256 ; then \ |
205 $(ECHO) "FAIL: $(z_name)"; $(RM) $@; \ | |
206 else \ | |
207 $(ECHO) "ERROR: $(z_name) [run: $(z_return2)]"; $(RM) $@; \ | |
208 fi \ | |
46 | 209 fi \ |
210 else \ | |
72 | 211 if $(ifeq__) $(z_return) 256 ; then \ |
212 $(ECHO) "FAIL: $(z_name) (compiling error)"; \ | |
213 else \ | |
75 | 214 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; \ |
72 | 215 fi \ |
46 | 216 fi |
75 | 217 endef |
46 | 218 |
219 # | |
108 | 220 # target should compile, link and run |
221 # (used for Makefile diagnosis) | |
222 # | |
223 %.diagnose.$(ext_run) : %.$(ext_source) basic_tools | |
224 # destination: $@ | |
225 # source: $< | |
109
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
226 $(eval y_tmp = OK) |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
227 # eval: $(y_tmp) |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
228 # shell: |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
229 @$(ECHO) $(shell $(ECHO) "OK") |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
230 $(eval y_tmp = $(shell $(ECHO) "OK")) |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
231 # eval.shell: $(y_tmp) |
108 | 232 $(eval z_name = $(subst .diagnose.$(ext_run),,$@)) |
233 # name: $(z_name) | |
234 # extract__: $(extract__) | |
235 # extract__.cmd: $(extract__) $(flag_pattern) < $< | |
236 $(extract_z_flags) | |
237 # extract__.result: $(z_flags) | |
238 # ifeq__: $(ifeq__) | |
239 # continue if ifeq__ works | |
240 $(ifeq__) someString someString | |
241 # return__: $(return__) | |
242 # dmd: $(DMD) | |
243 $(eval y_tmp = $(shell $(return__) "$(ifeq__) 1 1")) | |
244 # return__.return_code_0: $(y_tmp) (expect=0) | |
245 $(eval y_tmp = $(shell $(return__) "$(DMD) > /dev/null")) | |
246 # return__.return_code_1: $(y_tmp) (expect=256) | |
247 # dmd.cmd: $(DMD) $(DFLAGS) $(z_flags) -od$(OBJ_DIR) -of$@ $< $(to_log) | |
248 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) $(z_flags) -od$(OBJ_DIR) -of$@ $< $(to_log)")) | |
249 # dmd.return: $(z_return) | |
250 # for analyse_run diagnosis: '@if' -> 'if' in 'define analyse_run' (line 185) | |
251 $(analyse_run) | |
252 | |
253 # | |
46 | 254 # target should compile and link but fail to run |
255 # | |
251 | 256 norun : $(dstress__) |
257 rm -f norun/*.exe norun/*.$(ext_norun) | |
273 | 258 find norun/ -maxdepth 1 -name "?*.?*" | grep "." | sort | xargs -n 1 echo "$(dstress__) norun" > norun.sh |
251 | 259 chmod +x norun.sh |
260 ./norun.sh 2>> $(LOG) | |
0 | 261 |
251 | 262 # used in some complex test cases |
75 | 263 define analyse_norun |
72 | 264 @if $(ifeq__) $(z_return) 0; then \ |
265 if ./$@ $(to_log); \ | |
58 | 266 then $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \ |
46 | 267 else \ |
72 | 268 $(ECHO) "XFAIL: $(z_name)"; \ |
46 | 269 fi \ |
270 else \ | |
72 | 271 if $(ifeq__) $(z_return) 256 ; then \ |
272 $(ECHO) "FAIL: $(z_name) (compiling error)"; $(RM) $@; \ | |
273 else \ | |
75 | 274 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; \ |
72 | 275 fi \ |
46 | 276 fi |
75 | 277 endef |
278 | |
46 | 279 # |
280 # run all complex test cases | |
281 # | |
251 | 282 complex : basic_tools $(sort $(subst $(complex_todo),$(complex_done),$(complex_makefiles))) |
32 | 283 |
46 | 284 # |
285 # | |
286 # | |
17 | 287 distclean : clean_log clean |
251 | 288 $(RM) $(shell $(FIND) . -regex ".*~") $(shell $(FIND) . -regex "\\..*\\.swp") $(shell $(FIND) . -regex "#.*#") |
289 $(RM) $(return__) $(ifeq__) $(extract__) $(dstress__) www/*.class | |
6 | 290 |
46 | 291 # |
292 # remove compiler and assertion messages | |
293 # | |
0 | 294 clean_log : |
295 $(RM) $(LOG) | |
296 | |
46 | 297 # |
298 # remove targets and all temp objects | |
299 # | |
300 clean : $(sort $(subst $(complex_todo),clean,$(complex_makefiles))) | |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
301 $(RM) $(OBJ_DIR)/?*.?* nocompile/?*.$(ext_log) |
46 | 302 $(RM) run/?*.$(ext_run) norun/?*.$(ext_norun) compile/?*.$(ext_compile) nocompile/?*.$(ext_nocompile) |
251 | 303 $(RM) run.sh norun.sh compile.sh nocompile.sh |
83 | 304 |
305 # the empty line above has to remain, otherwise some weired problems can arise |