Mercurial > projects > dstress
annotate dstress.c @ 439:edb0923c9159
cleanup for Linux(gcc)
author | thomask |
---|---|
date | Sun, 17 Apr 2005 10:03:34 +0000 |
parents | 27039d5cbe81 |
children | dc186d1266ba |
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 { | |
439 | 104 fprintf(stderr,"Failed to allocate %zd bytes!\n", size); |
438 | 105 exit(EXIT_FAILURE); |
429 | 106 } |
107 p = malloc(size); | |
108 if (p == NULL) | |
109 { | |
439 | 110 fprintf(stderr,"Failed to allocate %zd 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 } | |
439 | 173 #else |
174 #if WIN32 | |
438 | 175 for(pos=strchr(filename, '/'); pos; pos=strchr(filename, '/')){ |
176 *pos='\\'; | |
177 } | |
178 #else | |
439 | 179 #error no cleanPathSeperator available for this system |
180 #endif /* WIN32 else */ | |
181 #endif /* USE_POSIX else */ | |
438 | 182 return filename; |
183 } | |
184 | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
185 /* Query the environment for the compiler name */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
186 char* getCompiler(){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
187 char* 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 = getenv("dmd"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
190 if(back==NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
191 back = "dmd"; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
192 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
193 } |
438 | 194 return cleanPathSeperator(back); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
195 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
196 |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
197 /* Query the environment for general flags */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
198 char* getGeneralFlags(){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
199 char* back = getenv("DFLAGS"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
200 if(back == NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
201 back = getenv("dflags"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
202 if(back==NULL){ |
432 | 203 back = calloc(1,1); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
204 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
205 } |
438 | 206 return cleanPathSeperator(back); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
207 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
208 |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
209 /* 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
|
210 char* getCaseFlag(const char* data, const char* tag){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
211 char* begin; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
212 char* end1; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
213 char* end2; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
214 char* back; |
438 | 215 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
216 if(data!=NULL && tag!=NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
217 begin = strstr(data, tag); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
218 if(begin!=NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
219 begin = begin+strlen(tag); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
220 end1 = strstr(begin, "\n"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
221 end2 = strstr(begin, "\r"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
222 if(end2!=NULL && ((end1!=NULL && end2<end1) || end1==NULL)){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
223 end1=end2; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
224 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
225 if(end1==NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
226 end1 = begin + strlen(begin); |
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 back = malloc(end1-begin+1); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
229 strncpy(back, begin, end1-begin); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
230 back[end1-begin+1]='\x00'; |
438 | 231 return cleanPathSeperator(back); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
232 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
233 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
234 |
429 | 235 return calloc(1,1); |
339
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 |
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 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
|
240 |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
241 char* file; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
242 char* line; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
243 char* dmd; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
244 char* gdc; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
245 |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
246 int back=0; |
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 /* clean arguments */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
249 if(strcmp(file_, "")!=0){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
250 file = malloc(strlen(file_)+1); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
251 strcpy(file, file_); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
252 }else{ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
253 file=NULL; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
254 } |
438 | 255 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
256 if(strcmp(line_, "")!=0){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
257 line = malloc(strlen(line_)+1); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
258 strcpy(line, line_); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
259 }else{ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
260 line=NULL; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
261 } |
438 | 262 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
263 /* gen patterns*/ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
264 if(file!=NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
265 if(line!=NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
266 dmd = malloc(strlen(file)+strlen(line)+5); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
267 dmd[0]='\x00'; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
268 strcat(dmd, file); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
269 strcat(dmd, "("); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
270 strcat(dmd, line); |
405
7df87732c662
fixed DMD's pattern generator for in-message location
thomask
parents:
373
diff
changeset
|
271 strcat(dmd, ")"); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
272 gdc = malloc(strlen(file)+strlen(line)+4); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
273 gdc[0]='\x00'; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
274 strcat(gdc, file); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
275 strcat(gdc, ":"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
276 strcat(gdc, line); |
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 }else{ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
279 dmd = malloc(strlen(file)+2); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
280 dmd[0]='\x00'; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
281 strcat(dmd, file); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
282 strcat(dmd, "("); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
283 gdc = malloc(strlen(file)+2); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
284 gdc[0]='\x00'; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
285 strcat(gdc, file); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
286 strcat(gdc, ":"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
287 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
288 }else if(line!=NULL){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
289 dmd = malloc(strlen(line)+5); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
290 dmd[0]='\x00'; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
291 strcat(dmd, "("); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
292 strcat(dmd, line); |
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 gdc = malloc(strlen(line)+4); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
295 gdc[0]='\x00'; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
296 strcat(gdc, ":"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
297 strcat(gdc, line); |
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 }else{ |
432 | 300 return 1; |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
301 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
302 |
438 | 303 /* specific error messages */ |
251 | 304 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
305 if( (dmd!=NULL && strstr(buffer, dmd)) |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
306 || (gdc!=NULL && strstr(buffer, gdc)) |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
307 || (dmd==NULL && gdc==NULL)){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
308 back=1; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
309 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
310 |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
311 return back; |
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 |
432 | 314 int checkRuntimeErrorMessage(const char* file_, const char* line_, const char* buffer){ |
438 | 315 /* PhobosLong dir/file.d(2) |
316 * Phobos package.module(2) | |
317 */ | |
432 | 318 |
319 char* file; | |
320 char* line; | |
321 char* phobos; | |
322 char* phobosLong; | |
323 | |
324 char* begin; | |
439 | 325 char* end; |
432 | 326 |
327 int back=0; | |
328 | |
329 /* clean arguments */ | |
330 if(strcmp(file_, "")!=0){ | |
331 file = malloc(strlen(file_)+1); | |
332 strcpy(file, file_); | |
333 }else{ | |
334 file=NULL; | |
335 } | |
438 | 336 |
432 | 337 if(strcmp(line_, "")!=0){ |
338 line = malloc(strlen(line_)+1); | |
339 strcpy(line, line_); | |
340 }else{ | |
341 line=NULL; | |
342 } | |
438 | 343 |
432 | 344 /* gen patterns*/ |
345 if(file!=NULL){ | |
346 if(line!=NULL){ | |
347 phobos = malloc(strlen(file)+strlen(line)+5); | |
348 phobos[0]='\x00'; | |
438 | 349 begin=strrchr(file,'/'); |
350 if(begin){ | |
432 | 351 begin++; |
352 }else{ | |
438 | 353 begin=strrchr(file,'\\'); |
354 if(begin){ | |
355 begin++; | |
356 }else{ | |
357 begin=file; | |
358 } | |
432 | 359 } |
439 | 360 end=strrchr(file,'.'); |
361 strncat(phobos, begin, end-begin); | |
432 | 362 strcat(phobos, "("); |
363 strcat(phobos, line); | |
364 strcat(phobos, ")"); | |
365 | |
366 phobosLong = malloc(strlen(file)+strlen(line)+5); | |
367 phobosLong[0]='\x00'; | |
368 strcat(phobosLong, file); | |
369 strcat(phobosLong, "("); | |
370 strcat(phobosLong, line); | |
371 strcat(phobosLong, ")"); | |
372 | |
373 }else{ | |
374 phobos = malloc(strlen(file)+2); | |
375 phobos[0]='\x00'; | |
438 | 376 begin=strrchr(file,'/'); |
377 if(begin){ | |
432 | 378 begin++; |
379 }else{ | |
438 | 380 begin=strrchr(file,'\\'); |
381 if(begin){ | |
382 begin++; | |
383 }else{ | |
384 begin=file; | |
385 } | |
432 | 386 } |
439 | 387 end=strrchr(file,'.'); |
388 strncat(phobos, begin, end-begin); | |
432 | 389 strcat(phobos, "("); |
390 | |
391 phobosLong = malloc(strlen(file)+2); | |
392 phobosLong[0]='\x00'; | |
393 strcat(phobosLong, file); | |
394 strcat(phobosLong, "("); | |
395 } | |
396 }else if(line!=NULL){ | |
397 phobos = malloc(strlen(line)+3); | |
398 phobos[0]='\x00'; | |
399 strcat(phobos, "("); | |
400 strcat(phobos, line); | |
401 strcat(phobos, ")"); | |
438 | 402 |
432 | 403 phobosLong=NULL; |
404 }else{ | |
405 return 1; | |
406 } | |
407 | |
438 | 408 /* specific error messages */ |
432 | 409 |
410 if( (phobos && strstr(buffer, phobos)) | |
411 || (phobosLong && strstr(buffer, phobosLong))) | |
412 { | |
413 back=1; | |
414 } | |
438 | 415 |
416 return back; | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
417 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
418 |
254 | 419 |
251 | 420 int main(int argc, char* arg[]){ |
438 | 421 char* compiler; /* the compiler - from enviroment flag "DMD" */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
422 char* cmd_arg_general; /* additional arguments - from enviroment flag "DFLAGS" */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
423 char* cmd_arg_case; /* additional arguments - from the testcase file */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
424 char* buffer; /* general purpos buffer */ |
438 | 425 int modus; /* test modus: RUN NORUN COMPILE NOCOMPILE */ |
426 int res; /* return code from external executions */ | |
427 char* case_file; | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
428 char* error_file; /* expected sourcefile containing the error */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
429 char* error_line; /* expected error line */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
430 int good_error; /* error contained file and line and matched the expectations */ |
438 | 431 |
251 | 432 /* check arguments */ |
433 if(argc != 3){ | |
438 | 434 err: |
435 if(argc!=0) | |
251 | 436 fprintf(stderr,"%s <run|norun|compile|nocompile> <source>\n", arg[0]); |
437 else | |
438 | 438 fprintf(stderr,"dstress <run|norun|compile|nocompile> <source>\n"); |
439 exit(EXIT_FAILURE); | |
251 | 440 } |
438 | 441 |
251 | 442 if(0==strcmp(arg[1], "run") || 0==strcmp(arg[1], "RUN")){ |
443 modus = RUN; | |
444 }else if(0==strcmp(arg[1], "norun") || 0==strcmp(arg[1], "NORUN")){ | |
445 modus = NORUN; | |
446 }else if(0==strcmp(arg[1], "compile") || 0==strcmp(arg[1], "COMPILE")){ | |
447 modus = COMPILE; | |
448 }else if(0==strcmp(arg[1], "nocompile") || 0==strcmp(arg[1], "NOCOMPILE")){ | |
449 modus = NOCOMPILE; | |
450 }else{ | |
451 goto err; | |
452 } | |
453 | |
454 /* gen flags */ | |
438 | 455 case_file = cleanPathSeperator(strdup(arg[2])); |
251 | 456 compiler = getCompiler(); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
457 cmd_arg_general = getGeneralFlags(); |
438 | 458 buffer = loadFile(case_file); |
459 | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
460 cmd_arg_case = getCaseFlag(buffer, "__DSTRESS_DFLAGS__"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
461 error_line = getCaseFlag(buffer, "__DSTRESS_ELINE__"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
462 error_file = getCaseFlag(buffer, "__DSTRESS_EFILE__"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
463 |
438 | 464 #if 0 |
465 fprintf(stderr, "case: \"%s\"\n", case_file); | |
466 fprintf(stderr, "compiler: \"%s\"\n", compiler); | |
467 fprintf(stderr, "DFLAGS G: \"%s\"\n", cmd_arg_general); | |
468 fprintf(stderr, "DFLAGS C: \"%s\"\n", cmd_arg_case); | |
469 fprintf(stderr, "ELINE : \"%s\"\n", error_line); | |
470 fprintf(stderr, "EFILE : \"%s\"\n", error_file); | |
471 #endif | |
472 | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
473 /* strip spaces */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
474 while(error_line[0]==' '){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
475 error_line++; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
476 } |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
477 for(buffer=error_line+strlen(error_line)-1; buffer && buffer[0]==' '; buffer=error_line+strlen(error_line)-1){ |
438 | 478 buffer[0]='\x00'; |
339
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 while(error_file[0]==' '){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
481 error_file++; |
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 for(buffer=error_file+strlen(error_file)-1; buffer && buffer[0]==' '; buffer=error_file+strlen(error_file)-1){ |
438 | 484 buffer[0]='\x00'; |
251 | 485 } |
486 | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
487 /* set implicit source file */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
488 if(strcmp(error_line, "")!=0 && strcmp(error_file, "")==0){ |
438 | 489 error_file=case_file; |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
490 } |
438 | 491 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
492 /* start working */ |
251 | 493 if(modus==COMPILE || modus==NOCOMPILE){ |
494 /* gen command */ | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
495 buffer = malloc(strlen(compiler)+strlen(cmd_arg_general)+strlen(cmd_arg_case)+strlen(OBJ) |
438 | 496 +strlen(case_file)+strlen(TLOG)+64); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
497 buffer[0]='\x00'; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
498 strcat(buffer, compiler); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
499 strcat(buffer, " "); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
500 strcat(buffer, cmd_arg_general); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
501 strcat(buffer, " "); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
502 strcat(buffer, cmd_arg_case); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
503 strcat(buffer, " -c "); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
504 if(NULL==strstr(buffer, "-od")){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
505 strcat(buffer, OBJ); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
506 strcat(buffer, " "); |
251 | 507 } |
438 | 508 strcat(buffer, case_file); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
509 strcat(buffer, " 1> "); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
510 strcat(buffer, TLOG); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
511 strcat(buffer, " 2>&1"); |
251 | 512 |
513 /* test */ | |
514 if(modus==COMPILE){ | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
515 fprintf(stderr, "compile: %s\n", buffer); |
251 | 516 }else{ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
517 fprintf(stderr, "nocompile: %s\n", buffer); |
251 | 518 } |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
519 res = crashRun(buffer); |
251 | 520 |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
521 /* diagnostic */ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
522 buffer = loadFile(TLOG); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
523 fprintf(stderr, "%s\n", buffer); |
438 | 524 good_error = checkErrorMessage(error_file, error_line, buffer); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
525 |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
526 if(strstr(buffer, "Internal error")!= NULL || strstr(buffer, "gcc.gnu.org/bugs")!=NULL){ |
438 | 527 printf("ERROR:\t%s (Internal compiler error)\n", case_file); |
251 | 528 }else if(modus==COMPILE){ |
438 | 529 if(res==SHELL_RETURN_OK){ |
530 printf("PASS: \t%s\n", case_file); | |
531 }else if(res==SHELL_RETURN_FAIL && good_error){ | |
532 if(checkErrorMessage(case_file, "", buffer)){ | |
533 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
|
534 }else{ |
438 | 535 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
|
536 } |
437 | 537 }else if(good_error){ |
438 | 538 printf("ERROR:\t%s [%d]\n", case_file, res); |
251 | 539 }else{ |
438 | 540 printf("ERROR:\t%s [%d] [bad error message]\n", case_file, res); |
251 | 541 } |
542 }else{ | |
438 | 543 if(res==SHELL_RETURN_FAIL){ |
361 | 544 if(good_error){ |
438 | 545 printf("XFAIL:\t%s\n", case_file); |
361 | 546 }else{ |
438 | 547 printf("FAIL: \t%s [bad error message]\n", case_file); |
361 | 548 } |
438 | 549 }else if(res==SHELL_RETURN_OK){ |
550 printf("XPASS:\t%s\n", case_file); | |
251 | 551 }else{ |
438 | 552 printf("ERROR:\t%s [%d]\n", case_file, res); |
251 | 553 } |
554 } | |
555 fprintf(stderr,"--------\n"); | |
556 }else if(modus==RUN || modus==NORUN){ | |
557 /* gen command */ | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
558 buffer = malloc(strlen(compiler)+strlen(cmd_arg_general)+strlen(cmd_arg_case)+strlen(OBJ) |
438 | 559 +strlen(case_file)*2+strlen(TLOG)+64); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
560 buffer[0]='\x00'; |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
561 strcat(buffer, compiler); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
562 strcat(buffer, " "); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
563 strcat(buffer, cmd_arg_general); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
564 strcat(buffer, " "); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
565 strcat(buffer, cmd_arg_case); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
566 strcat(buffer, " "); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
567 if(NULL==strstr(buffer, "-od")){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
568 strcat(buffer, OBJ); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
569 strcat(buffer, " "); |
251 | 570 } |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
571 if(NULL==strstr(buffer, "-of")){ |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
572 strcat(buffer, "-of"); |
438 | 573 strcat(buffer, case_file); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
574 strcat(buffer, ".exe "); |
251 | 575 } |
438 | 576 strcat(buffer, case_file); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
577 strcat(buffer, " 1> "); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
578 strcat(buffer, TLOG); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
579 strcat(buffer, " 2>&1"); |
251 | 580 |
581 /* test 1/2 */ | |
582 if(modus==RUN){ | |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
583 fprintf(stderr, "run: %s\n", buffer); |
251 | 584 }else{ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
585 fprintf(stderr, "norun: %s\n", buffer); |
251 | 586 } |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
587 res = crashRun(buffer); |
438 | 588 |
251 | 589 /* diagnostic 1/2 */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
590 buffer = loadFile(TLOG); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
591 fprintf(stderr, "%s", buffer); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
592 good_error = checkErrorMessage(error_file, error_line, buffer); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
593 if(strstr(buffer, "Internal error")!= NULL || strstr(buffer, "gcc.gnu.org/bugs")!=NULL){ |
438 | 594 printf("ERROR:\t%s (Internal compiler error)\n", case_file); |
251 | 595 fprintf(stderr, "\n--------\n"); |
437 | 596 return EXIT_SUCCESS; |
438 | 597 }else if(res==SHELL_RETURN_FAIL && good_error){ |
598 printf("FAIL: \t%s [%d]\n", case_file, res); | |
251 | 599 fprintf(stderr, "\n--------\n"); |
437 | 600 return EXIT_SUCCESS; |
438 | 601 }else if(res!=SHELL_RETURN_OK){ |
437 | 602 if(good_error){ |
438 | 603 printf("ERROR:\t%s [%d]\n", case_file, res); |
437 | 604 }else{ |
438 | 605 printf("ERROR:\t%s [%d] [bad error message]\n", case_file, res); |
437 | 606 } |
251 | 607 fprintf(stderr, "\n--------\n"); |
437 | 608 return EXIT_SUCCESS; |
251 | 609 } |
438 | 610 |
251 | 611 /* test 2/2 */ |
438 | 612 buffer = malloc(strlen(case_file) + strlen(TLOG) + 24); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
613 *buffer = '\x00'; |
438 | 614 strcat(buffer, case_file); |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
615 strcat(buffer, ".exe 1> "); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
616 strcat(buffer, TLOG); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
617 strcat(buffer, " 2>&1"); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
618 fprintf(stderr, "%s\n", buffer); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
619 res=crashRun(buffer); |
438 | 620 |
251 | 621 /* diagnostic 2/2 */ |
339
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
622 buffer = loadFile(TLOG); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
623 fprintf(stderr, "%s\n", buffer); |
a74c84e75682
added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents:
292
diff
changeset
|
624 good_error = checkRuntimeErrorMessage(error_file, error_line, buffer); |
251 | 625 if(modus==RUN){ |
438 | 626 if(res==SHELL_RETURN_OK){ |
627 printf("PASS: \t%s\n", case_file); | |
628 }else if(res==SHELL_RETURN_FAIL && good_error){ | |
629 printf("FAIL: \t%s [run: %d]\n", case_file, res); | |
251 | 630 }else{ |
437 | 631 if(good_error){ |
438 | 632 printf("ERROR:\t%s [run: %d]\n", case_file, res); |
437 | 633 }else{ |
438 | 634 printf("ERROR:\t%s [run: %d] [bad error message]\n", case_file, res); |
437 | 635 } |
251 | 636 } |
637 }else{ | |
438 | 638 if(res==SHELL_RETURN_FAIL){ |
361 | 639 if(good_error){ |
438 | 640 printf("XFAIL:\t%s\n", case_file); |
361 | 641 }else{ |
438 | 642 printf("FAIL: \t%s [bad errror message]\n", case_file); |
361 | 643 } |
438 | 644 }else if(res==SHELL_RETURN_OK){ |
645 printf("XPASS:\t%s [norun: %d]\n", case_file, res); | |
251 | 646 }else{ |
438 | 647 printf("ERROR:\t%s [norun: %d]\n", case_file, res); |
251 | 648 } |
649 } | |
650 fprintf(stderr, "--------\n"); | |
651 }else{ | |
438 | 652 printf("@bug@ %d (%s)\n", modus, case_file); |
436 | 653 return EXIT_FAILURE; |
251 | 654 } |
436 | 655 return EXIT_SUCCESS; |
251 | 656 } |