annotate dstress.c @ 436:5e210bace0f1

added "File not found" clause
author thomask
date Sat, 16 Apr 2005 11:24:56 +0000
parents db4b6169a99d
children 1b4034b27e93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1 /*
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
2 * core test tool for the DStress test suite
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 *
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
25 */
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
26
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
27 // Beware: the code doesn't care about freeing allocated memory
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
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
66 #define RETURN_OK 0
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
67 #define 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 {
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
104 fprintf(stderr,"Failed to allocate %ld bytes!\n", size);
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
105 exit(1);
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 {
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
110 fprintf(stderr,"Failed to allocate %ld bytes!\n", size);
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
111 exit(1);
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
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
122 #define RETURN_OK 0
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
123 #define RETURN_FAIL 1
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{
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
139 back = "\x00";
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{
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
142 back = "\x00";
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 }
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
147 errno = 0;
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
148 return back;
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
149 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
150 #error no crashRun adaptation for this system available
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
151
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
152 #else
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
153 #error no loadFile adaptation for this system available
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
154 #error no crashRun adaptation for this system available /* like system(char*) but has to return without human intervention even if the application segfaults */
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
155
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
156 #endif /* WIN32 else */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
157 #endif /* USE_POSIX else */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
158
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
159 /* Query the environment for the compiler name */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
160 char* getCompiler(){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
161 char* back = getenv("DMD");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
162 if(back == NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
163 back = getenv("dmd");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
164 if(back==NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
165 back = "dmd";
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
166 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
167 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
168 return back;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
169 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
170
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
171 /* Query the environment for general flags */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
172 char* getGeneralFlags(){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
173 char* back = getenv("DFLAGS");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
174 if(back == NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
175 back = getenv("dflags");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
176 if(back==NULL){
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
177 back = calloc(1,1);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
178 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
179 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
180 return back;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
181 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
182
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
183 /* 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
184 char* getCaseFlag(const char* data, const char* tag){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
185 char* begin;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
186 char* end1;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
187 char* end2;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
188 char* back;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
189
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
190 if(data!=NULL && tag!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
191 begin = strstr(data, tag);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
192 if(begin!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
193 begin = begin+strlen(tag);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
194 end1 = strstr(begin, "\n");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
195 end2 = strstr(begin, "\r");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
196 if(end2!=NULL && ((end1!=NULL && end2<end1) || end1==NULL)){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
197 end1=end2;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
198 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
199 if(end1==NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
200 end1 = begin + strlen(begin);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
201 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
202 back = malloc(end1-begin+1);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
203 strncpy(back, begin, end1-begin);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
204 back[end1-begin+1]='\x00';
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
205 return back;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
206 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
207 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
208
429
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
209 return calloc(1,1);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
210 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
211
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
212
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
213 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
214
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
215 char* file;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
216 char* line;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
217 char* dmd;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
218 char* gdc;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
219
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
220 char* begin;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
221 char* end1;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
222 char* end2;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
223
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
224 int back=0;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
225
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
226 /* clean arguments */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
227 if(strcmp(file_, "")!=0){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
228 file = malloc(strlen(file_)+1);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
229 strcpy(file, file_);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
230 }else{
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
231 file=NULL;
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 if(strcmp(line_, "")!=0){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
235 line = malloc(strlen(line_)+1);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
236 strcpy(line, line_);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
237 }else{
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
238 line=NULL;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
239 }
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 /* gen patterns*/
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
242 if(file!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
243 if(line!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
244 dmd = malloc(strlen(file)+strlen(line)+5);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
245 dmd[0]='\x00';
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
246 strcat(dmd, file);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
247 strcat(dmd, "(");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
248 strcat(dmd, line);
405
7df87732c662 fixed DMD's pattern generator for in-message location
thomask
parents: 373
diff changeset
249 strcat(dmd, ")");
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
250 gdc = malloc(strlen(file)+strlen(line)+4);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
251 gdc[0]='\x00';
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
252 strcat(gdc, file);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
253 strcat(gdc, ":");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
254 strcat(gdc, line);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
255 strcat(gdc, ": ");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
256 }else{
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
257 dmd = malloc(strlen(file)+2);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
258 dmd[0]='\x00';
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
259 strcat(dmd, file);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
260 strcat(dmd, "(");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
261 gdc = malloc(strlen(file)+2);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
262 gdc[0]='\x00';
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
263 strcat(gdc, file);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
264 strcat(gdc, ":");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
265 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
266 }else if(line!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
267 dmd = malloc(strlen(line)+5);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
268 dmd[0]='\x00';
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);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
271 strcat(dmd, "): ");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
272 gdc = malloc(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, ":");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
275 strcat(gdc, line);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
276 strcat(gdc, ": ");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
277 }else{
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
278 return 1;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
279 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
280
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
281 /* fix filenames */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
282 #ifdef WIN32
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
283 end1="/";
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
284 end2="\\";
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
285 #else
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
286 end1="\\";
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
287 end2="/";
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
288 #endif
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
289
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
290 if(dmd!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
291 while( (begin=strchr(dmd, end1[0])) ){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
292 begin[0]=end2[0];
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
293 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
294 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
295
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
296 if(gdc!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
297 while( (begin=strchr(gdc, end1[0])) ){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
298 begin[0]=end2[0];
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
299 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
300 }
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 /* specific error messages */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
303
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
304 if( (dmd!=NULL && strstr(buffer, dmd))
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
305 || (gdc!=NULL && strstr(buffer, gdc))
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
306 || (dmd==NULL && gdc==NULL)){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
307 back=1;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
308 }
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 return back;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
311 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
312
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
313 int checkRuntimeErrorMessage(const char* file_, const char* line_, const char* buffer){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
314 // Phobos(dmd & gdc): dir/file.d(2)
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
315
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
316 char* file;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
317 char* line;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
318 char* phobos;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
319 char* phobosLong;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
320
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
321 char* begin;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
322 char* end1;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
323 char* end2;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
324
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
325 int back=0;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
326
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
327 /* clean arguments */
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
328 if(strcmp(file_, "")!=0){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
329 file = malloc(strlen(file_)+1);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
330 strcpy(file, file_);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
331 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
332 file=NULL;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
333 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
334
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
335 if(strcmp(line_, "")!=0){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
336 line = malloc(strlen(line_)+1);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
337 strcpy(line, line_);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
338 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
339 line=NULL;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
340 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
341
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
342 /* gen patterns*/
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
343 if(file!=NULL){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
344 if(line!=NULL){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
345 phobos = malloc(strlen(file)+strlen(line)+5);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
346 phobos[0]='\x00';
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
347 if(begin=rindex(file,'/')){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
348 begin++;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
349 }else if(begin=rindex(file,'\\')){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
350 begin++;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
351 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
352 begin=file;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
353 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
354 end1=rindex(file,'.');
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
355 strncat(phobos, begin, end1-begin);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
356 strcat(phobos, "(");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
357 strcat(phobos, line);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
358 strcat(phobos, ")");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
359
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
360 phobosLong = malloc(strlen(file)+strlen(line)+5);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
361 phobosLong[0]='\x00';
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
362 strcat(phobosLong, file);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
363 strcat(phobosLong, "(");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
364 strcat(phobosLong, line);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
365 strcat(phobosLong, ")");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
366
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
367 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
368 phobos = malloc(strlen(file)+2);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
369 phobos[0]='\x00';
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
370 if(begin=rindex(file,'/')){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
371 begin++;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
372 }else if(begin=rindex(file,'\\')){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
373 begin++;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
374 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
375 begin=file;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
376 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
377 end1=rindex(file,'.');
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
378 strncat(phobos, begin, end1-begin);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
379 strcat(phobos, "(");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
380
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
381 phobosLong = malloc(strlen(file)+2);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
382 phobosLong[0]='\x00';
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
383 strcat(phobosLong, file);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
384 strcat(phobosLong, "(");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
385 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
386 }else if(line!=NULL){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
387 phobos = malloc(strlen(line)+3);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
388 phobos[0]='\x00';
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
389 strcat(phobos, "(");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
390 strcat(phobos, line);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
391 strcat(phobos, ")");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
392
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
393 phobosLong=NULL;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
394 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
395 return 1;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
396 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
397
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
398 /* fix filenames */
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
399 #ifdef WIN32
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
400 end1="/";
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
401 end2="\\";
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
402 #else
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
403 end1="\\";
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
404 end2="/";
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
405 #endif
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
406
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
407 if(phobos){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
408 while( (begin=strchr(phobos, end1[0])) ){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
409 begin[0]=end2[0];
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
410 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
411 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
412
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
413 if(phobosLong){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
414 while( (begin=strchr(phobosLong, end1[0])) ){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
415 begin[0]=end2[0];
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
416 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
417 while(phobosLong[0]==end2[0]){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
418 phobosLong++;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
419 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
420 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
421 /* specific error messages */
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
422
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
423 if( (phobos && strstr(buffer, phobos))
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
424 || (phobosLong && strstr(buffer, phobosLong)))
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
425 {
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
426 back=1;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
427 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
428
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
429 return back;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
430 return 1;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
431 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
432
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
433
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
434 int main(int argc, char* arg[]){
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
435 char* compiler; /* the compiler */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
436 char* cmd_arg_general; /* additional arguments - from enviroment flag "DFLAGS" */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
437 char* cmd_arg_case; /* additional arguments - from the testcase file */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
438 char* buffer; /* general purpos buffer */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
439 int modus; /* test modus: RUN NORUN COMPILE NOCOMPILE */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
440 int res; /* return code from external executions */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
441 char* error_file; /* expected sourcefile containing the error */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
442 char* error_line; /* expected error line */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
443 int good_error; /* error contained file and line and matched the expectations */
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
444
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
445 /* check arguments */
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
446 if(argc != 3){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
447 err: if(argc!=0)
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
448 fprintf(stderr,"%s <run|norun|compile|nocompile> <source>\n", arg[0]);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
449 else
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
450 fprintf(stderr,"dstress.exe <run|norun|compile|nocompile> <source>\n");
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
451 exit(-1);
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 if(0==strcmp(arg[1], "run") || 0==strcmp(arg[1], "RUN")){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
455 modus = RUN;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
456 }else if(0==strcmp(arg[1], "norun") || 0==strcmp(arg[1], "NORUN")){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
457 modus = NORUN;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
458 }else if(0==strcmp(arg[1], "compile") || 0==strcmp(arg[1], "COMPILE")){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
459 modus = COMPILE;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
460 }else if(0==strcmp(arg[1], "nocompile") || 0==strcmp(arg[1], "NOCOMPILE")){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
461 modus = NOCOMPILE;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
462 }else{
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
463 goto err;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
464 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
465
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
466 /* gen flags */
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
467 compiler = getCompiler();
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
468 cmd_arg_general = getGeneralFlags();
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
469 buffer = loadFile(arg[2]);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
470
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
471 cmd_arg_case = getCaseFlag(buffer, "__DSTRESS_DFLAGS__");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
472 error_line = getCaseFlag(buffer, "__DSTRESS_ELINE__");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
473 error_file = getCaseFlag(buffer, "__DSTRESS_EFILE__");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
474
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
475 /* strip spaces */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
476 while(error_line[0]==' '){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
477 error_line++;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
478 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
479 for(buffer=error_line+strlen(error_line)-1; buffer && buffer[0]==' '; buffer=error_line+strlen(error_line)-1){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
480 buffer[0]='\x00';
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
481 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
482 while(error_file[0]==' '){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
483 error_file++;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
484 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
485 for(buffer=error_file+strlen(error_file)-1; buffer && buffer[0]==' '; buffer=error_file+strlen(error_file)-1){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
486 buffer[0]='\x00';
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
487 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
488
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
489 /* set implicit source file */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
490 if(strcmp(error_line, "")!=0 && strcmp(error_file, "")==0){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
491 error_file=arg[2];
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
492 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
493
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
494 /* start working */
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
495 if(modus==COMPILE || modus==NOCOMPILE){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
496 /* gen command */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
497 buffer = malloc(strlen(compiler)+strlen(cmd_arg_general)+strlen(cmd_arg_case)+strlen(OBJ)
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
498 +strlen(arg[2])+strlen(TLOG)+64);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
499 buffer[0]='\x00';
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
500 strcat(buffer, compiler);
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_general);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
503 strcat(buffer, " ");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
504 strcat(buffer, cmd_arg_case);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
505 strcat(buffer, " -c ");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
506 if(NULL==strstr(buffer, "-od")){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
507 strcat(buffer, OBJ);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
508 strcat(buffer, " ");
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
509 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
510 strcat(buffer, arg[2]);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
511 strcat(buffer, " 1> ");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
512 strcat(buffer, TLOG);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
513 strcat(buffer, " 2>&1");
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
514
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
515 /* test */
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
516 if(modus==COMPILE){
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
517 fprintf(stderr, "compile: %s\n", buffer);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
518 }else{
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
519 fprintf(stderr, "nocompile: %s\n", 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 res = crashRun(buffer);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
522
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
523 /* diagnostic */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
524 buffer = loadFile(TLOG);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
525 fprintf(stderr, "%s\n", buffer);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
526 good_error = checkErrorMessage(error_file, error_line, buffer);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
527
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
528 if(strstr(buffer, "Internal error")!= NULL || strstr(buffer, "gcc.gnu.org/bugs")!=NULL){
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
529 printf("ERROR:\t%s (Internal compiler error)\n", arg[2]);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
530 }else if(modus==COMPILE){
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
531 if(res==RETURN_OK){
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
532 printf("PASS: \t%s\n", arg[2]);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
533 }else if(res==RETURN_FAIL && good_error){
373
177ce8d13eac test cases that unexpectetly fail and in addition fail to provide file/line information are now treated as ERROR instead of FAIL
thomask
parents: 361
diff changeset
534 if(checkErrorMessage(arg[2], "", buffer)){
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
535 printf("FAIL: \t%s [%d]\n", arg[2], res);
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 }else{
177ce8d13eac test cases that unexpectetly fail and in addition fail to provide file/line information are now treated as ERROR instead of FAIL
thomask
parents: 361
diff changeset
537 printf("ERROR:\t%s [%d]\n", arg[2], res);
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
538 }
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
539 }else{
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
540 printf("ERROR:\t%s [%d]\n", arg[2], res);
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{
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
543 if(res==RETURN_FAIL){
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
544 if(good_error){
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
545 printf("XFAIL:\t%s\n", arg[2]);
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
546 }else{
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
547 printf("FAIL: \t%s\n", arg[2]);
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
548 }
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
549 }else if(res==RETURN_OK){
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
550 printf("XPASS:\t%s\n", arg[2]);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
551 }else{
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
552 printf("ERROR:\t%s [%d]\n", arg[2], res);
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)
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
559 +strlen(arg[2])*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");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
573 strcat(buffer, arg[2]);
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 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
576 strcat(buffer, arg[2]);
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);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
588
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){
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
594 printf("ERROR:\t%s (Internal compiler error)\n", arg[2]);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
595 fprintf(stderr, "\n--------\n");
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
596 return 0;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
597 }else if(res==RETURN_FAIL && good_error){
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
598 printf("FAIL: \t%s [%d]\n", arg[2], res);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
599 fprintf(stderr, "\n--------\n");
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
600 return 0;
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
601 }else if(res!=RETURN_OK){
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
602 printf("ERROR:\t%s [%d]\n", arg[2], res);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
603 fprintf(stderr, "\n--------\n");
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
604 return 0;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
605 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
606
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
607 /* test 2/2 */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
608 buffer = malloc(strlen(arg[2]) + strlen(TLOG) + 24);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
609 *buffer = '\x00';
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
610 strcat(buffer, arg[2]);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
611 strcat(buffer, ".exe 1> ");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
612 strcat(buffer, TLOG);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
613 strcat(buffer, " 2>&1");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
614 fprintf(stderr, "%s\n", buffer);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
615 res=crashRun(buffer);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
616
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
617 /* diagnostic 2/2 */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
618 buffer = loadFile(TLOG);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
619 if(buffer==NULL || strlen(buffer)<2){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
620 buffer="";
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
621 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
622 fprintf(stderr, "%s\n", buffer);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
623 good_error = checkRuntimeErrorMessage(error_file, error_line, buffer);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
624 if(modus==RUN){
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
625 if(res==RETURN_OK){
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
626 printf("PASS: \t%s\n", arg[2]);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
627 }else if(res==RETURN_FAIL && good_error){
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
628 printf("FAIL: \t%s [run: %d]\n", arg[2], res);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
629 }else{
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
630 printf("ERROR:\t%s [run: %d]\n", arg[2], res);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
631 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
632 }else{
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
633 if(res==RETURN_FAIL){
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
634 if(good_error){
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
635 printf("XFAIL:\t%s\n", arg[2]);
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
636 }else{
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
637 printf("FAIL: \t%s\n", arg[2]);
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
638 }
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
639 }else if(res==RETURN_OK){
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
640 printf("XPASS:\t%s [norun: %d]\n", arg[2], res);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
641 }else{
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
642 printf("ERROR:\t%s [norun: %d]\n", arg[2], res);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
643 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
644 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
645 fprintf(stderr, "--------\n");
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
646 }else{
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
647 printf("@bug@ %d (%s)\n", modus, arg[2]);
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
648 return EXIT_FAILURE;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
649 }
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
650 return EXIT_SUCCESS;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
651 }