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