annotate dstress.c @ 439:edb0923c9159

cleanup for Linux(gcc)
author thomask
date Sun, 17 Apr 2005 10:03:34 +0000
parents 27039d5cbe81
children dc186d1266ba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1 /*
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
2 * core test tool for the DStress test suite
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
3 * http://dstress.kuehne.cn
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
4 *
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
5 * Copyright (C) 2005 Thomas Kuehne <thomas@kuehne.cn>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
6 *
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
10 * (at your option) any later version.
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
11 *
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
15 * GNU General Public License for more details.
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
16 *
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
20 *
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
21 * $HeadURL$
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
22 * $Date$
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
23 * $Author$
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
24 *
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
25 */
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
26
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
27 /* Beware: the code doesn't care about freeing allocated memory etc... */
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
28
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
29 #include <stdlib.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
30 #include <stdio.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
31 #include <string.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
32 #include <errno.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
33
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
34 #define TAG "__DSTRESS_DFLAGS__"
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
35 #define OBJ "-odobj "
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
36 #define TLOG "log.tmp"
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
37
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
38 #define RUN 1
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
39 #define NORUN 2
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
40 #define COMPILE 4
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
41 #define NOCOMPILE 8
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
42
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
43 #ifdef __GNU_LIBRARY__
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
44 #define USE_POSIX
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
45 #endif
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
46
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
47 #ifdef __GLIBC__
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
48 #define USE_POSIX
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
49 #endif
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
50
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
51 #ifdef linux
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
52 #define USE_POSIX
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
53 #endif
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
54
273
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
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
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
57 #endif
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
58
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
59 #ifdef __FreeBSD__
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
60 #define USE_POSIX
273
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
61 #endif
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
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
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
65
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
66 #define SHELL_RETURN_OK 0
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
69
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
70 #include <sys/types.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
71 #include <sys/stat.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
72 #include <fcntl.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
73 #include <unistd.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
74 char* loadFile(char* filename){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
75 char* back = NULL;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
76 struct stat fileInfo;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
77 int file = open(filename, O_RDONLY);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
78 if(errno == 0 && file != 0 && file != -1){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
79 if(0==fstat(file, &fileInfo)){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
80 back=malloc(fileInfo.st_size+1);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
81 fileInfo.st_size = read(file, back, fileInfo.st_size);
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
82 if(fileInfo.st_size>0){
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
83 *(back+fileInfo.st_size+1) = '\x00';
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
84 }else{
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
85 back = NULL;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
86 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
87 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
88 close(file);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
89 }
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
90
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
91 if(back){
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
92 return back;
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
93 }
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
94
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
95 fprintf(stderr, "File not found \"%s\"\n", filename);
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
96 exit(EXIT_FAILURE);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
97 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
98
429
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
99 void *xmalloc(size_t size)
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
100 {
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
101 void *p;
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
102 if (p < 0)
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
103 {
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
104 fprintf(stderr,"Failed to allocate %zd bytes!\n", size);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
105 exit(EXIT_FAILURE);
429
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
106 }
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
107 p = malloc(size);
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
108 if (p == NULL)
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
109 {
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
110 fprintf(stderr,"Failed to allocate %zd bytes!\n", size);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
111 exit(EXIT_FAILURE);
429
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
112 }
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
113 return p;
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
114 }
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
115
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
116 #define malloc xmalloc
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
117
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
118 #else
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
119
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
120 #ifdef WIN32
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
121
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
122 #define SHELL_RETURN_OK 0
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
123 #define SHELL_RETURN_FAIL 1
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
124
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
125 #include <windows.h>
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
126 char* loadFile(char* filename){
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
127 char* back=NULL;
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
128 DWORD size, numread;
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
129 HANDLE file=CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
130 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
131 if (file != INVALID_HANDLE_VALUE){
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
132 size = GetFileSize(file, NULL);
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
133 if (size != INVALID_FILE_SIZE){
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
134 back=malloc((size+1)*sizeof(char));
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
135 if (ReadFile(file,back,size,&numread,NULL) == 1){
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
136 if (numread==size){
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
137 *(back+size+1) = '\x00';
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
138 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
139 back = NULL;
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
140 }
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
141 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
142 back = NULL;
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
143 }
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
144 }
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
145 CloseHandle(file);
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
146 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
147 if(back){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
148 errno = 0;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
149 return back;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
150 }
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
151
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
152 fprintf(stderr, "File not found \"%s\"\n", filename);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
153 exit(EXIT_FAILURE);
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
154 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
157 #else
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
158 #error no loadFile adaptation available for this system
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
159
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
160 /* like system(char*) but has to return without human intervention even if the application segfaults */
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
161 #error no crashRun adaptation available for this system
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
166 /* cleanup "/" versus "\" in filenames */
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
167 char* cleanPathSeperator(char* filename){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
168 char* pos;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
169 #ifdef USE_POSIX
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
170 for(pos=strchr(filename, '\\'); pos; pos=strchr(filename, '\\')){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
171 *pos='/';
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
172 }
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
173 #else
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
174 #if WIN32
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
175 for(pos=strchr(filename, '/'); pos; pos=strchr(filename, '/')){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
176 *pos='\\';
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
177 }
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
178 #else
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
179 #error no cleanPathSeperator available for this system
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
180 #endif /* WIN32 else */
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
181 #endif /* USE_POSIX else */
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
182 return filename;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
183 }
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
303 /* specific error messages */
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
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
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
314 int checkRuntimeErrorMessage(const char* file_, const char* line_, const char* buffer){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
315 /* PhobosLong dir/file.d(2)
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
316 * Phobos package.module(2)
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
317 */
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
318
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
319 char* file;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
320 char* line;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
321 char* phobos;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
322 char* phobosLong;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
323
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
324 char* begin;
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
325 char* end;
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
326
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
327 int back=0;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
328
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
329 /* clean arguments */
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
330 if(strcmp(file_, "")!=0){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
331 file = malloc(strlen(file_)+1);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
332 strcpy(file, file_);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
333 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
334 file=NULL;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
335 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
336
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
337 if(strcmp(line_, "")!=0){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
338 line = malloc(strlen(line_)+1);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
339 strcpy(line, line_);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
340 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
341 line=NULL;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
342 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
343
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
344 /* gen patterns*/
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
345 if(file!=NULL){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
346 if(line!=NULL){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
347 phobos = malloc(strlen(file)+strlen(line)+5);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
348 phobos[0]='\x00';
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
349 begin=strrchr(file,'/');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
350 if(begin){
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
351 begin++;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
352 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
353 begin=strrchr(file,'\\');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
354 if(begin){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
355 begin++;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
356 }else{
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
357 begin=file;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
358 }
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
359 }
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
360 end=strrchr(file,'.');
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
361 strncat(phobos, begin, end-begin);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
362 strcat(phobos, "(");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
363 strcat(phobos, line);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
364 strcat(phobos, ")");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
365
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
366 phobosLong = malloc(strlen(file)+strlen(line)+5);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
367 phobosLong[0]='\x00';
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
368 strcat(phobosLong, file);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
369 strcat(phobosLong, "(");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
370 strcat(phobosLong, line);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
371 strcat(phobosLong, ")");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
372
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
373 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
374 phobos = malloc(strlen(file)+2);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
375 phobos[0]='\x00';
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
376 begin=strrchr(file,'/');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
377 if(begin){
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
378 begin++;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
379 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
380 begin=strrchr(file,'\\');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
381 if(begin){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
382 begin++;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
383 }else{
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
384 begin=file;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
385 }
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
386 }
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
387 end=strrchr(file,'.');
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
388 strncat(phobos, begin, end-begin);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
389 strcat(phobos, "(");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
390
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
391 phobosLong = malloc(strlen(file)+2);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
392 phobosLong[0]='\x00';
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
393 strcat(phobosLong, file);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
394 strcat(phobosLong, "(");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
395 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
396 }else if(line!=NULL){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
397 phobos = malloc(strlen(line)+3);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
398 phobos[0]='\x00';
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
399 strcat(phobos, "(");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
400 strcat(phobos, line);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
401 strcat(phobos, ")");
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
402
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
403 phobosLong=NULL;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
404 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
405 return 1;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
406 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
407
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
408 /* specific error messages */
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
409
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
410 if( (phobos && strstr(buffer, phobos))
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
411 || (phobosLong && strstr(buffer, phobosLong)))
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
412 {
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
413 back=1;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
414 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
415
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
419
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
420 int main(int argc, char* arg[]){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
425 int modus; /* test modus: RUN NORUN COMPILE NOCOMPILE */
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
426 int res; /* return code from external executions */
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
431
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
432 /* check arguments */
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
433 if(argc != 3){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
434 err:
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
435 if(argc!=0)
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
436 fprintf(stderr,"%s <run|norun|compile|nocompile> <source>\n", arg[0]);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
437 else
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
438 fprintf(stderr,"dstress <run|norun|compile|nocompile> <source>\n");
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
439 exit(EXIT_FAILURE);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
440 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
441
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
442 if(0==strcmp(arg[1], "run") || 0==strcmp(arg[1], "RUN")){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
443 modus = RUN;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
444 }else if(0==strcmp(arg[1], "norun") || 0==strcmp(arg[1], "NORUN")){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
445 modus = NORUN;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
446 }else if(0==strcmp(arg[1], "compile") || 0==strcmp(arg[1], "COMPILE")){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
447 modus = COMPILE;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
448 }else if(0==strcmp(arg[1], "nocompile") || 0==strcmp(arg[1], "NOCOMPILE")){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
449 modus = NOCOMPILE;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
450 }else{
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
451 goto err;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
452 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
453
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
454 /* gen flags */
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
455 case_file = cleanPathSeperator(strdup(arg[2]));
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
456 compiler = getCompiler();
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
457 cmd_arg_general = getGeneralFlags();
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
458 buffer = loadFile(case_file);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
464 #if 0
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
465 fprintf(stderr, "case: \"%s\"\n", case_file);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
466 fprintf(stderr, "compiler: \"%s\"\n", compiler);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
467 fprintf(stderr, "DFLAGS G: \"%s\"\n", cmd_arg_general);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
468 fprintf(stderr, "DFLAGS C: \"%s\"\n", cmd_arg_case);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
469 fprintf(stderr, "ELINE : \"%s\"\n", error_line);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
470 fprintf(stderr, "EFILE : \"%s\"\n", error_file);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
471 #endif
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
484 buffer[0]='\x00';
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
485 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
489 error_file=case_file;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
490 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
491
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
492 /* start working */
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
493 if(modus==COMPILE || modus==NOCOMPILE){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
507 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
512
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
513 /* test */
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
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
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
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
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
518 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
519 res = crashRun(buffer);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
527 printf("ERROR:\t%s (Internal compiler error)\n", case_file);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
528 }else if(modus==COMPILE){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
529 if(res==SHELL_RETURN_OK){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
530 printf("PASS: \t%s\n", case_file);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
531 }else if(res==SHELL_RETURN_FAIL && good_error){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
532 if(checkErrorMessage(case_file, "", buffer)){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
537 }else if(good_error){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
538 printf("ERROR:\t%s [%d]\n", case_file, res);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
539 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
540 printf("ERROR:\t%s [%d] [bad error message]\n", case_file, res);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
541 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
542 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
543 if(res==SHELL_RETURN_FAIL){
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
544 if(good_error){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
545 printf("XFAIL:\t%s\n", case_file);
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
546 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
547 printf("FAIL: \t%s [bad error message]\n", case_file);
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
548 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
549 }else if(res==SHELL_RETURN_OK){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
550 printf("XPASS:\t%s\n", case_file);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
551 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
552 printf("ERROR:\t%s [%d]\n", case_file, res);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
553 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
554 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
555 fprintf(stderr,"--------\n");
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
556 }else if(modus==RUN || modus==NORUN){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
575 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
580
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
581 /* test 1/2 */
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
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
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
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
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
586 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
587 res = crashRun(buffer);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
588
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
594 printf("ERROR:\t%s (Internal compiler error)\n", case_file);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
595 fprintf(stderr, "\n--------\n");
437
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
596 return EXIT_SUCCESS;
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
597 }else if(res==SHELL_RETURN_FAIL && good_error){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
598 printf("FAIL: \t%s [%d]\n", case_file, res);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
599 fprintf(stderr, "\n--------\n");
437
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
600 return EXIT_SUCCESS;
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
601 }else if(res!=SHELL_RETURN_OK){
437
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
602 if(good_error){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
603 printf("ERROR:\t%s [%d]\n", case_file, res);
437
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
604 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
605 printf("ERROR:\t%s [%d] [bad error message]\n", case_file, res);
437
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
606 }
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
607 fprintf(stderr, "\n--------\n");
437
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
608 return EXIT_SUCCESS;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
609 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
610
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
611 /* test 2/2 */
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
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
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
620
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
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
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
625 if(modus==RUN){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
626 if(res==SHELL_RETURN_OK){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
627 printf("PASS: \t%s\n", case_file);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
628 }else if(res==SHELL_RETURN_FAIL && good_error){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
629 printf("FAIL: \t%s [run: %d]\n", case_file, res);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
630 }else{
437
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
631 if(good_error){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
632 printf("ERROR:\t%s [run: %d]\n", case_file, res);
437
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
633 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
634 printf("ERROR:\t%s [run: %d] [bad error message]\n", case_file, res);
437
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
635 }
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
636 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
637 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
638 if(res==SHELL_RETURN_FAIL){
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
639 if(good_error){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
640 printf("XFAIL:\t%s\n", case_file);
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
641 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
642 printf("FAIL: \t%s [bad errror message]\n", case_file);
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
643 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
644 }else if(res==SHELL_RETURN_OK){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
645 printf("XPASS:\t%s [norun: %d]\n", case_file, res);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
646 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
647 printf("ERROR:\t%s [norun: %d]\n", case_file, res);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
648 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
649 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
650 fprintf(stderr, "--------\n");
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
651 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
652 printf("@bug@ %d (%s)\n", modus, case_file);
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
653 return EXIT_FAILURE;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
654 }
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
655 return EXIT_SUCCESS;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
656 }