Mercurial > projects > dstress
annotate Makefile @ 735:4704970e47ad
use Torture capabilities of dstress.c
author | thomask |
---|---|
date | Fri, 11 Nov 2005 21:17:23 +0000 |
parents | 528649416e9d |
children | fb70ca0d80ba |
rev | line source |
---|---|
735 | 1 # $HeadURL$ |
145
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 | |
716 | 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__ | |
639 | 86 dstress__ := ./dstress |
87 crashRun__ := ./crashRun | |
83 | 88 |
72 | 89 # settings |
190 | 90 to_log := >> $(LOG) 2>&1 |
91 ext_run := exe | |
92 ext_norun := bin | |
93 ext_nocompile := no | |
94 ext_compile := o | |
95 ext_source := d | |
96 ext_source_html := html | |
97 ext_log := log | |
98 complex_todo := complex.mak | |
99 complex_done := complex.done | |
100 flag_pattern := __DSTRESS_DFLAGS__ | |
0 | 101 |
605 | 102 .PHONY:: all version basic_tools compile nocompile run norun complex clean distclean clean_log |
190 | 103 |
104 .SUFFIXES: $(ext_run) $(ext_norun) $(ext_nocompile) $(ext_compile) | |
46 | 105 # |
106 # test everything | |
107 # | |
441 | 108 all : Makefile version compile nocompile run norun complex |
6 | 109 |
46 | 110 # |
72 | 111 # the tools |
112 # | |
83 | 113 $(return__) : return__.c Makefile |
114 $(CC) $(CFLAGS) $< -o $@ | |
115 | |
116 $(ifeq__) : ifeq__.c Makefile | |
72 | 117 $(CC) $(CFLAGS) $< -o $@ |
118 | |
83 | 119 $(extract__) : extract__.c Makefile |
72 | 120 $(CC) $(CFLAGS) $< -o $@ |
121 | |
490 | 122 $(dstress__) : dstress.c $(crashRun__) Makefile |
123 $(CC) $(CFLAGS) $< -o $@ | |
124 | |
125 $(crashRun__) : crashRun.c Makefile | |
251 | 126 $(CC) $(CFLAGS) $< -o $@ |
127 | |
128 basic_tools : $(ifeq__) $(return__) $(extract__) $(dstress__) | |
441 | 129 |
130 # | |
131 # kludge to get version information from DMD and GDC's dmd wraper | |
132 # | |
133 version: | |
134 @$(ECHO) ">>>> VERSION <<<<" | |
494 | 135 @date +"%a, %e %b %Y %T %z" |
136 @uname -s -m -r | |
441 | 137 -@$(DMD) |
138 -@$(DMD) --version version_dummy.d | |
139 @$(ECHO) "<<<< VERSION >>>>" | |
83 | 140 |
72 | 141 # |
46 | 142 # include complex test cases |
143 # | |
190 | 144 complex_makefiles := $(sort $(shell $(FIND) complex -regex ".*$(complex_todo)")) |
46 | 145 include $(complex_makefiles) |
6 | 146 |
83 | 147 # |
148 # extract potential compiling flags from the test case sources | |
149 # | |
150 define extract_z_flags | |
151 $(eval z_flags = $(shell $(extract__) $(flag_pattern) < $<)) | |
152 endef | |
153 | |
46 | 154 # |
155 # target should fail to compile | |
156 # | |
529 | 157 nocompile : $(dstress__) nocompile_clean |
735 | 158 find nocompile -type f | grep -v ".svn" | sort --ignore-case | xargs -n 1 echo "$(dstress__) torture-nocompile" > nocompile.sh |
251 | 159 chmod +x nocompile.sh |
160 ./nocompile.sh 2>> $(LOG) | |
17 | 161 |
529 | 162 nocompile_clean : |
163 $(eval z_rm = $(shell find nocompile -type f -name "*\\.o" | grep -v ".svn")) | |
164 | |
251 | 165 # used in some complex test cases |
75 | 166 define analyse_nocompile |
72 | 167 @if $(ifeq__) $(z_return) 0 ; then \ |
46 | 168 $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \ |
169 else \ | |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
170 if $(CAT) $(z_log) | $(GREP) ; then \ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
171 $(ECHO) "ERROR: $(z_name) [Internal compiler error]"; $(RM) $@; \ |
72 | 172 else \ |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
173 if $(ifeq__) $(z_return) 256 ; then \ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
174 $(ECHO) "XFAIL: $(z_name)"; $(TOUCH) $@; \ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
175 else \ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
176 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; $(RM) $@; \ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
177 fi \ |
72 | 178 fi \ |
46 | 179 fi |
75 | 180 endef |
181 | |
46 | 182 # |
183 # target should compile (excludes linking) | |
184 # | |
529 | 185 compile : $(dstress__) compile_clean |
735 | 186 find compile -type f | grep -v ".svn" | sort --ignore-case | xargs -n 1 echo "$(dstress__) torture-compile" > compile.sh |
251 | 187 chmod +x compile.sh |
188 ./compile.sh 2>> $(LOG) | |
0 | 189 |
529 | 190 compile_clean : |
191 $(eval z_rm = $(shell find compile -type f -name "*\\.o" | grep -v ".svn")) | |
192 | |
251 | 193 # used in some complex test cases |
75 | 194 define analyse_compile |
72 | 195 @if $(ifeq__) $(z_return) 0 ; then \ |
217 | 196 $(ECHO) "PASS: $(z_name)"; $(TOUCH) $@; \ |
46 | 197 else \ |
72 | 198 if $(ifeq__) $(z_return) 256 ; then \ |
199 $(ECHO) "FAIL: $(z_name)"; $(RM) $@; \ | |
200 else \ | |
75 | 201 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; $(RM) $@; \ |
72 | 202 fi \ |
46 | 203 fi |
75 | 204 endef |
205 | |
46 | 206 # |
207 # target should compile, link and run | |
208 # | |
529 | 209 run : $(dstress__) run_clean |
735 | 210 find run -type f | grep -v ".svn" | sort --ignore-case | xargs -n 1 echo "$(dstress__) torture-run" > run.sh |
251 | 211 chmod +x run.sh |
212 ./run.sh 2>> $(LOG) | |
0 | 213 |
529 | 214 run_clean : |
215 $(eval z_rm = $(shell find run -type f -name "*\\.exe" | grep -v ".svn")) | |
216 $(RM) $(z_rm) | |
217 | |
251 | 218 # used in some complex testcases |
75 | 219 define analyse_run |
72 | 220 @if $(ifeq__) $(z_return) 0 ; then \ |
80 | 221 $(eval z_return2 = $(shell $(return__) "./$@ $(to_log)")) \ |
222 if $(ifeq__) $(z_return2) 0 ; then \ | |
46 | 223 $(ECHO) "PASS: $(z_name)"; \ |
224 else \ | |
80 | 225 if $(ifeq__) $(z_return2) 256 ; then \ |
226 $(ECHO) "FAIL: $(z_name)"; $(RM) $@; \ | |
227 else \ | |
228 $(ECHO) "ERROR: $(z_name) [run: $(z_return2)]"; $(RM) $@; \ | |
229 fi \ | |
46 | 230 fi \ |
231 else \ | |
72 | 232 if $(ifeq__) $(z_return) 256 ; then \ |
233 $(ECHO) "FAIL: $(z_name) (compiling error)"; \ | |
234 else \ | |
75 | 235 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; \ |
72 | 236 fi \ |
46 | 237 fi |
75 | 238 endef |
46 | 239 |
240 # | |
108 | 241 # target should compile, link and run |
242 # (used for Makefile diagnosis) | |
243 # | |
244 %.diagnose.$(ext_run) : %.$(ext_source) basic_tools | |
245 # destination: $@ | |
246 # source: $< | |
109
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
247 $(eval y_tmp = OK) |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
248 # eval: $(y_tmp) |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
249 # shell: |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
250 @$(ECHO) $(shell $(ECHO) "OK") |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
251 $(eval y_tmp = $(shell $(ECHO) "OK")) |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
252 # eval.shell: $(y_tmp) |
108 | 253 $(eval z_name = $(subst .diagnose.$(ext_run),,$@)) |
254 # name: $(z_name) | |
255 # extract__: $(extract__) | |
256 # extract__.cmd: $(extract__) $(flag_pattern) < $< | |
257 $(extract_z_flags) | |
258 # extract__.result: $(z_flags) | |
259 # ifeq__: $(ifeq__) | |
260 # continue if ifeq__ works | |
261 $(ifeq__) someString someString | |
262 # return__: $(return__) | |
263 # dmd: $(DMD) | |
264 $(eval y_tmp = $(shell $(return__) "$(ifeq__) 1 1")) | |
265 # return__.return_code_0: $(y_tmp) (expect=0) | |
266 $(eval y_tmp = $(shell $(return__) "$(DMD) > /dev/null")) | |
267 # return__.return_code_1: $(y_tmp) (expect=256) | |
268 # dmd.cmd: $(DMD) $(DFLAGS) $(z_flags) -od$(OBJ_DIR) -of$@ $< $(to_log) | |
269 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) $(z_flags) -od$(OBJ_DIR) -of$@ $< $(to_log)")) | |
270 # dmd.return: $(z_return) | |
271 # for analyse_run diagnosis: '@if' -> 'if' in 'define analyse_run' (line 185) | |
272 $(analyse_run) | |
273 | |
274 # | |
46 | 275 # target should compile and link but fail to run |
276 # | |
529 | 277 norun : $(dstress__) norun_clean |
735 | 278 find norun -type f | grep -v ".svn" | sort --ignore-case | xargs -n 1 echo "$(dstress__) torture-norun" > norun.sh |
251 | 279 chmod +x norun.sh |
280 ./norun.sh 2>> $(LOG) | |
0 | 281 |
529 | 282 norun_clean : |
283 $(eval z_rm = $(shell find norun -type f -name "*\\.exe" | grep -v ".svn")) | |
284 $(RM) $(z_rm) | |
285 | |
251 | 286 # used in some complex test cases |
75 | 287 define analyse_norun |
72 | 288 @if $(ifeq__) $(z_return) 0; then \ |
289 if ./$@ $(to_log); \ | |
58 | 290 then $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \ |
46 | 291 else \ |
72 | 292 $(ECHO) "XFAIL: $(z_name)"; \ |
46 | 293 fi \ |
294 else \ | |
72 | 295 if $(ifeq__) $(z_return) 256 ; then \ |
296 $(ECHO) "FAIL: $(z_name) (compiling error)"; $(RM) $@; \ | |
297 else \ | |
75 | 298 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; \ |
72 | 299 fi \ |
46 | 300 fi |
75 | 301 endef |
302 | |
46 | 303 # |
304 # run all complex test cases | |
305 # | |
251 | 306 complex : basic_tools $(sort $(subst $(complex_todo),$(complex_done),$(complex_makefiles))) |
32 | 307 |
46 | 308 # |
309 # | |
310 # | |
17 | 311 distclean : clean_log clean |
708 | 312 $(RM) $(shell $(FIND) . -regex ".*~") |
313 $(RM) $(shell $(FIND) . -regex "\\..*\\.swp") | |
314 $(RM) $(shell $(FIND) . -regex "#.*#") | |
315 $(RM) $(shell $(FIND) . -regex ".*\\.map") | |
316 $(RM) $(shell $(FIND) . -regex ".*\\.bak") | |
490 | 317 $(RM) $(crashRun__) $(return__) $(ifeq__) $(extract__) $(dstress__) www/*.class |
6 | 318 |
46 | 319 # |
320 # remove compiler and assertion messages | |
321 # | |
0 | 322 clean_log : |
323 $(RM) $(LOG) | |
324 | |
46 | 325 # |
326 # remove targets and all temp objects | |
327 # | |
605 | 328 complex_clean : $(sort $(subst $(complex_todo),clean,$(complex_makefiles))) |
329 | |
330 clean : complex_clean nocompile_clean compile_clean norun_clean run_clean | |
563 | 331 $(RM) $(z_rm) $(OBJ_DIR)/?*.* |
251 | 332 $(RM) run.sh norun.sh compile.sh nocompile.sh |
83 | 333 |
334 # the empty line above has to remain, otherwise some weired problems can arise |