Mercurial > projects > dstress
annotate dstress.c @ 968:8b6d2dcf9954
* fixed new line escapes in GDB_SCRIPT
* fixed gdb_script handling
* added Vlagrind crash patterns
* fixed handling of TORTURE_REQUIRE for non-torture tests
author | thomask |
---|---|
date | Wed, 19 Apr 2006 06:43:40 +0000 |
parents | f4fc739bbaaf |
children | 8da09834526d |
rev | line source |
---|---|
438 | 1 /* |
2 * core test tool for the DStress test suite | |
251 | 3 * http://dstress.kuehne.cn |
4 * | |
940 | 5 * Copyright (C) |
6 * 2005, 2006 Thomas Kuehne <thomas@kuehne.cn> | |
7 * 2005 Carlos Santander (Window files) | |
8 * 2005 Stewart Gordon <smjg_1998@yahoo.com> (Window crashRun) | |
251 | 9 * |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 * | |
24 * $HeadURL$ | |
25 * $Date$ | |
26 * $Author$ | |
27 * | |
438 | 28 */ |
251 | 29 |
704 | 30 /* Beware: the code doesn't care about freeing allocated memory etc. ... */ |
432 | 31 |
251 | 32 #include <stdlib.h> |
33 #include <stdio.h> | |
34 #include <string.h> | |
35 #include <errno.h> | |
681 | 36 #include <ctype.h> |
251 | 37 |
734 | 38 /* number's choice: XOR and printf :) */ |
39 #define MODE_RUN (0x10000) | |
40 #define MODE_NORUN (0x1000) | |
41 #define MODE_COMPILE (0x100) | |
42 #define MODE_NOCOMPILE (0x10) | |
43 #define MODE_TORTURE (0x2) | |
251 | 44 |
734 | 45 #define RES_BASE_MASK (0xFFFFFF0) |
46 #define RES_PASS (0x1000000) | |
47 #define RES_XFAIL (0x100000) | |
48 #define RES_XPASS (0x10000) | |
49 #define RES_FAIL (0x1000) | |
50 #define RES_ERROR (0x100) | |
51 #define RES_UNTESTED (0x10) | |
52 #define RES_BAD_GDB (0x4) | |
53 #define RES_BAD_MSG (0x2) | |
490 | 54 |
499 | 55 #if defined(__GNU_LIBRARY__) || defined(__GLIBC__) |
697 | 56 #define USE_POSIX 1 |
251 | 57 #endif |
58 | |
685 | 59 #if defined(linux) || defined(__FreeBSD__) || defined(__OpenBSD__) |
697 | 60 #define USE_POSIX 1 |
251 | 61 #endif |
62 | |
273 | 63 #if defined(__APPLE__) && defined(__MACH__) |
697 | 64 #define USE_POSIX 1 |
273 | 65 #endif |
66 | |
888
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
67 #if defined(WIN) || defined(WIN32) || defined(WIN64) |
633 | 68 #define USE_WINDOWS 1 |
69 #endif | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
70 |
704 | 71 /* prefere USE_POSIX over USE_WINDOWS if both APIs are detected */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
72 #ifdef USE_POSIX |
254 | 73 |
251 | 74 #include <sys/types.h> |
75 #include <sys/stat.h> | |
76 #include <fcntl.h> | |
77 #include <unistd.h> | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
78 #include <regex.h> |
734 | 79 #include <limits.h> |
490 | 80 |
904 | 81 /* not every STDLIB propperly supports C99's "%z" for printf formating */ |
82 /* (I just love those non-conforming headers...) */ | |
83 #undef ZU | |
84 | |
85 #if !defined(ZU) && defined(SSIZE_MAX) | |
86 #if defined(INT_MAX) && SSIZE_MAX == INT_MAX | |
87 #define ZU "%u" | |
88 #elif defined(LONG_MAX) && SSIZE_MAX == LONG_MAX | |
89 #define ZU "%lu" | |
90 #elif defined(LLONG_MAX) && SSIZE_MAX == LLONG_MAX | |
91 #define ZU "%llu" | |
92 #elif defined(SHRT_MAX) && SSIZE_MAX == SHRT_MAX | |
93 #define ZU "%hu" | |
94 #endif | |
95 #endif /* SSIZE_MAX */ | |
96 | |
97 #if !defined(ZU) && defined(SIZE_T_MAX) | |
98 #if defined(UINT_MAX) && SIZE_T_MAX == UINT_MAX | |
734 | 99 #define ZU "%u" |
904 | 100 #elif defined(ULONG_MAX) && SIZE_T_MAX == ULONG_MAX |
734 | 101 #define ZU "%lu" |
904 | 102 #elif defined(ULLONG_MAX) && SIZE_T_MAX == ULLONG_MAX |
103 #define ZU "%llu" | |
104 #elif defined(USHRT_MAX) && SIZE_T_MAX == USHRT_MAX | |
734 | 105 #define ZU "%hu" |
904 | 106 #endif |
107 #endif /* SIZE_T_MAX */ | |
108 | |
109 #ifndef ZU | |
110 #include <stdint.h> | |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
111 #undef ZU |
904 | 112 #ifdef PTRDIFF_MAX |
113 #if defined(INT_MAX) && PTRDIFF_MAX == INT_MAX | |
114 #define ZU "%u" | |
115 #elif defined(LONG_MAX) && PTRDIFF_MAX == LONG_MAX | |
116 #define ZU "%lu" | |
117 #elif defined(LLONG_MAX) && PTRDIFF_MAX == LLONG_MAX | |
118 #define ZU "%llu" | |
119 #elif defined(SHRT_MAX) && PTRDIFF_MAX == SHRT_MAX | |
120 #define ZU "%hu" | |
121 #endif | |
122 #endif | |
123 #endif /* PTRDIFF_MAX */ | |
124 | |
125 #ifndef ZU | |
734 | 126 #error what is the size of a pointer? |
127 #endif | |
904 | 128 |
490 | 129 #else |
633 | 130 #ifdef USE_WINDOWS |
490 | 131 |
132 #include <windows.h> | |
685 | 133 #define snprintf _snprintf |
697 | 134 #ifndef INVALID_FILE_SIZE |
704 | 135 #define INVALID_FILE_SIZE (-1) |
742 | 136 #endif |
734 | 137 |
138 /* not every STDLIB supports C99's "%z" for printf formating */ | |
746 | 139 #ifdef WIN32 |
734 | 140 #define ZU "%u" |
141 #else | |
746 | 142 #ifdef WIN64 |
734 | 143 #define ZU "%llu" |
144 #else | |
145 #error what is the size of a pointer? | |
146 #endif | |
147 #endif | |
148 | |
633 | 149 #else |
704 | 150 #error neither POSIX nor MSWindows API detected |
633 | 151 #endif /* USE_WINDOWS else */ |
490 | 152 #endif /* USE_POSIX else */ |
153 | |
734 | 154 #define TORTURE_PREFIX "torture-" |
697 | 155 |
704 | 156 #ifdef USE_POSIX |
968 | 157 #define CRASH_RUN "./crashRun 30 2000" |
734 | 158 #define TMP_DIR "./obj" |
704 | 159 #else |
633 | 160 #ifdef USE_WINDOWS |
734 | 161 #define TMP_DIR ".\\obj" |
633 | 162 #else |
704 | 163 #error OS dependent file names not defined |
633 | 164 #endif |
165 #endif | |
166 | |
888
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
167 #ifdef USE_WINDOWS |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
168 HANDLE originalStdout, originalStderr; |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
169 #endif |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
170 |
734 | 171 const char* torture[] = { |
172 "", | |
746 | 173 |
734 | 174 "-g", "-inline", "-fPIC", "-O", "-release", |
746 | 175 |
734 | 176 "-g -inline", "-g -fPIC", "-g -O", "-g -release", |
177 "-inline -fPIC", "-inline -O", "-inline -release", | |
178 "-fPIC -O", "-fPIC -release", | |
179 "-O -release", | |
746 | 180 |
734 | 181 "-g -inline -fPIC", "-g -inline -O", "-g -inline -release", |
182 "-g -fPIC -O", "-g -fPIC -release", "-g -O -release", | |
183 "-inline -fPIC -O", "-inline -fPIC -release", "-inline -O -release", | |
184 "-fPIC -O -release", | |
185 | |
186 "-g -inline -fPIC -O", "-g -inline -fPIC -release", | |
187 "-g -fPIC -O -release", | |
188 "-inline -fPIC -O -release", | |
189 | |
190 "-g -inline -fPIC -O -release" | |
191 }; | |
192 | |
193 /* secure malloc */ | |
194 void *xmalloc(size_t size){ | |
195 void *p = malloc(size); | |
196 if (p == NULL){ | |
197 fprintf(stderr, "Failed to allocate " ZU " bytes!\n", size); | |
198 exit(EXIT_FAILURE); | |
199 } | |
200 return p; | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
201 } |
734 | 202 #define malloc xmalloc |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
203 |
734 | 204 /* secure calloc */ |
205 void* xcalloc(size_t members, size_t size){ | |
206 void* ptr = calloc(members, size); | |
207 if(ptr == NULL){ | |
208 fprintf(stderr, "Failed to allocate " ZU " elements" | |
209 "(" ZU " bytes each)!\n", members, size); | |
210 exit(EXIT_FAILURE); | |
211 } | |
212 return ptr; | |
213 } | |
214 #define calloc xcalloc | |
215 | |
216 | |
217 void printResult(int result, int modus, char* case_file, FILE* stream){ | |
218 char* msg = NULL; | |
219 #ifdef DEBUG | |
220 fprintf(stderr, "case: %s, modus: %x, result: %x\n", case_file, modus, | |
221 result); | |
222 #endif | |
223 | |
224 if(result & RES_PASS){ | |
225 msg = "PASS: "; | |
226 }else if(result & RES_XFAIL){ | |
227 msg = "XFAIL:"; | |
228 }else if(result & RES_XPASS){ | |
229 msg = "XPASS:"; | |
230 }else if(result & RES_FAIL){ | |
231 msg = "FAIL: "; | |
232 }else if(result & RES_ERROR){ | |
233 msg = "ERROR:"; | |
234 } | |
235 | |
236 fprintf(stream, "%s\t%s%s%s\n", msg, case_file, | |
237 (result & RES_BAD_MSG) ? " [bad error message]" : "", | |
238 (result & RES_BAD_GDB) ? " [bad debugger message]" : ""); | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
239 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
240 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
241 char* strip(char* buffer){ |
697 | 242 char* tmp = NULL; |
685 | 243 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
244 if(buffer!=NULL){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
245 while(isspace(buffer[0])){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
246 buffer++; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
247 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
248 |
622 | 249 for(tmp=buffer+strlen(buffer)-1; isspace(tmp[0]); tmp=buffer+strlen(buffer)-1){ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
250 tmp[0]='\x00'; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
251 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
252 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
253 return buffer; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
254 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
255 |
734 | 256 unsigned int genTempFileNameCount; |
257 char* genTempFileName(){ | |
258 char* back; | |
259 size_t len; | |
260 | |
261 len = strlen(TMP_DIR) + 128; | |
262 back = malloc(len); | |
746 | 263 |
264 #ifdef USE_POSIX | |
734 | 265 snprintf(back, len, "%s/t%x-%x-%x.tmp", TMP_DIR, getpid(), rand(), ++genTempFileNameCount); |
746 | 266 #else |
267 snprintf(back, len, "%s\\t%x-%x-%x.tmp", TMP_DIR, getpid(), rand(), ++genTempFileNameCount); | |
268 #endif | |
734 | 269 |
270 return back; | |
271 } | |
272 | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
273 /* cleanup "/" versus "\" in filenames */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
274 char* cleanPathSeperator(char* filename){ |
697 | 275 char* pos = NULL; |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
276 #ifdef USE_POSIX |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
277 for(pos=strchr(filename, '\\'); pos; pos=strchr(filename, '\\')){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
278 *pos='/'; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
279 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
280 #else |
633 | 281 #if USE_WINDOWS |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
282 for(pos=strchr(filename, '/'); pos; pos=strchr(filename, '/')){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
283 *pos='\\'; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
284 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
285 #else |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
286 |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
287 #error no cleanPathSeperator implementation available for this system |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
288 |
633 | 289 #endif /* USE_WINDOWS else */ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
290 #endif /* USE_POSIX else */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
291 return filename; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
292 } |
490 | 293 |
902 | 294 char* loadFile(char* filename, size_t* len){ |
490 | 295 #ifdef USE_POSIX |
697 | 296 char* back; |
251 | 297 struct stat fileInfo; |
298 int file = open(filename, O_RDONLY); | |
697 | 299 |
300 back = NULL; | |
301 | |
251 | 302 if(errno == 0 && file != 0 && file != -1){ |
303 if(0==fstat(file, &fileInfo)){ | |
304 back=malloc(fileInfo.st_size+1); | |
305 fileInfo.st_size = read(file, back, fileInfo.st_size); | |
440 | 306 if(fileInfo.st_size>=0){ |
697 | 307 *(back+fileInfo.st_size) = '\x00'; |
902 | 308 *len = fileInfo.st_size; |
251 | 309 }else{ |
436 | 310 back = NULL; |
902 | 311 *len = 0; |
251 | 312 } |
313 } | |
314 close(file); | |
315 } | |
436 | 316 |
317 if(back){ | |
318 return back; | |
319 } | |
320 | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
321 fprintf(stderr, "File not found \"%s\" (%s)\n", filename, strerror(errno)); |
436 | 322 exit(EXIT_FAILURE); |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
323 #else /* USE_POSIX */ |
633 | 324 #ifdef USE_WINDOWS |
734 | 325 /* @todo@ check for 32bit/64bit */ |
697 | 326 char* back; |
254 | 327 DWORD size, numread; |
328 HANDLE file=CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, | |
329 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); | |
697 | 330 |
331 back = NULL; | |
332 size = 0; | |
333 numread = 0; | |
254 | 334 if (file != INVALID_HANDLE_VALUE){ |
335 size = GetFileSize(file, NULL); | |
336 if (size != INVALID_FILE_SIZE){ | |
337 back=malloc((size+1)*sizeof(char)); | |
292 | 338 if (ReadFile(file,back,size,&numread,NULL) == 1){ |
339 if (numread==size){ | |
697 | 340 *(back+size) = '\x00'; |
904 | 341 *len = size; |
292 | 342 }else{ |
438 | 343 back = NULL; |
904 | 344 *len = 0; |
292 | 345 } |
346 }else{ | |
438 | 347 back = NULL; |
904 | 348 *len = 0; |
292 | 349 } |
254 | 350 } |
351 CloseHandle(file); | |
352 } | |
438 | 353 if(back){ |
354 errno = 0; | |
355 return back; | |
356 } | |
357 | |
358 fprintf(stderr, "File not found \"%s\"\n", filename); | |
359 exit(EXIT_FAILURE); | |
633 | 360 #else /* USE_WINDOWS */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
361 |
707 | 362 #error no loadFile implementation present |
361 | 363 |
633 | 364 #endif /* USE_WINDOWS */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
365 #endif /* USE_POSIX else */ |
490 | 366 } |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
367 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
368 void writeFile(const char* filename, const char* content){ |
697 | 369 size_t len; |
370 FILE* file; | |
371 | |
372 len = strlen(content); | |
373 errno = 0; | |
374 file = fopen(filename, "w+"); | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
375 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
376 if(errno == 0 && file != NULL){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
377 if((fwrite(content, sizeof(char), len, file) != len) || (errno != 0)){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
378 fprintf(stderr, "failed to write file \"%s\" (%s)\n", filename, strerror(errno)); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
379 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
380 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
381 if(fclose(file) || (errno != 0)){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
382 fprintf(stderr, "failed to close file \"%s\" (%s)\n", filename, strerror(errno)); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
383 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
384 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
385 return; |
438 | 386 } |
499 | 387 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
388 fprintf(stderr, "couldn't open file \"%s\" for writing (%s)\n", filename, strerror(errno)); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
389 exit(EXIT_FAILURE); |
438 | 390 } |
391 | |
499 | 392 /* query the environment for the compiler name */ |
697 | 393 char* getCompiler(void){ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
394 char* back = getenv("DMD"); |
704 | 395 |
396 if(back==NULL){ | |
397 back = "dmd"; | |
398 } | |
399 | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
400 return strip(cleanPathSeperator(back)); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
401 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
402 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
403 /* query the environment for the debugger name */ |
697 | 404 char* getGDB(void){ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
405 char* back = getenv("GDB"); |
704 | 406 |
407 if(back==NULL){ | |
408 back = "gdb"; | |
409 } | |
410 | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
411 return strip(cleanPathSeperator(back)); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
412 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
413 |
734 | 414 char* getTortureBlock(void){ |
415 char* back = getenv("DSTRESS_TORTURE_BLOCK"); | |
416 | |
417 if(back!=NULL){ | |
418 back = strip(back); | |
419 if(strlen(back)<1){ | |
420 back = NULL; | |
421 } | |
422 } | |
423 | |
424 return back; | |
425 } | |
426 | |
499 | 427 /* extract the FIRST occurance of a given TAG until the next linebreak */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
428 char* getCaseFlag(const char* data, const char* tag){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
429 char* begin; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
430 char* end1; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
431 char* end2; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
432 char* back; |
438 | 433 |
697 | 434 begin = NULL; |
435 end1 = NULL; | |
436 end2 = NULL; | |
437 back = NULL; | |
438 | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
439 if(data!=NULL && tag!=NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
440 begin = strstr(data, tag); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
441 if(begin!=NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
442 begin = begin+strlen(tag); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
443 end1 = strstr(begin, "\n"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
444 end2 = strstr(begin, "\r"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
445 if(end2!=NULL && ((end1!=NULL && end2<end1) || end1==NULL)){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
446 end1=end2; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
447 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
448 if(end1==NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
449 end1 = begin + strlen(begin); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
450 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
451 back = malloc(end1-begin+1); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
452 strncpy(back, begin, end1-begin); |
697 | 453 back[end1-begin]='\x00'; |
968 | 454 return strip(back); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
455 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
456 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
457 |
429 | 458 return calloc(1,1); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
459 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
460 |
499 | 461 /* check compile-time error messages */ |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
462 int checkErrorMessage(const char* file, const char* line, const char* buffer){ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
463 |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
464 char* dmd; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
465 char* gdc; |
697 | 466 size_t len; |
467 int back; | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
468 |
697 | 469 dmd = NULL; |
470 gdc = NULL; | |
471 len = 0; | |
472 back = 0; | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
473 |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
474 /* clean arguments */ |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
475 if(file && !file[0]){ |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
476 file = NULL; |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
477 } |
438 | 478 |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
479 if(line && !line[0]){ |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
480 line = NULL; |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
481 } |
438 | 482 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
483 /* gen patterns*/ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
484 if(file!=NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
485 if(line!=NULL){ |
770 | 486 len = strlen(file)+strlen(line)+3; |
685 | 487 dmd = malloc(len); |
488 snprintf(dmd, len, "%s(%s)", file, line); | |
489 | |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
490 gdc = malloc(--len); |
770 | 491 snprintf(gdc, len, "%s:%s", file, line); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
492 }else{ |
685 | 493 len = strlen(file)+2; |
494 dmd = malloc(len); | |
495 snprintf(dmd, len, "%s(", file); | |
622 | 496 |
685 | 497 gdc = malloc(len); |
498 snprintf(gdc, len, "%s:", file); | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
499 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
500 }else if(line!=NULL){ |
770 | 501 len = strlen(line)+3; |
685 | 502 dmd = malloc(len); |
770 | 503 snprintf(dmd, len, "(%s)", line); |
622 | 504 |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
505 gdc = malloc(--len); |
770 | 506 snprintf(gdc, len, ":%s", line); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
507 }else{ |
432 | 508 return 1; |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
509 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
510 |
438 | 511 /* specific error messages */ |
676 | 512 #ifdef DEBUG |
513 fprintf(stderr, "pattern(dmd):\t%s\n", dmd); | |
514 fprintf(stderr, "pattern(gdc):\t%s\n", gdc); | |
515 #endif | |
251 | 516 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
517 if( (dmd!=NULL && strstr(buffer, dmd)) |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
518 || (gdc!=NULL && strstr(buffer, gdc)) |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
519 || (dmd==NULL && gdc==NULL)){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
520 back=1; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
521 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
522 |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
523 free(dmd); |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
524 free(gdc); |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
525 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
526 return back; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
527 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
528 |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
529 int checkRuntimeErrorMessage(const char* file, const char* line, const char* buffer){ |
438 | 530 /* PhobosLong dir/file.d(2) |
490 | 531 * Phobos package.module(2) |
438 | 532 */ |
432 | 533 |
534 char* phobos; | |
535 char* phobosLong; | |
536 | |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
537 const char* begin; |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
538 const char* end; |
685 | 539 size_t len; |
432 | 540 |
541 int back=0; | |
542 | |
697 | 543 phobos = NULL; |
544 phobosLong = NULL; | |
545 | |
546 begin = NULL; | |
547 end = NULL; | |
548 len = 0; | |
549 | |
432 | 550 /* clean arguments */ |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
551 if(file && !file[0]){ |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
552 file = NULL; |
432 | 553 } |
438 | 554 |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
555 if(line && !line[0]){ |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
556 line = NULL; |
432 | 557 } |
438 | 558 |
432 | 559 /* gen patterns*/ |
560 if(file!=NULL){ | |
561 if(line!=NULL){ | |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
562 len = strlen(file)+strlen(line)+3; |
685 | 563 phobos = malloc(len); |
438 | 564 begin=strrchr(file,'/'); |
565 if(begin){ | |
432 | 566 begin++; |
567 }else{ | |
438 | 568 begin=strrchr(file,'\\'); |
569 if(begin){ | |
570 begin++; | |
571 }else{ | |
572 begin=file; | |
573 } | |
432 | 574 } |
439 | 575 end=strrchr(file,'.'); |
576 strncat(phobos, begin, end-begin); | |
685 | 577 snprintf(phobos, len, "%.*s(%s)", |
578 (int)(end-begin), begin, | |
579 line); | |
432 | 580 |
685 | 581 phobosLong = malloc(len); |
582 snprintf(phobosLong, len, "%s(%s)", file, line); | |
432 | 583 }else{ |
685 | 584 len = strlen(file)+2; |
585 phobos = malloc(len); | |
438 | 586 begin=strrchr(file,'/'); |
587 if(begin){ | |
432 | 588 begin++; |
589 }else{ | |
438 | 590 begin=strrchr(file,'\\'); |
591 if(begin){ | |
592 begin++; | |
593 }else{ | |
594 begin=file; | |
595 } | |
432 | 596 } |
439 | 597 end=strrchr(file,'.'); |
685 | 598 snprintf(phobos, len, "%.*s(", (int)(end-begin), begin); |
432 | 599 |
685 | 600 phobosLong = malloc(len); |
601 snprintf(phobosLong, len, "%s(", file); | |
432 | 602 } |
603 }else if(line!=NULL){ | |
685 | 604 len = strlen(line)+3; |
605 phobos = malloc(len); | |
606 snprintf(phobos, len, "(%s)", line); | |
438 | 607 |
432 | 608 phobosLong=NULL; |
609 }else{ | |
610 return 1; | |
611 } | |
612 | |
438 | 613 /* specific error messages */ |
432 | 614 |
676 | 615 #ifdef DEBUG |
616 fprintf(stderr, "pattern(phobosShort):\t%s\n", phobos); | |
617 fprintf(stderr, "pattern(phobosLong):\t%s\n", phobosLong); | |
618 #endif | |
619 | |
432 | 620 if( (phobos && strstr(buffer, phobos)) |
621 || (phobosLong && strstr(buffer, phobosLong))) | |
622 { | |
623 back=1; | |
624 } | |
438 | 625 |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
626 free(phobos); |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
627 if(phobosLong){ |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
628 free(phobosLong); |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
629 } |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
630 |
438 | 631 return back; |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
632 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
633 |
490 | 634 int hadExecCrash(const char* buffer){ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
635 if(strstr(buffer, "Segmentation fault") |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
636 || strstr(buffer, "Internal error") |
499 | 637 || strstr(buffer, "gcc.gnu.org/bugs") |
774 | 638 || strstr(buffer, "EXIT CODE: signal") |
639 || strstr(buffer, "Assertion failure") | |
968 | 640 || strstr(buffer, "Access Violation") |
641 || strstr(buffer, "Invalid read of size") | |
642 || strstr(buffer, "Conditional jump or move depends on uninitialised value") | |
643 || strstr(buffer, "Use of uninitialised value of size")) | |
490 | 644 { |
645 return 1; | |
646 } | |
647 return 0; | |
648 } | |
649 | |
499 | 650 /* system call with time-out */ |
734 | 651 int crashRun(const char* cmd, char** logFile){ |
746 | 652 |
697 | 653 size_t len; |
654 char* buffer; | |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
655 int back; |
697 | 656 |
734 | 657 *logFile = genTempFileName(); |
746 | 658 #ifdef USE_POSIX |
734 | 659 len = 20 + strlen(CRASH_RUN) + strlen(cmd) + strlen(*logFile); |
697 | 660 buffer = malloc(len); |
661 | |
940 | 662 snprintf(buffer, len, "%s %s > %s 2>&1", CRASH_RUN, cmd, *logFile); |
697 | 663 |
490 | 664 system(buffer); |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
665 free(buffer); |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
666 |
902 | 667 buffer=loadFile(*logFile, &len); |
490 | 668 |
902 | 669 /* @todo@ use: len */ |
490 | 670 if(strstr(buffer, "EXIT CODE: 0")){ |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
671 back = EXIT_SUCCESS; |
490 | 672 }else if(strstr(buffer, "EXIT CODE: 256") |
673 || strstr(buffer, "EXIT CODE: timeout")) | |
674 { | |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
675 back = EXIT_FAILURE; |
490 | 676 }else{ |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
677 back = RAND_MAX; |
490 | 678 } |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
679 free(buffer); |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
680 |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
681 return back; |
888
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
682 #elif defined USE_WINDOWS |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
683 PROCESS_INFORMATION processInfo; |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
684 STARTUPINFO startupInfo; |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
685 SECURITY_ATTRIBUTES sa = { |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
686 sizeof(SECURITY_ATTRIBUTES), NULL, TRUE |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
687 }; |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
688 HANDLE tLogFile; |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
689 unsigned long exitCode; |
902 | 690 int timeLeft = 600; /* time limit in iterations of WFX loop */ |
888
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
691 |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
692 memset(&processInfo, 0, sizeof(PROCESS_INFORMATION)); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
693 memset(&startupInfo, 0, sizeof(STARTUPINFO)); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
694 startupInfo.cb = sizeof(STARTUPINFO); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
695 |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
696 tLogFile = CreateFile(*logFile, GENERIC_WRITE, |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
697 0, &sa, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
698 |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
699 if (tLogFile == NULL) { |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
700 printf("ERROR: could not open log file"); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
701 return RAND_MAX; |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
702 } |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
703 |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
704 SetStdHandle(STD_OUTPUT_HANDLE, tLogFile); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
705 SetStdHandle(STD_ERROR_HANDLE, originalStdout); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
706 |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
707 if (!CreateProcess(NULL, (char*) cmd, NULL, NULL, TRUE, 0, NULL, NULL, |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
708 &startupInfo, &processInfo)) { |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
709 void *message; |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
710 |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
711 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
712 | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
713 (char*) &message, 0, NULL); |
490 | 714 |
888
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
715 SetStdHandle(STD_OUTPUT_HANDLE, originalStdout); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
716 SetStdHandle(STD_ERROR_HANDLE, originalStderr); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
717 CloseHandle(tLogFile); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
718 |
902 | 719 /* this should never happen */ |
888
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
720 fprintf(stderr, "ERROR running %s:\n", cmd); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
721 fprintf(stderr, "%s\n", message); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
722 LocalFree((HLOCAL) message); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
723 return RAND_MAX; |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
724 } |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
725 |
902 | 726 /* wait for exit */ |
888
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
727 while (TRUE) { |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
728 GetExitCodeProcess(processInfo.hProcess, &exitCode); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
729 if (exitCode == 0x103) { |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
730 if (--timeLeft == 0) { |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
731 TerminateProcess(processInfo.hProcess, EXIT_FAILURE); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
732 SetStdHandle(STD_OUTPUT_HANDLE, originalStdout); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
733 SetStdHandle(STD_ERROR_HANDLE, originalStderr); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
734 CloseHandle(tLogFile); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
735 printf("EXIT CODE: timeout\n"); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
736 Sleep(100); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
737 return RAND_MAX; |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
738 } |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
739 Sleep(100); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
740 } else { |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
741 SetStdHandle(STD_OUTPUT_HANDLE, originalStdout); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
742 SetStdHandle(STD_ERROR_HANDLE, originalStderr); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
743 |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
744 CloseHandle(tLogFile); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
745 |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
746 printf("EXIT CODE: %i\n", exitCode); |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
747 return exitCode; |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
748 } |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
749 } |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
750 |
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
751 #else /* USE_WINDOWS */ |
704 | 752 #error comment me out, if your test cases produce neither eternal loops nor Access Violations |
746 | 753 |
754 len = 10 + strlen(cmd) + strlen(*logFile); | |
755 buffer = malloc(len); | |
756 | |
757 snprintf(buffer, len, "%s > %s 2>&1", cmd, *logFile); | |
758 | |
759 int i = system(buffer); | |
902 | 760 printf("EXIT CODE: %i\n", i); |
746 | 761 |
697 | 762 return i; |
490 | 763 #endif /* USE_POSIX else */ |
764 } | |
765 | |
734 | 766 int target_compile(int modus, char* compiler, char* arguments, char* case_file, |
767 char* error_file, char* error_line) | |
768 { | |
769 size_t bufferLen; | |
770 char* buffer; | |
771 int res; | |
772 int testResult; | |
773 int good_error; | |
774 char* logFile; | |
775 | |
776 bufferLen = 0; | |
777 buffer = NULL; | |
778 res = -1; | |
779 testResult = -1; | |
780 good_error = 0; | |
781 logFile = NULL; | |
782 | |
783 if(!(modus & MODE_COMPILE) && !(modus & MODE_NOCOMPILE)){ | |
784 fprintf(stderr, "BUG: badly handled mode %i (->compile)\n", | |
785 modus); | |
786 exit(EXIT_FAILURE); | |
787 } | |
788 | |
789 /* gen command */ | |
790 bufferLen = strlen(compiler) + strlen(arguments) + strlen(TMP_DIR) | |
791 + strlen(case_file) + 21; | |
792 buffer = malloc(bufferLen); | |
793 snprintf(buffer, bufferLen, "%s %s ", compiler, arguments); | |
794 | |
795 if(NULL == strstr(buffer, "-od")){ | |
796 snprintf(buffer, bufferLen, "%s %s -od%s -c %s", | |
797 compiler, arguments, TMP_DIR, case_file); | |
798 }else{ | |
799 snprintf(buffer, bufferLen, "%s %s -c %s", | |
800 compiler, arguments, case_file); | |
801 } | |
802 | |
803 /* test */ | |
804 if(modus & MODE_COMPILE){ | |
902 | 805 printf("compile: %s\n", buffer); |
734 | 806 }else{ |
902 | 807 printf("nocompile: %s\n", buffer); |
734 | 808 } |
809 res = crashRun(buffer, &logFile); | |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
810 free(buffer); |
734 | 811 |
812 /* diagnostic */ | |
902 | 813 buffer = loadFile(logFile, &bufferLen); |
814 printf("%.*s\n", (int)bufferLen, buffer); | |
734 | 815 remove(logFile); |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
816 free(logFile); |
734 | 817 good_error = checkErrorMessage(error_file, error_line, buffer); |
818 | |
819 if(hadExecCrash(buffer)){ | |
820 testResult = RES_ERROR; | |
821 }else if(modus & MODE_COMPILE){ | |
822 if(res == EXIT_SUCCESS){ | |
823 testResult = RES_PASS; | |
824 }else if(res == EXIT_FAILURE){ | |
825 testResult = RES_FAIL | (good_error ? 0 : RES_BAD_MSG); | |
826 }else{ | |
827 testResult = RES_ERROR | (good_error ? 0 : RES_BAD_MSG); | |
828 } | |
829 }else{ | |
830 if(res == EXIT_FAILURE){ | |
831 if(good_error){ | |
832 testResult = RES_XFAIL; | |
833 }else{ | |
834 testResult = RES_FAIL | RES_BAD_MSG; | |
835 } | |
836 }else if(res == EXIT_SUCCESS){ | |
837 testResult = RES_XPASS; | |
838 }else{ | |
839 testResult = RES_ERROR; | |
840 } | |
841 } | |
842 | |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
843 free(buffer); |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
844 |
734 | 845 return testResult; |
846 } | |
847 | |
848 int target_run(int modus, char* compiler, char* arguments, char* case_file, | |
849 char* error_file, char* error_line | |
850 #ifdef REG_EXTENDED | |
851 , char* gdb, char* gdb_script, regex_t* gdb_pattern | |
852 #endif | |
853 ) | |
854 { | |
855 size_t bufferLen; | |
856 char* buffer; | |
857 int res; | |
858 int testResult; | |
859 int good_error; | |
860 char* logFile; | |
861 char* gdb_scripter; | |
862 int good_gdb; | |
863 | |
864 bufferLen = 0; | |
865 buffer = NULL; | |
866 res = -1; | |
867 testResult = -1; | |
868 good_error = 0; | |
869 logFile = NULL; | |
870 good_gdb = 0; | |
871 gdb_scripter = NULL; | |
872 | |
873 if(!(modus & MODE_RUN) && !(modus & MODE_NORUN)){ | |
874 fprintf(stderr, "BUG: badly handled mode %i (->run)\n", modus); | |
875 exit(EXIT_FAILURE); | |
876 } | |
746 | 877 |
734 | 878 /* gen command */ |
879 | |
880 bufferLen = strlen(compiler) + strlen(arguments) + strlen(TMP_DIR) | |
881 + strlen(case_file) * 2 + 64; | |
882 buffer = malloc(bufferLen); | |
883 snprintf(buffer, bufferLen, "%s %s ", compiler, arguments); | |
884 | |
885 if(NULL == strstr(buffer, "-od")){ | |
886 if(NULL == strstr(buffer, "-of")){ | |
887 snprintf(buffer, bufferLen, | |
888 "%s %s -od%s -of%s.exe %s", | |
889 compiler, arguments, TMP_DIR, case_file, | |
890 case_file); | |
891 }else{ | |
892 snprintf(buffer, bufferLen, | |
893 "%s %s -od%s %s", | |
894 compiler, arguments, TMP_DIR, case_file); | |
895 } | |
896 }else if(NULL == strstr(buffer, "-of")){ | |
897 snprintf(buffer, bufferLen, | |
898 "%s %s -of%s.exe %s", | |
899 compiler, arguments, case_file, case_file); | |
900 }else{ | |
901 snprintf(buffer, bufferLen, "%s %s %s", | |
902 compiler, arguments, case_file); | |
903 } | |
904 | |
905 /* test 1/3 - compile */ | |
906 if(modus & MODE_RUN){ | |
902 | 907 printf("run: %s\n", buffer); |
734 | 908 }else{ |
902 | 909 printf("norun: %s\n", buffer); |
734 | 910 } |
911 res = crashRun(buffer, &logFile); | |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
912 free(buffer); |
734 | 913 |
914 /* diagnostic 1/3 */ | |
902 | 915 buffer = loadFile(logFile, &bufferLen); |
916 printf("%.*s", (int)bufferLen, buffer); | |
734 | 917 remove(logFile); |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
918 free(logFile); |
746 | 919 |
734 | 920 if(modus & MODE_RUN){ |
921 good_error = checkErrorMessage(error_file, error_line, | |
922 buffer); | |
923 }else{ | |
924 good_error = 1; | |
925 } | |
926 | |
927 if(hadExecCrash(buffer)){ | |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
928 free(buffer); |
734 | 929 return RES_ERROR; |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
930 }else{ |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
931 free(buffer); |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
932 if((res == EXIT_FAILURE) && good_error){ |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
933 return RES_FAIL; |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
934 }else if(res!=EXIT_SUCCESS){ |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
935 return RES_ERROR | (good_error ? 0 : RES_BAD_MSG); |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
936 } |
734 | 937 } |
938 | |
939 /* test 2/3 - run */ | |
940 bufferLen = strlen(case_file) + 30; | |
941 buffer = malloc(bufferLen); | |
942 snprintf(buffer, bufferLen, "%s.exe", case_file); | |
902 | 943 printf("%s\n", buffer); |
734 | 944 res=crashRun(buffer, &logFile); |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
945 free(buffer); |
734 | 946 |
947 /* diagnostic 2/3 */ | |
902 | 948 buffer = loadFile(logFile, &bufferLen); |
949 printf("%.*s\n", (int) bufferLen, buffer); | |
734 | 950 remove(logFile); |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
951 free(logFile); |
734 | 952 |
953 if(modus & MODE_NORUN){ | |
954 good_error = checkRuntimeErrorMessage(error_file, error_line, | |
955 buffer); | |
956 }else{ | |
957 good_error = 1; | |
958 } | |
959 | |
960 #ifdef REG_EXTENDED | |
968 | 961 if(((res==EXIT_SUCCESS && (modus & MODE_RUN)) |
962 ||(res==EXIT_SUCCESS && (modus & MODE_RUN))) | |
963 && gdb_script != NULL) | |
964 { | |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
965 free(buffer); |
734 | 966 good_gdb = 0; |
967 /* test 3/3 - gdb */ | |
968 gdb_scripter = genTempFileName(); | |
969 writeFile(gdb_scripter, gdb_script); | |
970 bufferLen = strlen(gdb) + strlen(case_file) | |
971 + strlen(gdb_scripter) + 20; | |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
972 buffer = malloc(bufferLen); |
734 | 973 snprintf(buffer, bufferLen, "%s %s.exe < %s", |
974 gdb, case_file, gdb_scripter); | |
902 | 975 printf("%s\n", buffer); |
734 | 976 if(EXIT_SUCCESS==crashRun(buffer, &logFile)){ |
977 /* diagnostic 3/3 */ | |
902 | 978 buffer = loadFile(logFile, &bufferLen); |
979 printf("%.*s\n", (int)bufferLen, buffer); | |
734 | 980 good_gdb = (regexec(gdb_pattern, buffer, 0, NULL, 0)==0); |
981 } | |
982 remove(logFile); | |
983 remove(gdb_scripter); | |
984 }else{ | |
985 good_gdb = 1; | |
986 } | |
746 | 987 #else |
988 good_gdb = 1; | |
902 | 989 #endif /* REG_EXTENDED else */ |
734 | 990 |
991 if(modus & MODE_RUN){ | |
992 if(hadExecCrash(buffer)){ | |
746 | 993 testResult = RES_ERROR; |
734 | 994 }else if((res==EXIT_SUCCESS) && good_gdb){ |
995 testResult = RES_PASS; | |
996 }else if((res==EXIT_FAILURE) && good_error && good_gdb){ | |
997 testResult = RES_FAIL; | |
998 }else{ | |
999 testResult = RES_ERROR | (good_error ? 0 : RES_BAD_MSG) | |
1000 | (good_gdb ? 0 : RES_BAD_GDB); | |
1001 } | |
1002 }else{ | |
1003 if(res==EXIT_SUCCESS){ | |
1004 testResult = RES_XPASS; | |
1005 }else if(good_error && good_gdb){ | |
1006 testResult = RES_XFAIL; | |
1007 }else{ | |
1008 testResult = RES_FAIL | (good_error ? 0 : RES_BAD_MSG) | |
1009 | (good_gdb ? 0 : RES_BAD_GDB); | |
1010 } | |
1011 } | |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
1012 free(buffer); |
734 | 1013 |
1014 return testResult; | |
1015 } | |
254 | 1016 |
251 | 1017 int main(int argc, char* arg[]){ |
746 | 1018 |
438 | 1019 char* compiler; /* the compiler - from enviroment flag "DMD" */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
1020 char* cmd_arg_case; /* additional arguments - from the testcase file */ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1021 char* buffer; /* general purpose buffer */ |
685 | 1022 size_t bufferLen; |
734 | 1023 int index; |
438 | 1024 int modus; /* test modus: RUN NORUN COMPILE NOCOMPILE */ |
1025 char* case_file; | |
734 | 1026 int case_result; |
1027 int torture_result[sizeof(torture)/sizeof(char*)]; | |
1028 char* torture_block_global; | |
1029 char* torture_block_case; | |
1030 char* torture_require; | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
1031 char* error_file; /* expected sourcefile containing the error */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
1032 char* error_line; /* expected error line */ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1033 char* gdb; /* the debugger - from environment flag "GDB" */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1034 char* gdb_script; /* gdb command sequence */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1035 char* gdb_pattern_raw; /* POSIX regexp expected in GDB's output */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1036 #ifdef REG_EXTENDED |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1037 regex_t* gdb_pattern; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1038 #endif |
438 | 1039 |
697 | 1040 compiler = NULL; |
1041 cmd_arg_case = NULL; | |
1042 buffer = NULL; | |
1043 bufferLen = 0; | |
1044 modus = -1; | |
1045 case_file = NULL; | |
734 | 1046 torture_block_global = NULL; |
1047 torture_block_case = NULL; | |
1048 torture_require = NULL; | |
697 | 1049 error_file = NULL; |
1050 error_line = NULL; | |
1051 gdb = NULL; | |
1052 gdb_script = NULL; | |
1053 gdb_pattern_raw = NULL; | |
1054 #ifdef REG_EXTENDED | |
1055 gdb_pattern = NULL; | |
1056 #endif | |
1057 | |
251 | 1058 /* check arguments */ |
1059 if(argc != 3){ | |
438 | 1060 err: |
902 | 1061 fprintf(stderr, "DStress test executer (revision 1083)\n" |
1062 "Copyright by Thomas Kuehne <thomas@kuehne.cn> 2005, 2006\n" | |
704 | 1063 "\n"); |
1064 | |
734 | 1065 if(argc!=0){ |
704 | 1066 fprintf(stderr, |
1067 "%s <run|norun|compile|nocompile> <source>\n", | |
1068 arg[0]); | |
734 | 1069 }else{ |
704 | 1070 fprintf(stderr, |
1071 "dstress <run|norun|compile|nocompile>" | |
1072 " <source>\n"); | |
734 | 1073 } |
704 | 1074 |
734 | 1075 fprintf(stderr, "\n" |
704 | 1076 "== eniroment settings (usually $NAME or %%NAME%%) ==\n" |
1077 "* DMD - compiler (including standard arguments)\n" | |
734 | 1078 "* GDB - debugger (including standard arguments)\n"); |
1079 fprintf(stderr, "\n" | |
704 | 1080 "== case setting (line in the case source) ==\n" |
1081 "* __DSTRESS_DFLAGS__ - additional compiler arguments\n" | |
1082 "only evaluated if it is a \"nocompile\" or \"norun\" test:\n" | |
1083 "* __DSTRESS_ELINE__ - expected source line to throw an error message\n" | |
1084 "* __DSTRESS_EFILE__ - expected source file to throw an error message\n" | |
734 | 1085 " (defaults to the case file)\n"); |
1086 fprintf(stderr, | |
704 | 1087 "only evaluated if it is a \"run\" or \"norun\" test:\n" |
1088 "* __GDB_SCRIPT__ - command sequence to feed to the debugger\n" | |
1089 " (use \\n to encode a line break)\n" | |
1090 "* __GDB_PATTERN__ - expected regular expression in the debugger's\n" | |
734 | 1091 " output\n"); |
1092 fprintf(stderr, "\n" | |
704 | 1093 "== note ==\n" |
710 | 1094 "* the current directory is required to contain the sub-directory \"obj\"\n" |
704 | 1095 " (used for temporary files)\n" |
1096 ); | |
438 | 1097 exit(EXIT_FAILURE); |
251 | 1098 } |
438 | 1099 |
734 | 1100 modus = 0; |
1101 if(0==strncmp(arg[1], TORTURE_PREFIX, strlen(TORTURE_PREFIX))){ | |
1102 modus |= MODE_TORTURE; | |
1103 arg[1] += strlen(TORTURE_PREFIX); | |
1104 } | |
704 | 1105 if(0==strcmp(arg[1], "run")){ |
734 | 1106 modus |= MODE_RUN; |
704 | 1107 }else if(0==strcmp(arg[1], "norun")){ |
734 | 1108 modus |= MODE_NORUN; |
704 | 1109 }else if(0==strcmp(arg[1], "compile")){ |
734 | 1110 modus |= MODE_COMPILE; |
704 | 1111 }else if(0==strcmp(arg[1], "nocompile")){ |
734 | 1112 modus |= MODE_NOCOMPILE; |
251 | 1113 }else{ |
1114 goto err; | |
1115 } | |
1116 | |
1117 /* gen flags */ | |
902 | 1118 case_file = cleanPathSeperator(arg[2]); |
251 | 1119 compiler = getCompiler(); |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1120 gdb = getGDB(); |
734 | 1121 torture_block_global = getTortureBlock(); |
902 | 1122 buffer = loadFile(case_file, &bufferLen); |
1123 bufferLen = 0; | |
438 | 1124 |
968 | 1125 cmd_arg_case = cleanPathSeperator(getCaseFlag(buffer, "__DSTRESS_DFLAGS__")); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
1126 error_line = getCaseFlag(buffer, "__DSTRESS_ELINE__"); |
968 | 1127 error_file = cleanPathSeperator(getCaseFlag(buffer, "__DSTRESS_EFILE__")); |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1128 gdb_script = getCaseFlag(buffer, "__GDB_SCRIPT__"); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1129 gdb_pattern_raw = getCaseFlag(buffer, "__GDB_PATTERN__"); |
734 | 1130 torture_block_case = getCaseFlag(buffer, "__DSTRESS_TORTURE_BLOCK__"); |
1131 torture_require = getCaseFlag(buffer, "__DSTRESS_TORTURE_REQUIRE__"); | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1132 |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
1133 free(buffer); |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
1134 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1135 /* set implicit source file */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1136 if(strcmp(error_line, "")!=0 && strcmp(error_file, "")==0){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1137 error_file=case_file; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1138 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1139 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1140 /* gdb pattern */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1141 #ifdef REG_EXTENDED |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1142 if(gdb_pattern_raw!=NULL && gdb_pattern_raw[0]!='\x00'){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1143 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1144 gdb_pattern = malloc(sizeof(regex_t)); |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
1145 if(regcomp(gdb_pattern, gdb_pattern_raw, REG_EXTENDED | REG_NOSUB)){ |
704 | 1146 fprintf(stderr, "failed to compile regular expression:" |
1147 "\n\t%s\n", gdb_pattern_raw); | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1148 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1149 }else if(gdb_script==NULL){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1150 fprintf(stderr, "GDB pattern without GDB script\n"); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1151 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1152 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1153 }else{ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1154 gdb_pattern = NULL; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1155 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1156 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1157 /* gdb script */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1158 if(gdb_script!=NULL && gdb_script[0]!='\x00'){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1159 if(gdb_pattern==NULL){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1160 fprintf(stderr, "GDB script without GDB pattern\n"); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1161 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1162 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1163 buffer=gdb_script; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1164 for(; *buffer; buffer++){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1165 if(buffer[0]=='\\'){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1166 if(buffer[1]=='n'){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1167 buffer[0]=' '; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1168 buffer[1]='\n'; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1169 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1170 buffer++; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1171 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1172 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1173 |
685 | 1174 bufferLen = strlen(gdb_script)+11; |
1175 buffer=malloc(bufferLen); | |
1176 snprintf(buffer, bufferLen, "%s\n\nquit\ny\n\n", gdb_script); | |
1177 gdb_script=buffer; | |
922
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
1178 }else if(gdb_script){ |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
1179 free(gdb_script); |
95160f4d06f8
minimized memory leaks in repeatedly called functions
thomask
parents:
904
diff
changeset
|
1180 gdb_script = NULL; |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1181 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1182 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1183 #else |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1184 |
704 | 1185 if(gdb_script && strlen(gdb_script)){ |
1186 if(gdb_pattern_raw && strlen(gdb_pattern_raw)){ | |
734 | 1187 fprintf(stderr, "WARNING: GDB/regex support inactive\n"); |
704 | 1188 }else{ |
734 | 1189 fprintf(stderr, "GDB script without GDB pattern\n"); |
704 | 1190 exit(EXIT_FAILURE); |
1191 } | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1192 }else if(gdb_pattern_raw && strlen(gdb_pattern_raw)){ |
734 | 1193 fprintf(stderr, "GDB pattern without GDB script\n"); |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1194 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1195 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1196 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1197 #endif /* REG_EXTENDED else */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1198 |
493 | 1199 #ifdef DEBUG |
902 | 1200 fprintf(stderr, "case : \"%s\"\n", case_file); |
438 | 1201 fprintf(stderr, "compiler: \"%s\"\n", compiler); |
1202 fprintf(stderr, "DFLAGS C: \"%s\"\n", cmd_arg_case); | |
1203 fprintf(stderr, "ELINE : \"%s\"\n", error_line); | |
1204 fprintf(stderr, "EFILE : \"%s\"\n", error_file); | |
734 | 1205 #ifdef REG_EXTENDED |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1206 fprintf(stderr, "GDB Scri: \"%s\"\n", gdb_script); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
1207 fprintf(stderr, "GDB Patt: \"%s\"\n", gdb_pattern_raw); |
438 | 1208 #endif |
734 | 1209 fprintf(stderr, "block G : \"%s\"\n", torture_block_global); |
1210 fprintf(stderr, "block C : \"%s\"\n", torture_block_case); | |
1211 fprintf(stderr, "modus : %x\n", modus); | |
1212 #endif | |
685 | 1213 |
251 | 1214 |
734 | 1215 /* let's get serious */ |
888
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
1216 #ifdef USE_WINDOWS |
902 | 1217 originalStdout = GetStdHandle(STD_OUTPUT_HANDLE); |
1218 originalStderr = GetStdHandle(STD_ERROR_HANDLE); | |
888
a995eae8e75c
blind: partial merger of Stewart's crashRun for Windows
thomask
parents:
881
diff
changeset
|
1219 #endif |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
1220 |
734 | 1221 if(modus & MODE_TORTURE){ |
746 | 1222 if((modus & (MODE_COMPILE | MODE_NOCOMPILE)) |
734 | 1223 && (modus & (MODE_RUN | MODE_NORUN))) |
1224 { | |
1225 fprintf(stderr, "BUG: unhandled torture modus %x\n", modus); | |
902 | 1226 exit(EXIT_FAILURE); |
734 | 1227 }else if(!(modus & (MODE_COMPILE | MODE_NOCOMPILE | MODE_RUN | MODE_NORUN))){ |
1228 fprintf(stderr, "BUG: unhandled torture modus %x\n", modus); | |
902 | 1229 exit(EXIT_FAILURE); |
251 | 1230 } |
1231 | |
734 | 1232 bufferLen = strlen(torture[(sizeof(torture) / sizeof(char*))-1]) |
1233 + strlen(cmd_arg_case) + 3; | |
746 | 1234 |
734 | 1235 if(torture_block_case!=NULL && strlen(torture_block_case)<1){ |
1236 torture_block_case=NULL; | |
676 | 1237 } |
746 | 1238 |
734 | 1239 buffer = malloc(bufferLen); |
1240 for(index=0; index < sizeof(torture)/sizeof(char*); index++){ | |
1241 if((torture_block_global && strstr(torture[index], torture_block_global)) | |
1242 || (torture_block_case && strstr(torture[index], torture_block_case)) | |
959 | 1243 || (torture_require && !strstr(torture[index], torture_require))) |
734 | 1244 { |
1245 torture_result[index]=RES_UNTESTED; | |
1246 continue; | |
1247 } | |
746 | 1248 |
734 | 1249 buffer[0]=0; |
1250 snprintf(buffer, bufferLen, "%s %s", torture[index], cmd_arg_case); | |
746 | 1251 |
734 | 1252 if(modus & (MODE_COMPILE | MODE_NOCOMPILE)){ |
1253 torture_result[index] = target_compile(modus, | |
1254 compiler, buffer, case_file, | |
1255 error_file, error_line); | |
1256 }else if(modus & (MODE_RUN | MODE_NORUN)){ | |
1257 torture_result[index] = target_run(modus, | |
1258 compiler, buffer, case_file, | |
1259 error_file, error_line | |
1260 #ifdef REG_EXTENDED | |
1261 , gdb, gdb_script, gdb_pattern | |
1262 #endif | |
1263 ); | |
1264 } | |
438 | 1265 |
902 | 1266 printf("Torture-Sub-%i/" ZU "-", index+1, |
734 | 1267 sizeof(torture)/sizeof(char*)); |
1268 printResult(torture_result[index], modus, case_file, | |
902 | 1269 stdout); |
1270 printf("--------\n"); | |
685 | 1271 } |
251 | 1272 }else{ |
968 | 1273 if(torture_require){ |
1274 if(!cmd_arg_case){ | |
1275 torture_require = cmd_arg_case; | |
1276 }else{ | |
1277 size_t new_len = strlen(cmd_arg_case); | |
1278 new_len += strlen(torture_require); | |
1279 new_len++; | |
1280 cmd_arg_case = realloc(cmd_arg_case, new_len); | |
1281 strcat(cmd_arg_case, " "); | |
1282 strcat(cmd_arg_case, torture_require); | |
1283 } | |
1284 } | |
734 | 1285 if(modus & (MODE_RUN | MODE_NORUN)){ |
1286 case_result = target_run(modus, compiler, cmd_arg_case, | |
1287 case_file, error_file, error_line | |
1288 #ifdef REG_EXTENDED | |
1289 , gdb, gdb_script, gdb_pattern | |
1290 #endif | |
1291 ); | |
880 | 1292 }else if(modus & (MODE_COMPILE | MODE_NOCOMPILE)){ |
734 | 1293 case_result = target_compile(modus, compiler, |
1294 cmd_arg_case, case_file, error_file, | |
1295 error_line); | |
881 | 1296 }else{ |
1297 fprintf(stderr, "BUG: unhandled non-torture modus %x\n", modus); | |
902 | 1298 exit(EXIT_FAILURE); |
734 | 1299 } |
904 | 1300 |
902 | 1301 printf("Torture-Sub-1/" ZU "-", |
880 | 1302 sizeof(torture)/sizeof(char*)); |
1303 printResult(case_result, modus, case_file, stdout); | |
251 | 1304 } |
734 | 1305 |
902 | 1306 exit(EXIT_SUCCESS); |
251 | 1307 } |