Mercurial > projects > dstress
annotate dstress.c @ 703:8dc894322ce8
repos maintenance
author | thomask |
---|---|
date | Wed, 12 Oct 2005 18:24:50 +0000 |
parents | fbee62becd2c |
children | 3e690f0d2cbf |
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 |
622 | 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 |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
67 #ifdef USE_POSIX |
254 | 68 |
251 | 69 #include <sys/types.h> |
70 #include <sys/stat.h> | |
71 #include <fcntl.h> | |
72 #include <unistd.h> | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
73 #include <regex.h> |
490 | 74 |
75 #else | |
633 | 76 #ifdef USE_WINDOWS |
490 | 77 |
78 #include <windows.h> | |
685 | 79 #define snprintf _snprintf |
697 | 80 #ifndef INVALID_FILE_SIZE |
81 #define INVALID_FILE_SIZE -1 | |
82 #endif | |
490 | 83 |
633 | 84 #else |
85 #error neither POSIX nor MSWindows detected | |
86 #endif /* USE_WINDOWS else */ | |
490 | 87 #endif /* USE_POSIX else */ |
88 | |
685 | 89 #define OBJ "obj " |
697 | 90 |
633 | 91 #ifdef USE_WINDOWS |
697 | 92 #define TLOG ".\\obj\\log.tmp" |
93 #define CRASH_RUN ".\\crashRun" | |
94 #define GDB_SCRIPTER ".\\obj\\gdb.tmp" | |
633 | 95 #else |
96 #ifdef USE_POSIX | |
697 | 97 #define TLOG "./obj/log.tmp" |
98 #define CRASH_RUN "./crashRun" | |
99 #define GDB_SCRIPTER "./obj/gdb.tmp" | |
633 | 100 #endif |
101 #endif | |
102 | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
103 char* errorMsg(int good_error){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
104 return (good_error) ? ("") : " [bad error message]"; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
105 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
106 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
107 char* gdbMsg(int good_gdb){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
108 return (good_gdb) ? ("") : " [bad debugger message]"; |
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 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
111 char* strip(char* buffer){ |
697 | 112 char* tmp = NULL; |
685 | 113 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
114 if(buffer!=NULL){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
115 while(isspace(buffer[0])){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
116 buffer++; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
117 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
118 |
622 | 119 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
|
120 tmp[0]='\x00'; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
121 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
122 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
123 return buffer; |
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 /* cleanup "/" versus "\" in filenames */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
127 char* cleanPathSeperator(char* filename){ |
697 | 128 char* pos = NULL; |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
129 #ifdef USE_POSIX |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
130 for(pos=strchr(filename, '\\'); pos; pos=strchr(filename, '\\')){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
131 *pos='/'; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
132 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
133 #else |
633 | 134 #if USE_WINDOWS |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
135 for(pos=strchr(filename, '/'); pos; pos=strchr(filename, '/')){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
136 *pos='\\'; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
137 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
138 #else |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
139 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
140 #error no cleanPathSeperator available for this system |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
141 |
633 | 142 #endif /* USE_WINDOWS else */ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
143 #endif /* USE_POSIX else */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
144 return filename; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
145 } |
490 | 146 |
251 | 147 char* loadFile(char* filename){ |
490 | 148 #ifdef USE_POSIX |
697 | 149 char* back; |
251 | 150 struct stat fileInfo; |
151 int file = open(filename, O_RDONLY); | |
697 | 152 |
153 back = NULL; | |
154 | |
251 | 155 if(errno == 0 && file != 0 && file != -1){ |
156 if(0==fstat(file, &fileInfo)){ | |
157 back=malloc(fileInfo.st_size+1); | |
158 fileInfo.st_size = read(file, back, fileInfo.st_size); | |
440 | 159 if(fileInfo.st_size>=0){ |
697 | 160 *(back+fileInfo.st_size) = '\x00'; |
251 | 161 }else{ |
436 | 162 back = NULL; |
251 | 163 } |
164 } | |
165 close(file); | |
166 } | |
436 | 167 |
168 if(back){ | |
169 return back; | |
170 } | |
440 | 171 if(0==strcmp(filename, TLOG)){ |
172 return calloc(1,sizeof(char)); | |
173 } | |
436 | 174 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
175 fprintf(stderr, "File not found \"%s\" (%s)\n", filename, strerror(errno)); |
436 | 176 exit(EXIT_FAILURE); |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
177 #else /* USE_POSIX */ |
633 | 178 #ifdef USE_WINDOWS |
697 | 179 // @todo@ check for 32bit/64bit |
180 char* back; | |
254 | 181 DWORD size, numread; |
182 HANDLE file=CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, | |
183 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); | |
697 | 184 |
185 back = NULL; | |
186 size = 0; | |
187 numread = 0; | |
254 | 188 if (file != INVALID_HANDLE_VALUE){ |
189 size = GetFileSize(file, NULL); | |
190 if (size != INVALID_FILE_SIZE){ | |
191 back=malloc((size+1)*sizeof(char)); | |
292 | 192 if (ReadFile(file,back,size,&numread,NULL) == 1){ |
193 if (numread==size){ | |
697 | 194 *(back+size) = '\x00'; |
292 | 195 }else{ |
438 | 196 back = NULL; |
292 | 197 } |
198 }else{ | |
438 | 199 back = NULL; |
292 | 200 } |
254 | 201 } |
202 CloseHandle(file); | |
203 } | |
438 | 204 if(back){ |
205 errno = 0; | |
206 return back; | |
207 } | |
208 | |
209 fprintf(stderr, "File not found \"%s\"\n", filename); | |
210 exit(EXIT_FAILURE); | |
633 | 211 #else /* USE_WINDOWS */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
212 |
490 | 213 #error "no loadFile implementation present" |
361 | 214 |
633 | 215 #endif /* USE_WINDOWS */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
216 #endif /* USE_POSIX else */ |
490 | 217 } |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
218 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
219 void writeFile(const char* filename, const char* content){ |
697 | 220 size_t len; |
221 FILE* file; | |
222 | |
223 len = strlen(content); | |
224 errno = 0; | |
225 file = fopen(filename, "w+"); | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
226 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
227 if(errno == 0 && file != NULL){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
228 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
|
229 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
|
230 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
231 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
232 if(fclose(file) || (errno != 0)){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
233 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
|
234 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
235 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
236 return; |
438 | 237 } |
499 | 238 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
239 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
|
240 exit(EXIT_FAILURE); |
438 | 241 } |
242 | |
499 | 243 /* query the environment for the compiler name */ |
697 | 244 char* getCompiler(void){ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
245 char* back = getenv("DMD"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
246 if(back == NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
247 back = getenv("dmd"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
248 if(back==NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
249 back = "dmd"; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
250 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
251 } |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
252 return strip(cleanPathSeperator(back)); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
253 } |
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 /* query the environment for the debugger name */ |
697 | 256 char* getGDB(void){ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
257 char* back = getenv("GDB"); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
258 if(back == NULL){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
259 back = getenv("gdb"); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
260 if(back == NULL){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
261 back = "gdb"; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
262 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
263 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
264 return strip(cleanPathSeperator(back)); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
265 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
266 |
499 | 267 /* 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
|
268 char* getCaseFlag(const char* data, const char* tag){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
269 char* begin; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
270 char* end1; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
271 char* end2; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
272 char* back; |
438 | 273 |
697 | 274 begin = NULL; |
275 end1 = NULL; | |
276 end2 = NULL; | |
277 back = NULL; | |
278 | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
279 if(data!=NULL && tag!=NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
280 begin = strstr(data, tag); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
281 if(begin!=NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
282 begin = begin+strlen(tag); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
283 end1 = strstr(begin, "\n"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
284 end2 = strstr(begin, "\r"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
285 if(end2!=NULL && ((end1!=NULL && end2<end1) || end1==NULL)){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
286 end1=end2; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
287 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
288 if(end1==NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
289 end1 = begin + strlen(begin); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
290 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
291 back = malloc(end1-begin+1); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
292 strncpy(back, begin, end1-begin); |
697 | 293 back[end1-begin]='\x00'; |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
294 return strip(cleanPathSeperator(back)); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
295 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
296 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
297 |
429 | 298 return calloc(1,1); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
299 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
300 |
499 | 301 /* check compile-time error messages */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
302 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
|
303 |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
304 char* file; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
305 char* line; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
306 char* dmd; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
307 char* gdc; |
697 | 308 size_t len; |
309 int back; | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
310 |
697 | 311 file = NULL; |
312 line = NULL; | |
313 dmd = NULL; | |
314 gdc = NULL; | |
315 len = 0; | |
316 back = 0; | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
317 |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
318 /* clean arguments */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
319 if(strcmp(file_, "")!=0){ |
685 | 320 len = strlen(file_)+1; |
321 file = malloc(len); | |
322 strncpy(file, file_, len); | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
323 } |
438 | 324 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
325 if(strcmp(line_, "")!=0){ |
685 | 326 len = strlen(line_)+1; |
327 line = malloc(len); | |
328 strncpy(line, line_, len); | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
329 } |
438 | 330 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
331 /* gen patterns*/ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
332 if(file!=NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
333 if(line!=NULL){ |
685 | 334 len = strlen(file)+strlen(line)+5; |
335 dmd = malloc(len); | |
336 snprintf(dmd, len, "%s(%s)", file, line); | |
337 | |
338 gdc = malloc(len); | |
339 snprintf(gdc, len, "%s:%s: ", file, line); | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
340 }else{ |
685 | 341 len = strlen(file)+2; |
342 dmd = malloc(len); | |
343 snprintf(dmd, len, "%s(", file); | |
622 | 344 |
685 | 345 gdc = malloc(len); |
346 snprintf(gdc, len, "%s:", file); | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
347 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
348 }else if(line!=NULL){ |
685 | 349 len = strlen(line)+5; |
350 dmd = malloc(len); | |
351 snprintf(dmd, len, "(%s): ", line); | |
622 | 352 |
685 | 353 gdc = malloc(len); |
354 snprintf(gdc, len, ":%s: ", line); | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
355 }else{ |
432 | 356 return 1; |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
357 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
358 |
438 | 359 /* specific error messages */ |
676 | 360 #ifdef DEBUG |
361 fprintf(stderr, "pattern(dmd):\t%s\n", dmd); | |
362 fprintf(stderr, "pattern(gdc):\t%s\n", gdc); | |
363 #endif | |
251 | 364 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
365 if( (dmd!=NULL && strstr(buffer, dmd)) |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
366 || (gdc!=NULL && strstr(buffer, gdc)) |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
367 || (dmd==NULL && gdc==NULL)){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
368 back=1; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
369 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
370 |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
371 return back; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
372 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
373 |
432 | 374 int checkRuntimeErrorMessage(const char* file_, const char* line_, const char* buffer){ |
438 | 375 /* PhobosLong dir/file.d(2) |
490 | 376 * Phobos package.module(2) |
438 | 377 */ |
432 | 378 |
379 char* file; | |
380 char* line; | |
381 char* phobos; | |
382 char* phobosLong; | |
383 | |
384 char* begin; | |
439 | 385 char* end; |
685 | 386 size_t len; |
432 | 387 |
388 int back=0; | |
389 | |
697 | 390 file = NULL; |
391 line = NULL; | |
392 phobos = NULL; | |
393 phobosLong = NULL; | |
394 | |
395 begin = NULL; | |
396 end = NULL; | |
397 len = 0; | |
398 | |
432 | 399 /* clean arguments */ |
400 if(strcmp(file_, "")!=0){ | |
685 | 401 len = strlen(file_)+1; |
402 file = malloc(len); | |
403 strncpy(file, file_, len); | |
432 | 404 } |
438 | 405 |
432 | 406 if(strcmp(line_, "")!=0){ |
685 | 407 len = strlen(line_)+1; |
408 line = malloc(len); | |
409 strncpy(line, line_, len); | |
432 | 410 } |
438 | 411 |
432 | 412 /* gen patterns*/ |
413 if(file!=NULL){ | |
414 if(line!=NULL){ | |
685 | 415 len = strlen(file)+strlen(line)+5; |
416 phobos = malloc(len); | |
438 | 417 begin=strrchr(file,'/'); |
418 if(begin){ | |
432 | 419 begin++; |
420 }else{ | |
438 | 421 begin=strrchr(file,'\\'); |
422 if(begin){ | |
423 begin++; | |
424 }else{ | |
425 begin=file; | |
426 } | |
432 | 427 } |
439 | 428 end=strrchr(file,'.'); |
429 strncat(phobos, begin, end-begin); | |
685 | 430 snprintf(phobos, len, "%.*s(%s)", |
431 (int)(end-begin), begin, | |
432 line); | |
432 | 433 |
685 | 434 phobosLong = malloc(len); |
435 snprintf(phobosLong, len, "%s(%s)", file, line); | |
432 | 436 }else{ |
685 | 437 len = strlen(file)+2; |
438 phobos = malloc(len); | |
438 | 439 begin=strrchr(file,'/'); |
440 if(begin){ | |
432 | 441 begin++; |
442 }else{ | |
438 | 443 begin=strrchr(file,'\\'); |
444 if(begin){ | |
445 begin++; | |
446 }else{ | |
447 begin=file; | |
448 } | |
432 | 449 } |
439 | 450 end=strrchr(file,'.'); |
685 | 451 snprintf(phobos, len, "%.*s(", (int)(end-begin), begin); |
432 | 452 |
685 | 453 phobosLong = malloc(len); |
454 snprintf(phobosLong, len, "%s(", file); | |
432 | 455 } |
456 }else if(line!=NULL){ | |
685 | 457 len = strlen(line)+3; |
458 phobos = malloc(len); | |
459 snprintf(phobos, len, "(%s)", line); | |
438 | 460 |
432 | 461 phobosLong=NULL; |
462 }else{ | |
463 return 1; | |
464 } | |
465 | |
438 | 466 /* specific error messages */ |
432 | 467 |
676 | 468 #ifdef DEBUG |
469 fprintf(stderr, "pattern(phobosShort):\t%s\n", phobos); | |
470 fprintf(stderr, "pattern(phobosLong):\t%s\n", phobosLong); | |
471 #endif | |
472 | |
432 | 473 if( (phobos && strstr(buffer, phobos)) |
474 || (phobosLong && strstr(buffer, phobosLong))) | |
475 { | |
476 back=1; | |
477 } | |
438 | 478 |
479 return back; | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
480 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
481 |
490 | 482 int hadExecCrash(const char* buffer){ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
483 if(strstr(buffer, "Segmentation fault") |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
484 || strstr(buffer, "Internal error") |
499 | 485 || strstr(buffer, "gcc.gnu.org/bugs") |
486 || strstr(buffer, "EXIT CODE: signal")) | |
490 | 487 { |
488 return 1; | |
489 } | |
490 return 0; | |
491 } | |
492 | |
499 | 493 /* system call with time-out */ |
490 | 494 int crashRun(const char* cmd){ |
495 #ifdef USE_POSIX | |
697 | 496 size_t len; |
497 char* buffer; | |
498 | |
703 | 499 len = 4 + strlen(CRASH_RUN) + strlen(cmd); |
697 | 500 buffer = malloc(len); |
501 | |
685 | 502 snprintf(buffer, len, "\"%s\" %s", CRASH_RUN, cmd); |
697 | 503 |
490 | 504 system(buffer); |
505 buffer=loadFile(TLOG); | |
506 | |
507 if(strstr(buffer, "EXIT CODE: 0")){ | |
508 return EXIT_SUCCESS; | |
509 }else if(strstr(buffer, "EXIT CODE: 256") | |
510 || strstr(buffer, "EXIT CODE: timeout")) | |
511 { | |
512 return EXIT_FAILURE; | |
513 }else{ | |
514 return RAND_MAX; | |
515 } | |
516 #else | |
517 | |
703 | 518 //#error comment me out, if your test cases produce neither eternal loops nor Access Violations |
697 | 519 int i = system(cmd); |
703 | 520 fprintf(stderr, "EXIT CODE: %i\n", i); |
697 | 521 return i; |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
522 |
490 | 523 #endif /* USE_POSIX else */ |
524 } | |
525 | |
254 | 526 |
251 | 527 int main(int argc, char* arg[]){ |
438 | 528 char* compiler; /* the compiler - from enviroment flag "DMD" */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
529 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
|
530 char* buffer; /* general purpose buffer */ |
685 | 531 size_t bufferLen; |
438 | 532 int modus; /* test modus: RUN NORUN COMPILE NOCOMPILE */ |
533 int res; /* return code from external executions */ | |
534 char* case_file; | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
535 char* error_file; /* expected sourcefile containing the error */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
536 char* error_line; /* expected error line */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
537 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
|
538 char* gdb; /* the debugger - from environment flag "GDB" */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
539 char* gdb_script; /* gdb command sequence */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
540 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
|
541 #ifdef REG_EXTENDED |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
542 regex_t* gdb_pattern; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
543 #endif |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
544 int good_gdb; /* (gdb test and positive) or (no gdb test)*/ |
438 | 545 |
697 | 546 compiler = NULL; |
547 cmd_arg_case = NULL; | |
548 buffer = NULL; | |
549 bufferLen = 0; | |
550 modus = -1; | |
551 res = -1; | |
552 case_file = NULL; | |
553 error_file = NULL; | |
554 error_line = NULL; | |
555 good_error = -1; | |
556 gdb = NULL; | |
557 gdb_script = NULL; | |
558 gdb_pattern_raw = NULL; | |
559 #ifdef REG_EXTENDED | |
560 gdb_pattern = NULL; | |
561 #endif | |
562 good_gdb = -1; | |
563 | |
251 | 564 /* check arguments */ |
565 if(argc != 3){ | |
438 | 566 err: |
567 if(argc!=0) | |
251 | 568 fprintf(stderr,"%s <run|norun|compile|nocompile> <source>\n", arg[0]); |
569 else | |
438 | 570 fprintf(stderr,"dstress <run|norun|compile|nocompile> <source>\n"); |
571 exit(EXIT_FAILURE); | |
251 | 572 } |
438 | 573 |
251 | 574 if(0==strcmp(arg[1], "run") || 0==strcmp(arg[1], "RUN")){ |
575 modus = RUN; | |
576 }else if(0==strcmp(arg[1], "norun") || 0==strcmp(arg[1], "NORUN")){ | |
577 modus = NORUN; | |
578 }else if(0==strcmp(arg[1], "compile") || 0==strcmp(arg[1], "COMPILE")){ | |
579 modus = COMPILE; | |
580 }else if(0==strcmp(arg[1], "nocompile") || 0==strcmp(arg[1], "NOCOMPILE")){ | |
581 modus = NOCOMPILE; | |
582 }else{ | |
583 goto err; | |
584 } | |
585 | |
586 /* gen flags */ | |
438 | 587 case_file = cleanPathSeperator(strdup(arg[2])); |
251 | 588 compiler = getCompiler(); |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
589 gdb = getGDB(); |
438 | 590 buffer = loadFile(case_file); |
591 | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
592 cmd_arg_case = getCaseFlag(buffer, "__DSTRESS_DFLAGS__"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
593 error_line = getCaseFlag(buffer, "__DSTRESS_ELINE__"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
594 error_file = getCaseFlag(buffer, "__DSTRESS_EFILE__"); |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
595 gdb_script = getCaseFlag(buffer, "__GDB_SCRIPT__"); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
596 gdb_pattern_raw = getCaseFlag(buffer, "__GDB_PATTERN__"); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
597 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
598 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
599 /* set implicit source file */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
600 if(strcmp(error_line, "")!=0 && strcmp(error_file, "")==0){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
601 error_file=case_file; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
602 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
603 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
604 /* gdb pattern */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
605 #ifdef REG_EXTENDED |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
606 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
|
607 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
608 gdb_pattern = malloc(sizeof(regex_t)); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
609 if(regcomp(gdb_pattern, gdb_pattern_raw, REG_EXTENDED)){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
610 fprintf(stderr, "failed to compile regular expression:\n\t%s\n", gdb_pattern_raw); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
611 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
612 }else if(gdb_script==NULL){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
613 fprintf(stderr, "GDB pattern without GDB script\n"); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
614 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
615 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
616 }else{ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
617 gdb_pattern = NULL; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
618 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
619 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
620 /* gdb script */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
621 if(gdb_script!=NULL && gdb_script[0]!='\x00'){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
622 if(gdb_pattern==NULL){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
623 fprintf(stderr, "GDB script without GDB pattern\n"); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
624 exit(EXIT_FAILURE); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
625 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
626 buffer=gdb_script; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
627 for(; *buffer; buffer++){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
628 if(buffer[0]=='\\'){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
629 if(buffer[1]=='n'){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
630 buffer[0]=' '; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
631 buffer[1]='\n'; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
632 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
633 buffer++; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
634 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
635 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
636 |
685 | 637 bufferLen = strlen(gdb_script)+11; |
638 buffer=malloc(bufferLen); | |
639 snprintf(buffer, bufferLen, "%s\n\nquit\ny\n\n", gdb_script); | |
640 gdb_script=buffer; | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
641 good_gdb = 0; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
642 }else{ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
643 good_gdb = 1; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
644 gdb_script = NULL; |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
645 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
646 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
647 #else |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
648 |
622 | 649 if(gdb_script && strlen(gdb_script) && gdb_pattern_raw && strlen(gdb_pattern_raw)){ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
650 fprintf(stderr, "WARNING: regex support inactive\n"); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
651 }else if(gdb_script && strlen(gdb_script)){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
652 fprintf(stderr, "GDB script without GDB pattern\n"); |
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_pattern_raw && strlen(gdb_pattern_raw)){ |
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 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
659 #endif /* REG_EXTENDED else */ |
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 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
662 |
493 | 663 #ifdef DEBUG |
438 | 664 fprintf(stderr, "case: \"%s\"\n", case_file); |
665 fprintf(stderr, "compiler: \"%s\"\n", compiler); | |
666 fprintf(stderr, "DFLAGS C: \"%s\"\n", cmd_arg_case); | |
667 fprintf(stderr, "ELINE : \"%s\"\n", error_line); | |
668 fprintf(stderr, "EFILE : \"%s\"\n", error_file); | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
669 fprintf(stderr, "GDB Scri: \"%s\"\n", gdb_script); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
670 fprintf(stderr, "GDB Patt: \"%s\"\n", gdb_pattern_raw); |
438 | 671 #endif |
672 | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
673 /* start working */ |
251 | 674 if(modus==COMPILE || modus==NOCOMPILE){ |
675 /* gen command */ | |
693 | 676 bufferLen = strlen(compiler)+strlen(cmd_arg_case) |
697 | 677 +strlen(OBJ)+strlen(case_file)+strlen(TLOG)+21; |
693 | 678 buffer = malloc(bufferLen); |
685 | 679 snprintf(buffer, bufferLen, "%s %s ", compiler, cmd_arg_case); |
680 | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
681 if(NULL==strstr(buffer, "-od")){ |
685 | 682 snprintf(buffer, bufferLen, |
683 "%s %s -od%s -c %s 1> %s 2>&1", | |
684 compiler, cmd_arg_case, OBJ, case_file, TLOG); | |
685 }else{ | |
686 snprintf(buffer, bufferLen, "%s %s -c %s 1> %s 2>&1", | |
687 compiler, cmd_arg_case, case_file, TLOG); | |
251 | 688 } |
689 | |
690 /* test */ | |
691 if(modus==COMPILE){ | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
692 fprintf(stderr, "compile: %s\n", buffer); |
251 | 693 }else{ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
694 fprintf(stderr, "nocompile: %s\n", buffer); |
251 | 695 } |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
696 res = crashRun(buffer); |
251 | 697 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
698 /* diagnostic */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
699 buffer = loadFile(TLOG); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
700 fprintf(stderr, "%s\n", buffer); |
438 | 701 good_error = checkErrorMessage(error_file, error_line, buffer); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
702 |
490 | 703 if(hadExecCrash(buffer)){ |
499 | 704 printf("ERROR:\t%s [internal compiler error]\n", case_file); |
251 | 705 }else if(modus==COMPILE){ |
490 | 706 if(res==EXIT_SUCCESS){ |
438 | 707 printf("PASS: \t%s\n", case_file); |
490 | 708 }else if(res==EXIT_FAILURE && good_error){ |
438 | 709 if(checkErrorMessage(case_file, "", buffer)){ |
499 | 710 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
|
711 }else{ |
622 | 712 printf("ERROR:\t%s%s\n", case_file, 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
|
713 } |
251 | 714 }else{ |
622 | 715 printf("ERROR:\t%s%s\n", case_file, errorMsg(good_error)); |
251 | 716 } |
717 }else{ | |
490 | 718 if(res==EXIT_FAILURE){ |
361 | 719 if(good_error){ |
438 | 720 printf("XFAIL:\t%s\n", case_file); |
361 | 721 }else{ |
622 | 722 printf("FAIL: \t%s%s\n", case_file, errorMsg(good_error)); |
361 | 723 } |
490 | 724 }else if(res==EXIT_SUCCESS){ |
438 | 725 printf("XPASS:\t%s\n", case_file); |
251 | 726 }else{ |
499 | 727 printf("ERROR:\t%s\n", case_file); |
251 | 728 } |
729 } | |
730 fprintf(stderr,"--------\n"); | |
731 }else if(modus==RUN || modus==NORUN){ | |
732 /* gen command */ | |
685 | 733 |
734 bufferLen = strlen(compiler)+strlen(cmd_arg_case) | |
735 +strlen(OBJ) | |
736 +strlen(case_file)*2+strlen(TLOG)+64; | |
737 buffer = malloc(bufferLen); | |
738 snprintf(buffer, bufferLen, "%s %s ", compiler, cmd_arg_case); | |
739 | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
740 if(NULL==strstr(buffer, "-od")){ |
685 | 741 if(NULL==strstr(buffer, "-of")){ |
742 snprintf(buffer, bufferLen, | |
743 "%s %s -od%s -of%s.exe %s 1> %s 2>&1", | |
744 compiler, cmd_arg_case, OBJ, case_file, | |
745 case_file, TLOG); | |
746 }else{ | |
747 snprintf(buffer, bufferLen, | |
748 "%s %s -od%s %s 1> %s 2>&1", | |
749 compiler, cmd_arg_case, OBJ, case_file, | |
750 TLOG); | |
751 } | |
752 }else if(NULL==strstr(buffer, "-of")){ | |
753 snprintf(buffer, bufferLen, | |
754 "%s %s -of%s.exe %s 1> %s 2>&1", | |
755 compiler, cmd_arg_case, case_file, case_file, | |
756 TLOG); | |
757 }else{ | |
758 snprintf(buffer, bufferLen, "%s %s %s 1> %s 2>&1", | |
759 compiler, cmd_arg_case, case_file, TLOG); | |
251 | 760 } |
761 | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
762 /* test 1/3 - compile */ |
251 | 763 if(modus==RUN){ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
764 fprintf(stderr, "run: %s\n", buffer); |
251 | 765 }else{ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
766 fprintf(stderr, "norun: %s\n", buffer); |
251 | 767 } |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
768 res = crashRun(buffer); |
438 | 769 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
770 /* diagnostic 1/3 */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
771 buffer = loadFile(TLOG); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
772 fprintf(stderr, "%s", buffer); |
697 | 773 |
676 | 774 if(modus==RUN){ |
775 good_error = checkErrorMessage(error_file, error_line, buffer); | |
776 }else{ | |
777 good_error = 1; | |
778 } | |
490 | 779 if(hadExecCrash(buffer)){ |
499 | 780 printf("ERROR:\t%s [internal compiler error]\n", case_file); |
251 | 781 fprintf(stderr, "\n--------\n"); |
437 | 782 return EXIT_SUCCESS; |
490 | 783 }else if(res==EXIT_FAILURE && good_error){ |
499 | 784 printf("FAIL: \t%s\n", case_file); |
251 | 785 fprintf(stderr, "\n--------\n"); |
437 | 786 return EXIT_SUCCESS; |
490 | 787 }else if(res!=EXIT_SUCCESS){ |
622 | 788 printf("ERROR:\t%s%s\n", case_file, errorMsg(good_error)); |
251 | 789 fprintf(stderr, "\n--------\n"); |
437 | 790 return EXIT_SUCCESS; |
251 | 791 } |
438 | 792 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
793 /* test 2/3 - run */ |
685 | 794 bufferLen = strlen(case_file) + strlen(TLOG) + 30; |
795 buffer = malloc(bufferLen); | |
796 snprintf(buffer, bufferLen, "%s.exe 1> %s 2>&1\n", case_file, | |
797 TLOG); | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
798 fprintf(stderr, "%s\n", buffer); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
799 res=crashRun(buffer); |
438 | 800 |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
801 /* diagnostic 2/3 */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
802 buffer = loadFile(TLOG); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
803 fprintf(stderr, "%s\n", buffer); |
685 | 804 if(modus==NORUN){ |
805 good_error = checkRuntimeErrorMessage(error_file, error_line, buffer); | |
806 }else{ | |
807 good_error = 1; | |
808 } | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
809 |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
810 #ifdef REG_EXTENDED |
622 | 811 if(!good_gdb){ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
812 /* test 3/3 - gdb */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
813 writeFile(GDB_SCRIPTER, gdb_script); |
685 | 814 bufferLen = strlen(gdb) + strlen(case_file) |
815 + strlen(GDB_SCRIPTER) + strlen(TLOG) + 20; | |
816 snprintf(buffer, bufferLen, "%s %s.exe < %s > %s 2>&1", | |
817 gdb, case_file, GDB_SCRIPTER, TLOG); | |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
818 fprintf(stderr, "%s\n", buffer); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
819 if(EXIT_SUCCESS==crashRun(buffer)){ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
820 /* diagnostic 3/3 */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
821 buffer = loadFile(TLOG); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
822 fprintf(stderr, "%s\n", buffer); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
823 good_gdb = (regexec(gdb_pattern, buffer, 0, NULL, 0)==0); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
824 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
825 } |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
826 #endif /* REG_EXTENDED */ |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
827 |
251 | 828 if(modus==RUN){ |
499 | 829 if(hadExecCrash(buffer)){ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
830 printf("ERROR:\t%s [test case crash]%s%s", case_file, errorMsg(good_error), gdbMsg(good_gdb)); |
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
831 }else if(res==EXIT_SUCCESS && good_gdb){ |
438 | 832 printf("PASS: \t%s\n", case_file); |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
833 }else if(res==EXIT_FAILURE && good_error && good_gdb){ |
499 | 834 printf("FAIL: \t%s\n", case_file); |
251 | 835 }else{ |
620
03ad4005cd8e
POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents:
499
diff
changeset
|
836 printf("ERROR:\t%s%s%s\n", case_file, errorMsg(good_error), gdbMsg(good_gdb)); |
251 | 837 } |
838 }else{ | |
622 | 839 if(res==EXIT_SUCCESS && good_gdb){ |
697 | 840 printf("XPASS:\t%s%s\n", case_file, gdbMsg(good_gdb)); |
622 | 841 }else if(good_error && good_gdb){ |
842 printf("XFAIL:\t%s%s%s\n", case_file, errorMsg(good_error), gdbMsg(good_gdb)); | |
251 | 843 }else{ |
622 | 844 printf("FAIL:\t%s%s%s\n", case_file, errorMsg(good_error), gdbMsg(good_gdb)); |
251 | 845 } |
846 } | |
847 fprintf(stderr, "--------\n"); | |
848 }else{ | |
438 | 849 printf("@bug@ %d (%s)\n", modus, case_file); |
436 | 850 return EXIT_FAILURE; |
251 | 851 } |
436 | 852 return EXIT_SUCCESS; |
251 | 853 } |