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