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