Mercurial > projects > dstress
annotate dstress.c @ 704:3e690f0d2cbf
documentation maintenance for dstress.c
author | thomask |
---|---|
date | Sun, 16 Oct 2005 12:41:54 +0000 |
parents | 8dc894322ce8 |
children | 5ba45899cddd |
rev | line source |
---|---|
438 | 1 /* |
2 * core test tool for the DStress test suite | |
251 | 3 * http://dstress.kuehne.cn |
4 * | |
5 * Copyright (C) 2005 Thomas Kuehne <thomas@kuehne.cn> | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 * | |
21 * $HeadURL$ | |
22 * $Date$ | |
23 * $Author$ | |
24 * | |
438 | 25 */ |
251 | 26 |
704 | 27 /* Beware: the code doesn't care about freeing allocated memory etc. ... */ |
432 | 28 |
251 | 29 #include <stdlib.h> |
30 #include <stdio.h> | |
31 #include <string.h> | |
32 #include <errno.h> | |
681 | 33 #include <ctype.h> |
251 | 34 |
35 #define RUN 1 | |
36 #define NORUN 2 | |
37 #define COMPILE 4 | |
38 #define NOCOMPILE 8 | |
39 | |
490 | 40 /* secure malloc */ |
41 void *xmalloc(size_t size){ | |
697 | 42 void *p = malloc(size); |
490 | 43 if (p == NULL){ |
44 fprintf(stderr,"Failed to allocate %zd bytes!\n", size); | |
45 exit(EXIT_FAILURE); | |
46 } | |
47 return p; | |
48 } | |
49 #define malloc xmalloc | |
50 | |
499 | 51 #if defined(__GNU_LIBRARY__) || defined(__GLIBC__) |
697 | 52 #define USE_POSIX 1 |
251 | 53 #endif |
54 | |
685 | 55 #if defined(linux) || defined(__FreeBSD__) || defined(__OpenBSD__) |
697 | 56 #define USE_POSIX 1 |
251 | 57 #endif |
58 | |
273 | 59 #if defined(__APPLE__) && defined(__MACH__) |
697 | 60 #define USE_POSIX 1 |
273 | 61 #endif |
62 | |
633 | 63 #if defined(WIN) || defined(WIN32) |
64 #define USE_WINDOWS 1 | |
65 #endif | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
66 |
704 | 67 /* 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
|
68 #ifdef USE_POSIX |
254 | 69 |
251 | 70 #include <sys/types.h> |
71 #include <sys/stat.h> | |
72 #include <fcntl.h> | |
73 #include <unistd.h> | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
74 #include <regex.h> |
490 | 75 |
76 #else | |
633 | 77 #ifdef USE_WINDOWS |
490 | 78 |
79 #include <windows.h> | |
685 | 80 #define snprintf _snprintf |
697 | 81 #ifndef INVALID_FILE_SIZE |
704 | 82 #define INVALID_FILE_SIZE (-1) |
697 | 83 #endif |
490 | 84 |
633 | 85 #else |
704 | 86 #error neither POSIX nor MSWindows API detected |
633 | 87 #endif /* USE_WINDOWS else */ |
490 | 88 #endif /* USE_POSIX else */ |
89 | |
685 | 90 #define OBJ "obj " |
697 | 91 |
704 | 92 #ifdef USE_POSIX |
93 #define TLOG "./obj/log.tmp" | |
94 #define CRASH_RUN "./crashRun" | |
95 #define GDB_SCRIPTER "./obj/gdb.tmp" | |
96 #else | |
633 | 97 #ifdef USE_WINDOWS |
697 | 98 #define TLOG ".\\obj\\log.tmp" |
99 #define CRASH_RUN ".\\crashRun" | |
100 #define GDB_SCRIPTER ".\\obj\\gdb.tmp" | |
633 | 101 #else |
704 | 102 #error OS dependent file names not defined |
633 | 103 #endif |
104 #endif | |
105 | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
106 char* errorMsg(int good_error){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
107 return (good_error) ? ("") : " [bad error message]"; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
108 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
109 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
110 char* gdbMsg(int good_gdb){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
111 return (good_gdb) ? ("") : " [bad debugger message]"; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
112 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
113 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
114 char* strip(char* buffer){ |
697 | 115 char* tmp = NULL; |
685 | 116 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
117 if(buffer!=NULL){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
118 while(isspace(buffer[0])){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
119 buffer++; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
120 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
121 |
622 | 122 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
|
123 tmp[0]='\x00'; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
124 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
125 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
126 return buffer; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
127 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
128 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
129 /* cleanup "/" versus "\" in filenames */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
130 char* cleanPathSeperator(char* filename){ |
697 | 131 char* pos = NULL; |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
132 #ifdef USE_POSIX |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
133 for(pos=strchr(filename, '\\'); pos; pos=strchr(filename, '\\')){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
134 *pos='/'; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
135 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
136 #else |
633 | 137 #if USE_WINDOWS |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
138 for(pos=strchr(filename, '/'); pos; pos=strchr(filename, '/')){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
139 *pos='\\'; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
140 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
141 #else |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
142 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
143 #error no cleanPathSeperator available for this system |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
144 |
633 | 145 #endif /* USE_WINDOWS else */ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
146 #endif /* USE_POSIX else */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
147 return filename; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
148 } |
490 | 149 |
251 | 150 char* loadFile(char* filename){ |
490 | 151 #ifdef USE_POSIX |
697 | 152 char* back; |
251 | 153 struct stat fileInfo; |
154 int file = open(filename, O_RDONLY); | |
697 | 155 |
156 back = NULL; | |
157 | |
251 | 158 if(errno == 0 && file != 0 && file != -1){ |
159 if(0==fstat(file, &fileInfo)){ | |
160 back=malloc(fileInfo.st_size+1); | |
161 fileInfo.st_size = read(file, back, fileInfo.st_size); | |
440 | 162 if(fileInfo.st_size>=0){ |
697 | 163 *(back+fileInfo.st_size) = '\x00'; |
251 | 164 }else{ |
436 | 165 back = NULL; |
251 | 166 } |
167 } | |
168 close(file); | |
169 } | |
436 | 170 |
171 if(back){ | |
172 return back; | |
173 } | |
440 | 174 if(0==strcmp(filename, TLOG)){ |
175 return calloc(1,sizeof(char)); | |
176 } | |
436 | 177 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
178 fprintf(stderr, "File not found \"%s\" (%s)\n", filename, strerror(errno)); |
436 | 179 exit(EXIT_FAILURE); |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
180 #else /* USE_POSIX */ |
633 | 181 #ifdef USE_WINDOWS |
697 | 182 // @todo@ check for 32bit/64bit |
183 char* back; | |
254 | 184 DWORD size, numread; |
185 HANDLE file=CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, | |
186 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); | |
697 | 187 |
188 back = NULL; | |
189 size = 0; | |
190 numread = 0; | |
254 | 191 if (file != INVALID_HANDLE_VALUE){ |
192 size = GetFileSize(file, NULL); | |
193 if (size != INVALID_FILE_SIZE){ | |
194 back=malloc((size+1)*sizeof(char)); | |
292 | 195 if (ReadFile(file,back,size,&numread,NULL) == 1){ |
196 if (numread==size){ | |
697 | 197 *(back+size) = '\x00'; |
292 | 198 }else{ |
438 | 199 back = NULL; |
292 | 200 } |
201 }else{ | |
438 | 202 back = NULL; |
292 | 203 } |
254 | 204 } |
205 CloseHandle(file); | |
206 } | |
438 | 207 if(back){ |
208 errno = 0; | |
209 return back; | |
210 } | |
211 | |
212 fprintf(stderr, "File not found \"%s\"\n", filename); | |
213 exit(EXIT_FAILURE); | |
633 | 214 #else /* USE_WINDOWS */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
215 |
490 | 216 #error "no loadFile implementation present" |
361 | 217 |
633 | 218 #endif /* USE_WINDOWS */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
219 #endif /* USE_POSIX else */ |
490 | 220 } |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
221 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
222 void writeFile(const char* filename, const char* content){ |
697 | 223 size_t len; |
224 FILE* file; | |
225 | |
226 len = strlen(content); | |
227 errno = 0; | |
228 file = fopen(filename, "w+"); | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
229 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
230 if(errno == 0 && file != NULL){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
231 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
|
232 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
|
233 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
234 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
235 if(fclose(file) || (errno != 0)){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
236 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
|
237 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
238 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
239 return; |
438 | 240 } |
499 | 241 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
242 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
|
243 exit(EXIT_FAILURE); |
438 | 244 } |
245 | |
499 | 246 /* query the environment for the compiler name */ |
697 | 247 char* getCompiler(void){ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
248 char* back = getenv("DMD"); |
704 | 249 |
250 #ifdef USE_WINDOWS | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
251 if(back == NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
252 back = getenv("dmd"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
253 } |
704 | 254 #endif |
255 if(back==NULL){ | |
256 back = "dmd"; | |
257 } | |
258 | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
259 return strip(cleanPathSeperator(back)); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
260 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
261 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
262 /* query the environment for the debugger name */ |
697 | 263 char* getGDB(void){ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
264 char* back = getenv("GDB"); |
704 | 265 |
266 #ifdef USE_WINDOWS | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
267 if(back == NULL){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
268 back = getenv("gdb"); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
269 } |
704 | 270 #endif |
271 if(back==NULL){ | |
272 back = "gdb"; | |
273 } | |
274 | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
275 return strip(cleanPathSeperator(back)); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
276 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
277 |
499 | 278 /* 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
|
279 char* getCaseFlag(const char* data, const char* tag){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
280 char* begin; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
281 char* end1; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
282 char* end2; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
283 char* back; |
438 | 284 |
697 | 285 begin = NULL; |
286 end1 = NULL; | |
287 end2 = NULL; | |
288 back = NULL; | |
289 | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
290 if(data!=NULL && tag!=NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
291 begin = strstr(data, tag); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
292 if(begin!=NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
293 begin = begin+strlen(tag); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
294 end1 = strstr(begin, "\n"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
295 end2 = strstr(begin, "\r"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
296 if(end2!=NULL && ((end1!=NULL && end2<end1) || end1==NULL)){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
297 end1=end2; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
298 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
299 if(end1==NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
300 end1 = begin + strlen(begin); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
301 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
302 back = malloc(end1-begin+1); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
303 strncpy(back, begin, end1-begin); |
697 | 304 back[end1-begin]='\x00'; |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
305 return strip(cleanPathSeperator(back)); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
306 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
307 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
308 |
429 | 309 return calloc(1,1); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
310 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
311 |
499 | 312 /* check compile-time error messages */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
313 int checkErrorMessage(const char* file_, const char* line_, const char* buffer){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
314 |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
315 char* file; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
316 char* line; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
317 char* dmd; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
318 char* gdc; |
697 | 319 size_t len; |
320 int back; | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
321 |
697 | 322 file = NULL; |
323 line = NULL; | |
324 dmd = NULL; | |
325 gdc = NULL; | |
326 len = 0; | |
327 back = 0; | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
328 |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
329 /* clean arguments */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
330 if(strcmp(file_, "")!=0){ |
685 | 331 len = strlen(file_)+1; |
332 file = malloc(len); | |
333 strncpy(file, file_, len); | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
334 } |
438 | 335 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
336 if(strcmp(line_, "")!=0){ |
685 | 337 len = strlen(line_)+1; |
338 line = malloc(len); | |
339 strncpy(line, line_, len); | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
340 } |
438 | 341 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
342 /* gen patterns*/ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
343 if(file!=NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
344 if(line!=NULL){ |
685 | 345 len = strlen(file)+strlen(line)+5; |
346 dmd = malloc(len); | |
347 snprintf(dmd, len, "%s(%s)", file, line); | |
348 | |
349 gdc = malloc(len); | |
350 snprintf(gdc, len, "%s:%s: ", file, line); | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
351 }else{ |
685 | 352 len = strlen(file)+2; |
353 dmd = malloc(len); | |
354 snprintf(dmd, len, "%s(", file); | |
622 | 355 |
685 | 356 gdc = malloc(len); |
357 snprintf(gdc, len, "%s:", file); | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
358 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
359 }else if(line!=NULL){ |
685 | 360 len = strlen(line)+5; |
361 dmd = malloc(len); | |
362 snprintf(dmd, len, "(%s): ", line); | |
622 | 363 |
685 | 364 gdc = malloc(len); |
365 snprintf(gdc, len, ":%s: ", line); | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
366 }else{ |
432 | 367 return 1; |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
368 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
369 |
438 | 370 /* specific error messages */ |
676 | 371 #ifdef DEBUG |
372 fprintf(stderr, "pattern(dmd):\t%s\n", dmd); | |
373 fprintf(stderr, "pattern(gdc):\t%s\n", gdc); | |
374 #endif | |
251 | 375 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
376 if( (dmd!=NULL && strstr(buffer, dmd)) |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
377 || (gdc!=NULL && strstr(buffer, gdc)) |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
378 || (dmd==NULL && gdc==NULL)){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
379 back=1; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
380 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
381 |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
382 return back; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
383 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
384 |
432 | 385 int checkRuntimeErrorMessage(const char* file_, const char* line_, const char* buffer){ |
438 | 386 /* PhobosLong dir/file.d(2) |
490 | 387 * Phobos package.module(2) |
438 | 388 */ |
432 | 389 |
390 char* file; | |
391 char* line; | |
392 char* phobos; | |
393 char* phobosLong; | |
394 | |
395 char* begin; | |
439 | 396 char* end; |
685 | 397 size_t len; |
432 | 398 |
399 int back=0; | |
400 | |
697 | 401 file = NULL; |
402 line = NULL; | |
403 phobos = NULL; | |
404 phobosLong = NULL; | |
405 | |
406 begin = NULL; | |
407 end = NULL; | |
408 len = 0; | |
409 | |
432 | 410 /* clean arguments */ |
411 if(strcmp(file_, "")!=0){ | |
685 | 412 len = strlen(file_)+1; |
413 file = malloc(len); | |
414 strncpy(file, file_, len); | |
432 | 415 } |
438 | 416 |
432 | 417 if(strcmp(line_, "")!=0){ |
685 | 418 len = strlen(line_)+1; |
419 line = malloc(len); | |
420 strncpy(line, line_, len); | |
432 | 421 } |
438 | 422 |
432 | 423 /* gen patterns*/ |
424 if(file!=NULL){ | |
425 if(line!=NULL){ | |
685 | 426 len = strlen(file)+strlen(line)+5; |
427 phobos = malloc(len); | |
438 | 428 begin=strrchr(file,'/'); |
429 if(begin){ | |
432 | 430 begin++; |
431 }else{ | |
438 | 432 begin=strrchr(file,'\\'); |
433 if(begin){ | |
434 begin++; | |
435 }else{ | |
436 begin=file; | |
437 } | |
432 | 438 } |
439 | 439 end=strrchr(file,'.'); |
440 strncat(phobos, begin, end-begin); | |
685 | 441 snprintf(phobos, len, "%.*s(%s)", |
442 (int)(end-begin), begin, | |
443 line); | |
432 | 444 |
685 | 445 phobosLong = malloc(len); |
446 snprintf(phobosLong, len, "%s(%s)", file, line); | |
432 | 447 }else{ |
685 | 448 len = strlen(file)+2; |
449 phobos = malloc(len); | |
438 | 450 begin=strrchr(file,'/'); |
451 if(begin){ | |
432 | 452 begin++; |
453 }else{ | |
438 | 454 begin=strrchr(file,'\\'); |
455 if(begin){ | |
456 begin++; | |
457 }else{ | |
458 begin=file; | |
459 } | |
432 | 460 } |
439 | 461 end=strrchr(file,'.'); |
685 | 462 snprintf(phobos, len, "%.*s(", (int)(end-begin), begin); |
432 | 463 |
685 | 464 phobosLong = malloc(len); |
465 snprintf(phobosLong, len, "%s(", file); | |
432 | 466 } |
467 }else if(line!=NULL){ | |
685 | 468 len = strlen(line)+3; |
469 phobos = malloc(len); | |
470 snprintf(phobos, len, "(%s)", line); | |
438 | 471 |
432 | 472 phobosLong=NULL; |
473 }else{ | |
474 return 1; | |
475 } | |
476 | |
438 | 477 /* specific error messages */ |
432 | 478 |
676 | 479 #ifdef DEBUG |
480 fprintf(stderr, "pattern(phobosShort):\t%s\n", phobos); | |
481 fprintf(stderr, "pattern(phobosLong):\t%s\n", phobosLong); | |
482 #endif | |
483 | |
432 | 484 if( (phobos && strstr(buffer, phobos)) |
485 || (phobosLong && strstr(buffer, phobosLong))) | |
486 { | |
487 back=1; | |
488 } | |
438 | 489 |
490 return back; | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
491 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
492 |
490 | 493 int hadExecCrash(const char* buffer){ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
494 if(strstr(buffer, "Segmentation fault") |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
495 || strstr(buffer, "Internal error") |
499 | 496 || strstr(buffer, "gcc.gnu.org/bugs") |
497 || strstr(buffer, "EXIT CODE: signal")) | |
490 | 498 { |
499 return 1; | |
500 } | |
501 return 0; | |
502 } | |
503 | |
499 | 504 /* system call with time-out */ |
490 | 505 int crashRun(const char* cmd){ |
506 #ifdef USE_POSIX | |
697 | 507 size_t len; |
508 char* buffer; | |
509 | |
703 | 510 len = 4 + strlen(CRASH_RUN) + strlen(cmd); |
697 | 511 buffer = malloc(len); |
512 | |
685 | 513 snprintf(buffer, len, "\"%s\" %s", CRASH_RUN, cmd); |
697 | 514 |
490 | 515 system(buffer); |
516 buffer=loadFile(TLOG); | |
517 | |
518 if(strstr(buffer, "EXIT CODE: 0")){ | |
519 return EXIT_SUCCESS; | |
520 }else if(strstr(buffer, "EXIT CODE: 256") | |
521 || strstr(buffer, "EXIT CODE: timeout")) | |
522 { | |
523 return EXIT_FAILURE; | |
524 }else{ | |
525 return RAND_MAX; | |
526 } | |
527 #else | |
528 | |
704 | 529 #error comment me out, if your test cases produce neither eternal loops nor Access Violations |
697 | 530 int i = system(cmd); |
703 | 531 fprintf(stderr, "EXIT CODE: %i\n", i); |
697 | 532 return i; |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
533 |
490 | 534 #endif /* USE_POSIX else */ |
535 } | |
536 | |
254 | 537 |
251 | 538 int main(int argc, char* arg[]){ |
438 | 539 char* compiler; /* the compiler - from enviroment flag "DMD" */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
540 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
|
541 char* buffer; /* general purpose buffer */ |
685 | 542 size_t bufferLen; |
438 | 543 int modus; /* test modus: RUN NORUN COMPILE NOCOMPILE */ |
544 int res; /* return code from external executions */ | |
545 char* case_file; | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
546 char* error_file; /* expected sourcefile containing the error */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
547 char* error_line; /* expected error line */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
548 int good_error; /* error contained file and line and matched the expectations */ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
549 char* gdb; /* the debugger - from environment flag "GDB" */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
550 char* gdb_script; /* gdb command sequence */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
551 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
|
552 #ifdef REG_EXTENDED |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
553 regex_t* gdb_pattern; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
554 #endif |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
555 int good_gdb; /* (gdb test and positive) or (no gdb test)*/ |
438 | 556 |
697 | 557 compiler = NULL; |
558 cmd_arg_case = NULL; | |
559 buffer = NULL; | |
560 bufferLen = 0; | |
561 modus = -1; | |
562 res = -1; | |
563 case_file = NULL; | |
564 error_file = NULL; | |
565 error_line = NULL; | |
566 good_error = -1; | |
567 gdb = NULL; | |
568 gdb_script = NULL; | |
569 gdb_pattern_raw = NULL; | |
570 #ifdef REG_EXTENDED | |
571 gdb_pattern = NULL; | |
572 #endif | |
573 good_gdb = -1; | |
574 | |
251 | 575 /* check arguments */ |
576 if(argc != 3){ | |
438 | 577 err: |
704 | 578 fprintf(stderr, "DStress test executer (revision 853)\n" |
579 "Copyright by Thomas Kuehne <thomas@kuehne.cn> 2005\n" | |
580 "\n"); | |
581 | |
438 | 582 if(argc!=0) |
704 | 583 fprintf(stderr, |
584 "%s <run|norun|compile|nocompile> <source>\n", | |
585 arg[0]); | |
251 | 586 else |
704 | 587 fprintf(stderr, |
588 "dstress <run|norun|compile|nocompile>" | |
589 " <source>\n"); | |
590 | |
591 fprintf(stderr, | |
592 "\n" | |
593 "== eniroment settings (usually $NAME or %%NAME%%) ==\n" | |
594 "* DMD - compiler (including standard arguments)\n" | |
595 "* GDB - debugger (including standard arguments)\n" | |
596 "\n" | |
597 "== case setting (line in the case source) ==\n" | |
598 "* __DSTRESS_DFLAGS__ - additional compiler arguments\n" | |
599 "only evaluated if it is a \"nocompile\" or \"norun\" test:\n" | |
600 "* __DSTRESS_ELINE__ - expected source line to throw an error message\n" | |
601 "* __DSTRESS_EFILE__ - expected source file to throw an error message\n" | |
602 " (defaults to the case file)\n" | |
603 "only evaluated if it is a \"run\" or \"norun\" test:\n" | |
604 "* __GDB_SCRIPT__ - command sequence to feed to the debugger\n" | |
605 " (use \\n to encode a line break)\n" | |
606 "* __GDB_PATTERN__ - expected regular expression in the debugger's\n" | |
607 " output\n" | |
608 "== note ==\n" | |
609 "* there current directory is required to contain the sub-directory \"obj\"\n" | |
610 " (used for temporary files)\n" | |
611 ); | |
438 | 612 exit(EXIT_FAILURE); |
251 | 613 } |
438 | 614 |
704 | 615 if(0==strcmp(arg[1], "run")){ |
251 | 616 modus = RUN; |
704 | 617 }else if(0==strcmp(arg[1], "norun")){ |
251 | 618 modus = NORUN; |
704 | 619 }else if(0==strcmp(arg[1], "compile")){ |
251 | 620 modus = COMPILE; |
704 | 621 }else if(0==strcmp(arg[1], "nocompile")){ |
251 | 622 modus = NOCOMPILE; |
623 }else{ | |
624 goto err; | |
625 } | |
626 | |
627 /* gen flags */ | |
438 | 628 case_file = cleanPathSeperator(strdup(arg[2])); |
251 | 629 compiler = getCompiler(); |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
630 gdb = getGDB(); |
438 | 631 buffer = loadFile(case_file); |
632 | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
633 cmd_arg_case = getCaseFlag(buffer, "__DSTRESS_DFLAGS__"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
634 error_line = getCaseFlag(buffer, "__DSTRESS_ELINE__"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
635 error_file = getCaseFlag(buffer, "__DSTRESS_EFILE__"); |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
636 gdb_script = getCaseFlag(buffer, "__GDB_SCRIPT__"); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
637 gdb_pattern_raw = getCaseFlag(buffer, "__GDB_PATTERN__"); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
638 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
639 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
640 /* set implicit source file */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
641 if(strcmp(error_line, "")!=0 && strcmp(error_file, "")==0){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
642 error_file=case_file; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
643 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
644 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
645 /* gdb pattern */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
646 #ifdef REG_EXTENDED |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
647 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
|
648 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
649 gdb_pattern = malloc(sizeof(regex_t)); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
650 if(regcomp(gdb_pattern, gdb_pattern_raw, REG_EXTENDED)){ |
704 | 651 fprintf(stderr, "failed to compile regular expression:" |
652 "\n\t%s\n", gdb_pattern_raw); | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
653 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
654 }else if(gdb_script==NULL){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
655 fprintf(stderr, "GDB pattern without GDB script\n"); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
656 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
657 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
658 }else{ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
659 gdb_pattern = NULL; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
660 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
661 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
662 /* gdb script */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
663 if(gdb_script!=NULL && gdb_script[0]!='\x00'){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
664 if(gdb_pattern==NULL){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
665 fprintf(stderr, "GDB script without GDB pattern\n"); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
666 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
667 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
668 buffer=gdb_script; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
669 for(; *buffer; buffer++){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
670 if(buffer[0]=='\\'){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
671 if(buffer[1]=='n'){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
672 buffer[0]=' '; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
673 buffer[1]='\n'; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
674 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
675 buffer++; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
676 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
677 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
678 |
685 | 679 bufferLen = strlen(gdb_script)+11; |
680 buffer=malloc(bufferLen); | |
681 snprintf(buffer, bufferLen, "%s\n\nquit\ny\n\n", gdb_script); | |
682 gdb_script=buffer; | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
683 good_gdb = 0; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
684 }else{ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
685 good_gdb = 1; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
686 gdb_script = NULL; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
687 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
688 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
689 #else |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
690 |
704 | 691 if(gdb_script && strlen(gdb_script)){ |
692 if(gdb_pattern_raw && strlen(gdb_pattern_raw)){ | |
693 fprintf(stderr, "WARNING: debugger/regex support inactive\n"); | |
694 }else{ | |
695 fprintf(stderr, "debugger script without debugger pattern\n"); | |
696 exit(EXIT_FAILURE); | |
697 } | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
698 }else if(gdb_pattern_raw && strlen(gdb_pattern_raw)){ |
704 | 699 fprintf(stderr, "debugger pattern without debugger script\n"); |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
700 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
701 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
702 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
703 #endif /* REG_EXTENDED else */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
704 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
705 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
706 |
493 | 707 #ifdef DEBUG |
438 | 708 fprintf(stderr, "case: \"%s\"\n", case_file); |
709 fprintf(stderr, "compiler: \"%s\"\n", compiler); | |
710 fprintf(stderr, "DFLAGS C: \"%s\"\n", cmd_arg_case); | |
711 fprintf(stderr, "ELINE : \"%s\"\n", error_line); | |
712 fprintf(stderr, "EFILE : \"%s\"\n", error_file); | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
713 fprintf(stderr, "GDB Scri: \"%s\"\n", gdb_script); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
714 fprintf(stderr, "GDB Patt: \"%s\"\n", gdb_pattern_raw); |
438 | 715 #endif |
716 | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
717 /* start working */ |
251 | 718 if(modus==COMPILE || modus==NOCOMPILE){ |
719 /* gen command */ | |
693 | 720 bufferLen = strlen(compiler)+strlen(cmd_arg_case) |
697 | 721 +strlen(OBJ)+strlen(case_file)+strlen(TLOG)+21; |
693 | 722 buffer = malloc(bufferLen); |
685 | 723 snprintf(buffer, bufferLen, "%s %s ", compiler, cmd_arg_case); |
724 | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
725 if(NULL==strstr(buffer, "-od")){ |
685 | 726 snprintf(buffer, bufferLen, |
727 "%s %s -od%s -c %s 1> %s 2>&1", | |
728 compiler, cmd_arg_case, OBJ, case_file, TLOG); | |
729 }else{ | |
730 snprintf(buffer, bufferLen, "%s %s -c %s 1> %s 2>&1", | |
731 compiler, cmd_arg_case, case_file, TLOG); | |
251 | 732 } |
733 | |
734 /* test */ | |
735 if(modus==COMPILE){ | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
736 fprintf(stderr, "compile: %s\n", buffer); |
251 | 737 }else{ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
738 fprintf(stderr, "nocompile: %s\n", buffer); |
251 | 739 } |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
740 res = crashRun(buffer); |
251 | 741 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
742 /* diagnostic */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
743 buffer = loadFile(TLOG); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
744 fprintf(stderr, "%s\n", buffer); |
438 | 745 good_error = checkErrorMessage(error_file, error_line, buffer); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
746 |
490 | 747 if(hadExecCrash(buffer)){ |
704 | 748 printf("ERROR:\t%s [internal compiler error]\n", |
749 case_file); | |
251 | 750 }else if(modus==COMPILE){ |
490 | 751 if(res==EXIT_SUCCESS){ |
438 | 752 printf("PASS: \t%s\n", case_file); |
490 | 753 }else if(res==EXIT_FAILURE && good_error){ |
438 | 754 if(checkErrorMessage(case_file, "", buffer)){ |
499 | 755 printf("FAIL: \t%s\n", case_file); |
373
177ce8d13eac
test cases that unexpectetly fail and in addition fail to provide file/line information are now treated as ERROR instead of FAIL
thomask
parents:
361
diff
changeset
|
756 }else{ |
704 | 757 printf("ERROR:\t%s%s\n", case_file, |
758 errorMsg(good_error)); | |
373
177ce8d13eac
test cases that unexpectetly fail and in addition fail to provide file/line information are now treated as ERROR instead of FAIL
thomask
parents:
361
diff
changeset
|
759 } |
251 | 760 }else{ |
704 | 761 printf("ERROR:\t%s%s\n", case_file, |
762 errorMsg(good_error)); | |
251 | 763 } |
764 }else{ | |
490 | 765 if(res==EXIT_FAILURE){ |
361 | 766 if(good_error){ |
438 | 767 printf("XFAIL:\t%s\n", case_file); |
361 | 768 }else{ |
704 | 769 printf("FAIL: \t%s%s\n", case_file, |
770 errorMsg(good_error)); | |
361 | 771 } |
490 | 772 }else if(res==EXIT_SUCCESS){ |
438 | 773 printf("XPASS:\t%s\n", case_file); |
251 | 774 }else{ |
499 | 775 printf("ERROR:\t%s\n", case_file); |
251 | 776 } |
777 } | |
778 fprintf(stderr,"--------\n"); | |
779 }else if(modus==RUN || modus==NORUN){ | |
780 /* gen command */ | |
685 | 781 |
782 bufferLen = strlen(compiler)+strlen(cmd_arg_case) | |
783 +strlen(OBJ) | |
784 +strlen(case_file)*2+strlen(TLOG)+64; | |
785 buffer = malloc(bufferLen); | |
786 snprintf(buffer, bufferLen, "%s %s ", compiler, cmd_arg_case); | |
787 | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
788 if(NULL==strstr(buffer, "-od")){ |
685 | 789 if(NULL==strstr(buffer, "-of")){ |
790 snprintf(buffer, bufferLen, | |
791 "%s %s -od%s -of%s.exe %s 1> %s 2>&1", | |
792 compiler, cmd_arg_case, OBJ, case_file, | |
793 case_file, TLOG); | |
794 }else{ | |
795 snprintf(buffer, bufferLen, | |
796 "%s %s -od%s %s 1> %s 2>&1", | |
797 compiler, cmd_arg_case, OBJ, case_file, | |
798 TLOG); | |
799 } | |
800 }else if(NULL==strstr(buffer, "-of")){ | |
801 snprintf(buffer, bufferLen, | |
802 "%s %s -of%s.exe %s 1> %s 2>&1", | |
803 compiler, cmd_arg_case, case_file, case_file, | |
804 TLOG); | |
805 }else{ | |
806 snprintf(buffer, bufferLen, "%s %s %s 1> %s 2>&1", | |
807 compiler, cmd_arg_case, case_file, TLOG); | |
251 | 808 } |
809 | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
810 /* test 1/3 - compile */ |
251 | 811 if(modus==RUN){ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
812 fprintf(stderr, "run: %s\n", buffer); |
251 | 813 }else{ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
814 fprintf(stderr, "norun: %s\n", buffer); |
251 | 815 } |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
816 res = crashRun(buffer); |
438 | 817 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
818 /* diagnostic 1/3 */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
819 buffer = loadFile(TLOG); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
820 fprintf(stderr, "%s", buffer); |
697 | 821 |
676 | 822 if(modus==RUN){ |
704 | 823 good_error = checkErrorMessage(error_file, error_line, |
824 buffer); | |
676 | 825 }else{ |
826 good_error = 1; | |
827 } | |
490 | 828 if(hadExecCrash(buffer)){ |
704 | 829 printf("ERROR:\t%s [internal compiler error]\n", |
830 case_file); | |
251 | 831 fprintf(stderr, "\n--------\n"); |
437 | 832 return EXIT_SUCCESS; |
490 | 833 }else if(res==EXIT_FAILURE && good_error){ |
499 | 834 printf("FAIL: \t%s\n", case_file); |
251 | 835 fprintf(stderr, "\n--------\n"); |
437 | 836 return EXIT_SUCCESS; |
490 | 837 }else if(res!=EXIT_SUCCESS){ |
704 | 838 printf("ERROR:\t%s%s\n", case_file, |
839 errorMsg(good_error)); | |
251 | 840 fprintf(stderr, "\n--------\n"); |
437 | 841 return EXIT_SUCCESS; |
251 | 842 } |
438 | 843 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
844 /* test 2/3 - run */ |
685 | 845 bufferLen = strlen(case_file) + strlen(TLOG) + 30; |
846 buffer = malloc(bufferLen); | |
847 snprintf(buffer, bufferLen, "%s.exe 1> %s 2>&1\n", case_file, | |
848 TLOG); | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
849 fprintf(stderr, "%s\n", buffer); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
850 res=crashRun(buffer); |
438 | 851 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
852 /* diagnostic 2/3 */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
853 buffer = loadFile(TLOG); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
854 fprintf(stderr, "%s\n", buffer); |
685 | 855 if(modus==NORUN){ |
704 | 856 good_error = checkRuntimeErrorMessage(error_file, |
857 error_line, buffer); | |
685 | 858 }else{ |
859 good_error = 1; | |
860 } | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
861 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
862 #ifdef REG_EXTENDED |
622 | 863 if(!good_gdb){ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
864 /* test 3/3 - gdb */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
865 writeFile(GDB_SCRIPTER, gdb_script); |
685 | 866 bufferLen = strlen(gdb) + strlen(case_file) |
867 + strlen(GDB_SCRIPTER) + strlen(TLOG) + 20; | |
868 snprintf(buffer, bufferLen, "%s %s.exe < %s > %s 2>&1", | |
869 gdb, case_file, GDB_SCRIPTER, TLOG); | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
870 fprintf(stderr, "%s\n", buffer); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
871 if(EXIT_SUCCESS==crashRun(buffer)){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
872 /* diagnostic 3/3 */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
873 buffer = loadFile(TLOG); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
874 fprintf(stderr, "%s\n", buffer); |
704 | 875 good_gdb = (regexec( |
876 gdb_pattern, buffer, 0, NULL, 0 | |
877 )==0); | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
878 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
879 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
880 #endif /* REG_EXTENDED */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
881 |
251 | 882 if(modus==RUN){ |
499 | 883 if(hadExecCrash(buffer)){ |
704 | 884 printf("ERROR:\t%s [test case crash]%s%s", |
885 case_file, errorMsg(good_error), | |
886 gdbMsg(good_gdb)); | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
887 }else if(res==EXIT_SUCCESS && good_gdb){ |
438 | 888 printf("PASS: \t%s\n", case_file); |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
889 }else if(res==EXIT_FAILURE && good_error && good_gdb){ |
499 | 890 printf("FAIL: \t%s\n", case_file); |
251 | 891 }else{ |
704 | 892 printf("ERROR:\t%s%s%s\n", case_file, |
893 errorMsg(good_error), gdbMsg(good_gdb)); | |
251 | 894 } |
895 }else{ | |
622 | 896 if(res==EXIT_SUCCESS && good_gdb){ |
697 | 897 printf("XPASS:\t%s%s\n", case_file, gdbMsg(good_gdb)); |
622 | 898 }else if(good_error && good_gdb){ |
704 | 899 printf("XFAIL:\t%s%s%s\n", case_file, |
900 errorMsg(good_error), gdbMsg(good_gdb)); | |
251 | 901 }else{ |
704 | 902 printf("FAIL:\t%s%s%s\n", case_file, |
903 errorMsg(good_error), gdbMsg(good_gdb)); | |
251 | 904 } |
905 } | |
906 fprintf(stderr, "--------\n"); | |
907 }else{ | |
438 | 908 printf("@bug@ %d (%s)\n", modus, case_file); |
436 | 909 return EXIT_FAILURE; |
251 | 910 } |
436 | 911 return EXIT_SUCCESS; |
251 | 912 } |