annotate dstress.c @ 681:be27bc9d0d28

gentoo fixes
author thomask
date Sat, 24 Sep 2005 19:51:27 +0000
parents f90958db522d
children 4f97e51515d8
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
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
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>
681
be27bc9d0d28 gentoo fixes
thomask
parents: 676
diff changeset
33 #include <ctype.h>
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
34
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
35 #define RUN 1
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
36 #define NORUN 2
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
37 #define COMPILE 4
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
38 #define NOCOMPILE 8
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
39
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
40 /* secure malloc */
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
41 void *xmalloc(size_t size){
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
42 void *p;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
43 if (p < 0){
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
44 fprintf(stderr,"Failed to allocate %zd bytes!\n", size);
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
45 exit(EXIT_FAILURE);
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
46 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
47 p = malloc(size);
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
48 if (p == NULL){
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
49 fprintf(stderr,"Failed to allocate %zd bytes!\n", size);
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
50 exit(EXIT_FAILURE);
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
51 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
52 return p;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
53 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
54 #define malloc xmalloc
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
55
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
56 #if defined(__GNU_LIBRARY__) || defined(__GLIBC__)
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
57 #define USE_POSIX
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
58 #endif
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
59
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
60 #ifdef linux
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
61 #define USE_POSIX
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
62 #endif
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
63
273
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
64 #if defined(__APPLE__) && defined(__MACH__)
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
65 #define USE_POSIX
273
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
66 #endif
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
67
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
68 #ifdef __FreeBSD__
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
69 #define USE_POSIX 1
273
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
70 #endif
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
71
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
72 #if defined(WIN) || defined(WIN32)
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
73 #define USE_WINDOWS 1
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
74 #endif
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
75
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
76 #ifdef USE_POSIX
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
77
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
78 #include <sys/types.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
79 #include <sys/stat.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
80 #include <fcntl.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
81 #include <unistd.h>
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
82 #include <regex.h>
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
83
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
84 #else
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
85 #ifdef USE_WINDOWS
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
86
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
87 #include <windows.h>
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
88
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
89 #else
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
90 #error neither POSIX nor MSWindows detected
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
91 #endif /* USE_WINDOWS else */
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
92 #endif /* USE_POSIX else */
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
93
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
94 #define OBJ "-odobj "
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
95 #ifdef USE_WINDOWS
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
96 #define TLOG ".\\obj\\log.tmp"
639
463c60e26040 updated readme
thomask
parents: 633
diff changeset
97 #define CRASH_RUN ".\\crashRun"
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
98 #define GDB_SCRIPTER ".\\obj\\gdb.tmp"
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
99 #else
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
100 #ifdef USE_POSIX
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
101 #define TLOG "./obj/log.tmp"
639
463c60e26040 updated readme
thomask
parents: 633
diff changeset
102 #define CRASH_RUN "./crashRun"
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
103 #define GDB_SCRIPTER "./obj/gdb.tmp"
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
104 #endif
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
105 #endif
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
106
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
107 char* errorMsg(int good_error){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
108 return (good_error) ? ("") : " [bad error message]";
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
109 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
110
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
111 char* gdbMsg(int good_gdb){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
112 return (good_gdb) ? ("") : " [bad debugger message]";
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
113 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
114
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
115 char* strip(char* buffer){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
116 if(buffer!=NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
117 while(isspace(buffer[0])){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
118 buffer++;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
119 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
120
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
121 char* tmp;
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
122 for(tmp=buffer+strlen(buffer)-1; isspace(tmp[0]); tmp=buffer+strlen(buffer)-1){
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
123 tmp[0]='\x00';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
124 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
125 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
126 return buffer;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
127 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
128
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
129 /* cleanup "/" versus "\" in filenames */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
130 char* cleanPathSeperator(char* filename){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
131 char* pos;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
132 #ifdef USE_POSIX
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
133 for(pos=strchr(filename, '\\'); pos; pos=strchr(filename, '\\')){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
134 *pos='/';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
135 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
136 #else
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
137 #if USE_WINDOWS
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
138 for(pos=strchr(filename, '/'); pos; pos=strchr(filename, '/')){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
139 *pos='\\';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
140 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
141 #else
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
142
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
143 #error no cleanPathSeperator available for this system
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
144
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
145 #endif /* USE_WINDOWS else */
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
146 #endif /* USE_POSIX else */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
147 return filename;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
148 }
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
149
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
150 char* loadFile(char* filename){
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
151 #ifdef USE_POSIX
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
152 char* back = NULL;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
153 struct stat fileInfo;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
154 int file = open(filename, O_RDONLY);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
155 if(errno == 0 && file != 0 && file != -1){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
156 if(0==fstat(file, &fileInfo)){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
157 back=malloc(fileInfo.st_size+1);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
158 fileInfo.st_size = read(file, back, fileInfo.st_size);
440
dc186d1266ba fixed handling of empty files
thomask
parents: 439
diff changeset
159 if(fileInfo.st_size>=0){
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
160 *(back+fileInfo.st_size+1) = '\x00';
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
161 }else{
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
162 back = NULL;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
163 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
164 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
165 close(file);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
166 }
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
167
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
168 if(back){
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
169 return back;
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
170 }
440
dc186d1266ba fixed handling of empty files
thomask
parents: 439
diff changeset
171 if(0==strcmp(filename, TLOG)){
dc186d1266ba fixed handling of empty files
thomask
parents: 439
diff changeset
172 return calloc(1,sizeof(char));
dc186d1266ba fixed handling of empty files
thomask
parents: 439
diff changeset
173 }
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
174
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
175 fprintf(stderr, "File not found \"%s\" (%s)\n", filename, strerror(errno));
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
176 exit(EXIT_FAILURE);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
177 #else /* USE_POSIX */
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
178 #ifdef USE_WINDOWS
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
179
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
180 char* back=NULL;
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
181 DWORD size, numread;
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
182 HANDLE file=CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
183 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
184 if (file != INVALID_HANDLE_VALUE){
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
185 size = GetFileSize(file, NULL);
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
186 if (size != INVALID_FILE_SIZE){
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
187 back=malloc((size+1)*sizeof(char));
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
188 if (ReadFile(file,back,size,&numread,NULL) == 1){
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
189 if (numread==size){
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
190 *(back+size+1) = '\x00';
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
191 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
192 back = NULL;
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
193 }
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
194 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
195 back = NULL;
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
196 }
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
197 }
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
198 CloseHandle(file);
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
199 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
200 if(back){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
201 errno = 0;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
202 return back;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
203 }
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
204
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
205 fprintf(stderr, "File not found \"%s\"\n", filename);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
206 exit(EXIT_FAILURE);
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
207 #else /* USE_WINDOWS */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
208
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
209 #error "no loadFile implementation present"
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
210
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
211 #endif /* USE_WINDOWS */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
212 #endif /* USE_POSIX else */
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
213 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
214
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
215 void writeFile(const char* filename, const char* content){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
216 size_t len = strlen(content);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
217 FILE* file = fopen(filename, "w+");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
218
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
219 if(errno == 0 && file != NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
220 if((fwrite(content, sizeof(char), len, file) != len) || (errno != 0)){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
221 fprintf(stderr, "failed to write file \"%s\" (%s)\n", filename, strerror(errno));
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
222 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
223 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
224 if(fclose(file) || (errno != 0)){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
225 fprintf(stderr, "failed to close file \"%s\" (%s)\n", filename, strerror(errno));
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
226 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
227 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
228 return;
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
229 }
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
230
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
231 fprintf(stderr, "couldn't open file \"%s\" for writing (%s)\n", filename, strerror(errno));
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
232 exit(EXIT_FAILURE);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
233 }
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
234
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
235 /* query the environment for the compiler name */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
236 char* getCompiler(){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
237 char* back = getenv("DMD");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
238 if(back == NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
239 back = getenv("dmd");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
240 if(back==NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
241 back = "dmd";
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
242 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
243 }
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
244 return strip(cleanPathSeperator(back));
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
245 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
246
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
247 /* query the environment for the debugger name */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
248 char* getGDB(){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
249 char* back = getenv("GDB");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
250 if(back == NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
251 back = getenv("gdb");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
252 if(back == NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
253 back = "gdb";
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
254 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
255 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
256 return strip(cleanPathSeperator(back));
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
257 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
258
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
259 /* extract the FIRST occurance of a given TAG until the next linebreak */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
260 char* getCaseFlag(const char* data, const char* tag){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
261 char* begin;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
262 char* end1;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
263 char* end2;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
264 char* back;
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
265
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
266 if(data!=NULL && tag!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
267 begin = strstr(data, tag);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
268 if(begin!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
269 begin = begin+strlen(tag);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
270 end1 = strstr(begin, "\n");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
271 end2 = strstr(begin, "\r");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
272 if(end2!=NULL && ((end1!=NULL && end2<end1) || end1==NULL)){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
273 end1=end2;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
274 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
275 if(end1==NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
276 end1 = begin + strlen(begin);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
277 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
278 back = malloc(end1-begin+1);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
279 strncpy(back, begin, end1-begin);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
280 back[end1-begin+1]='\x00';
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
281 return strip(cleanPathSeperator(back));
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
282 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
283 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
284
429
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
285 return calloc(1,1);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
286 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
287
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
288 /* check compile-time error messages */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
289 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
290
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
291 char* file;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
292 char* line;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
293 char* dmd;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
294 char* gdc;
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 int back=0;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
297
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
298 /* clean arguments */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
299 if(strcmp(file_, "")!=0){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
300 file = malloc(strlen(file_)+1);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
301 strcpy(file, file_);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
302 }else{
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
303 file=NULL;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
304 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
305
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
306 if(strcmp(line_, "")!=0){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
307 line = malloc(strlen(line_)+1);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
308 strcpy(line, line_);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
309 }else{
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
310 line=NULL;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
311 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
312
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
313 /* gen patterns*/
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
314 if(file!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
315 if(line!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
316 dmd = malloc(strlen(file)+strlen(line)+5);
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
317 sprintf(dmd, "%s(%s)", file, line);
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
318
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
319 gdc = malloc(strlen(file)+strlen(line)+4);
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
320 sprintf(gdc, "%s:%s: ", file, line);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
321 }else{
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
322 dmd = malloc(strlen(file)+2);
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
323 sprintf(dmd, "%s(", file);
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
324
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
325 gdc = malloc(strlen(file)+2);
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
326 sprintf(gdc, "%s:", file);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
327 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
328 }else if(line!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
329 dmd = malloc(strlen(line)+5);
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
330 sprintf(dmd, "(%s): ", line);
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
331
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
332 gdc = malloc(strlen(line)+4);
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
333 sprintf(gdc, ":%s: ", line);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
334 }else{
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
335 return 1;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
336 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
337
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
338 /* specific error messages */
676
f90958db522d extended debug output
thomask
parents: 639
diff changeset
339 #ifdef DEBUG
f90958db522d extended debug output
thomask
parents: 639
diff changeset
340 fprintf(stderr, "pattern(dmd):\t%s\n", dmd);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
341 fprintf(stderr, "pattern(gdc):\t%s\n", gdc);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
342 #endif
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
343
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
344 if( (dmd!=NULL && strstr(buffer, dmd))
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
345 || (gdc!=NULL && strstr(buffer, gdc))
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
346 || (dmd==NULL && gdc==NULL)){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
347 back=1;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
348 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
349
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
350 return back;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
351 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
352
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
353 int checkRuntimeErrorMessage(const char* file_, const char* line_, const char* buffer){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
354 /* PhobosLong dir/file.d(2)
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
355 * Phobos package.module(2)
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
356 */
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
357
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
358 char* file;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
359 char* line;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
360 char* phobos;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
361 char* phobosLong;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
362
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
363 char* begin;
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
364 char* end;
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
365
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
366 int back=0;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
367
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
368 /* clean arguments */
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
369 if(strcmp(file_, "")!=0){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
370 file = malloc(strlen(file_)+1);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
371 strcpy(file, file_);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
372 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
373 file=NULL;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
374 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
375
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
376 if(strcmp(line_, "")!=0){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
377 line = malloc(strlen(line_)+1);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
378 strcpy(line, line_);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
379 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
380 line=NULL;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
381 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
382
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
383 /* gen patterns*/
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
384 if(file!=NULL){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
385 if(line!=NULL){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
386 phobos = malloc(strlen(file)+strlen(line)+5);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
387 phobos[0]='\x00';
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
388 begin=strrchr(file,'/');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
389 if(begin){
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
390 begin++;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
391 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
392 begin=strrchr(file,'\\');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
393 if(begin){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
394 begin++;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
395 }else{
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
396 begin=file;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
397 }
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
398 }
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
399 end=strrchr(file,'.');
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
400 strncat(phobos, begin, end-begin);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
401 strcat(phobos, "(");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
402 strcat(phobos, line);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
403 strcat(phobos, ")");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
404
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
405 phobosLong = malloc(strlen(file)+strlen(line)+5);
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
406 sprintf(phobosLong, "%s(%s)", file, line);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
407 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
408 phobos = malloc(strlen(file)+2);
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
409 phobos[0]='\x00';
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
410 begin=strrchr(file,'/');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
411 if(begin){
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
412 begin++;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
413 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
414 begin=strrchr(file,'\\');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
415 if(begin){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
416 begin++;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
417 }else{
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
418 begin=file;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
419 }
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
420 }
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
421 end=strrchr(file,'.');
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
422 strncat(phobos, begin, end-begin);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
423 strcat(phobos, "(");
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
424
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
425 phobosLong = malloc(strlen(file)+2);
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
426 sprintf(phobosLong, "%s(", file);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
427 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
428 }else if(line!=NULL){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
429 phobos = malloc(strlen(line)+3);
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
430 sprintf(phobos, "(%s)", line);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
431
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
432 phobosLong=NULL;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
433 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
434 return 1;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
435 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
436
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
437 /* specific error messages */
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
438
676
f90958db522d extended debug output
thomask
parents: 639
diff changeset
439 #ifdef DEBUG
f90958db522d extended debug output
thomask
parents: 639
diff changeset
440 fprintf(stderr, "pattern(phobosShort):\t%s\n", phobos);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
441 fprintf(stderr, "pattern(phobosLong):\t%s\n", phobosLong);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
442 #endif
f90958db522d extended debug output
thomask
parents: 639
diff changeset
443
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
444 if( (phobos && strstr(buffer, phobos))
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
445 || (phobosLong && strstr(buffer, phobosLong)))
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
446 {
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
447 back=1;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
448 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
449
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
450 return back;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
451 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
452
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
453 int hadExecCrash(const char* buffer){
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
454 if(strstr(buffer, "Segmentation fault")
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
455 || strstr(buffer, "Internal error")
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
456 || strstr(buffer, "gcc.gnu.org/bugs")
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
457 || strstr(buffer, "EXIT CODE: signal"))
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
458 {
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
459 return 1;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
460 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
461 return 0;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
462 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
463
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
464 /* system call with time-out */
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
465 int crashRun(const char* cmd){
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
466 #ifdef USE_POSIX
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
467 char* buffer=malloc(4+strlen(CRASH_RUN)+strlen(cmd));
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
468 sprintf(buffer, "\"%s\" %s", CRASH_RUN, cmd);
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
469 system(buffer);
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
470 buffer=loadFile(TLOG);
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
471
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
472 if(strstr(buffer, "EXIT CODE: 0")){
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
473 return EXIT_SUCCESS;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
474 }else if(strstr(buffer, "EXIT CODE: 256")
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
475 || strstr(buffer, "EXIT CODE: timeout"))
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
476 {
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
477 return EXIT_FAILURE;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
478 }else{
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
479 return RAND_MAX;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
480 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
481 #else
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
482
639
463c60e26040 updated readme
thomask
parents: 633
diff changeset
483 #error comment me out, if your test cases produce neither eternal loops nor Access Violations
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
484 return system(cmd);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
485
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
486 #endif /* USE_POSIX else */
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
487 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
488
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
489
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
490 int main(int argc, char* arg[]){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
491 char* compiler; /* the compiler - from enviroment flag "DMD" */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
492 char* cmd_arg_case; /* additional arguments - from the testcase file */
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
493 char* buffer; /* general purpose buffer */
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
494 int modus; /* test modus: RUN NORUN COMPILE NOCOMPILE */
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
495 int res; /* return code from external executions */
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
496 char* case_file;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
497 char* error_file; /* expected sourcefile containing the error */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
498 char* error_line; /* expected error line */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
499 int good_error; /* error contained file and line and matched the expectations */
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
500 char* gdb; /* the debugger - from environment flag "GDB" */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
501 char* gdb_script; /* gdb command sequence */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
502 char* gdb_pattern_raw; /* POSIX regexp expected in GDB's output */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
503 #ifdef REG_EXTENDED
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
504 regex_t* gdb_pattern;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
505 #endif
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
506 int good_gdb; /* (gdb test and positive) or (no gdb test)*/
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
507
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
508 /* check arguments */
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
509 if(argc != 3){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
510 err:
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
511 if(argc!=0)
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
512 fprintf(stderr,"%s <run|norun|compile|nocompile> <source>\n", arg[0]);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
513 else
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
514 fprintf(stderr,"dstress <run|norun|compile|nocompile> <source>\n");
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
515 exit(EXIT_FAILURE);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
516 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
517
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
518 if(0==strcmp(arg[1], "run") || 0==strcmp(arg[1], "RUN")){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
519 modus = RUN;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
520 }else if(0==strcmp(arg[1], "norun") || 0==strcmp(arg[1], "NORUN")){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
521 modus = NORUN;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
522 }else if(0==strcmp(arg[1], "compile") || 0==strcmp(arg[1], "COMPILE")){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
523 modus = COMPILE;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
524 }else if(0==strcmp(arg[1], "nocompile") || 0==strcmp(arg[1], "NOCOMPILE")){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
525 modus = NOCOMPILE;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
526 }else{
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
527 goto err;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
528 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
529
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
530 /* gen flags */
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
531 case_file = cleanPathSeperator(strdup(arg[2]));
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
532 compiler = getCompiler();
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
533 gdb = getGDB();
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
534 buffer = loadFile(case_file);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
535
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
536 cmd_arg_case = getCaseFlag(buffer, "__DSTRESS_DFLAGS__");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
537 error_line = getCaseFlag(buffer, "__DSTRESS_ELINE__");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
538 error_file = getCaseFlag(buffer, "__DSTRESS_EFILE__");
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
539 gdb_script = getCaseFlag(buffer, "__GDB_SCRIPT__");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
540 gdb_pattern_raw = getCaseFlag(buffer, "__GDB_PATTERN__");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
541
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
542
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
543 /* set implicit source file */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
544 if(strcmp(error_line, "")!=0 && strcmp(error_file, "")==0){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
545 error_file=case_file;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
546 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
547
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
548 /* gdb pattern */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
549 #ifdef REG_EXTENDED
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
550 if(gdb_pattern_raw!=NULL && gdb_pattern_raw[0]!='\x00'){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
551
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
552 gdb_pattern = malloc(sizeof(regex_t));
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
553 if(regcomp(gdb_pattern, gdb_pattern_raw, REG_EXTENDED)){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
554 fprintf(stderr, "failed to compile regular expression:\n\t%s\n", gdb_pattern_raw);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
555 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
556 }else if(gdb_script==NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
557 fprintf(stderr, "GDB pattern without GDB script\n");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
558 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
559 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
560 }else{
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
561 gdb_pattern = NULL;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
562 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
563
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
564 /* gdb script */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
565 if(gdb_script!=NULL && gdb_script[0]!='\x00'){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
566 if(gdb_pattern==NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
567 fprintf(stderr, "GDB script without GDB pattern\n");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
568 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
569 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
570 buffer=gdb_script;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
571 for(; *buffer; buffer++){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
572 if(buffer[0]=='\\'){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
573 if(buffer[1]=='n'){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
574 buffer[0]=' ';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
575 buffer[1]='\n';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
576 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
577 buffer++;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
578 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
579 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
580
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
581 buffer=malloc(strlen(gdb_script)+10);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
582 strcpy(buffer, gdb_script);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
583 gdb_script=strcat(buffer, "\n\nquit\ny\n\n");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
584 good_gdb = 0;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
585 }else{
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
586 good_gdb = 1;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
587 gdb_script = NULL;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
588 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
589
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
590 #else
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
591
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
592 if(gdb_script && strlen(gdb_script) && gdb_pattern_raw && strlen(gdb_pattern_raw)){
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
593 fprintf(stderr, "WARNING: regex support inactive\n");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
594 }else if(gdb_script && strlen(gdb_script)){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
595 fprintf(stderr, "GDB script without GDB pattern\n");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
596 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
597 }else if(gdb_pattern_raw && strlen(gdb_pattern_raw)){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
598 fprintf(stderr, "GDB pattern without GDB script\n");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
599 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
600 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
601
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
602 #endif /* REG_EXTENDED else */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
603
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
604
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
605
493
1418f225a81e disabled debug output
thomask
parents: 490
diff changeset
606 #ifdef DEBUG
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
607 fprintf(stderr, "case: \"%s\"\n", case_file);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
608 fprintf(stderr, "compiler: \"%s\"\n", compiler);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
609 fprintf(stderr, "DFLAGS C: \"%s\"\n", cmd_arg_case);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
610 fprintf(stderr, "ELINE : \"%s\"\n", error_line);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
611 fprintf(stderr, "EFILE : \"%s\"\n", error_file);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
612 fprintf(stderr, "GDB Scri: \"%s\"\n", gdb_script);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
613 fprintf(stderr, "GDB Patt: \"%s\"\n", gdb_pattern_raw);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
614 #endif
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
615
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
616 /* start working */
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
617 if(modus==COMPILE || modus==NOCOMPILE){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
618 /* gen command */
639
463c60e26040 updated readme
thomask
parents: 633
diff changeset
619 buffer = malloc(strlen(compiler)+strlen(cmd_arg_case)+strlen(OBJ)
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
620 +strlen(case_file)+strlen(TLOG)+64);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
621 buffer[0]='\x00';
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
622 strcat(buffer, compiler);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
623 strcat(buffer, " ");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
624 strcat(buffer, cmd_arg_case);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
625 strcat(buffer, " -c ");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
626 if(NULL==strstr(buffer, "-od")){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
627 strcat(buffer, OBJ);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
628 strcat(buffer, " ");
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
629 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
630 strcat(buffer, case_file);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
631 strcat(buffer, " 1> ");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
632 strcat(buffer, TLOG);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
633 strcat(buffer, " 2>&1");
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
634
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
635 /* test */
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
636 if(modus==COMPILE){
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
637 fprintf(stderr, "compile: %s\n", buffer);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
638 }else{
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
639 fprintf(stderr, "nocompile: %s\n", buffer);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
640 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
641 res = crashRun(buffer);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
642
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
643 /* diagnostic */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
644 buffer = loadFile(TLOG);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
645 fprintf(stderr, "%s\n", buffer);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
646 good_error = checkErrorMessage(error_file, error_line, buffer);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
647
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
648 if(hadExecCrash(buffer)){
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
649 printf("ERROR:\t%s [internal compiler error]\n", case_file);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
650 }else if(modus==COMPILE){
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
651 if(res==EXIT_SUCCESS){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
652 printf("PASS: \t%s\n", case_file);
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
653 }else if(res==EXIT_FAILURE && good_error){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
654 if(checkErrorMessage(case_file, "", buffer)){
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
655 printf("FAIL: \t%s\n", case_file);
373
177ce8d13eac test cases that unexpectetly fail and in addition fail to provide file/line information are now treated as ERROR instead of FAIL
thomask
parents: 361
diff changeset
656 }else{
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
657 printf("ERROR:\t%s%s\n", case_file, errorMsg(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
658 }
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
659 }else{
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
660 printf("ERROR:\t%s%s\n", case_file, errorMsg(good_error));
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
661 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
662 }else{
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
663 if(res==EXIT_FAILURE){
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
664 if(good_error){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
665 printf("XFAIL:\t%s\n", case_file);
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
666 }else{
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
667 printf("FAIL: \t%s%s\n", case_file, errorMsg(good_error));
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
668 }
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
669 }else if(res==EXIT_SUCCESS){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
670 printf("XPASS:\t%s\n", case_file);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
671 }else{
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
672 printf("ERROR:\t%s\n", case_file);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
673 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
674 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
675 fprintf(stderr,"--------\n");
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
676 }else if(modus==RUN || modus==NORUN){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
677 /* gen command */
639
463c60e26040 updated readme
thomask
parents: 633
diff changeset
678 buffer = malloc(strlen(compiler)+strlen(cmd_arg_case)+strlen(OBJ)
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
679 +strlen(case_file)*2+strlen(TLOG)+64);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
680 strcpy(buffer, compiler);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
681 strcat(buffer, " ");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
682 strcat(buffer, cmd_arg_case);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
683 strcat(buffer, " ");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
684 if(NULL==strstr(buffer, "-od")){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
685 strcat(buffer, OBJ);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
686 strcat(buffer, " ");
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
687 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
688 if(NULL==strstr(buffer, "-of")){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
689 strcat(buffer, "-of");
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
690 strcat(buffer, case_file);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
691 strcat(buffer, ".exe ");
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
692 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
693 strcat(buffer, case_file);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
694 strcat(buffer, " 1> ");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
695 strcat(buffer, TLOG);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
696 strcat(buffer, " 2>&1");
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
697
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
698 /* test 1/3 - compile */
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
699 if(modus==RUN){
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
700 fprintf(stderr, "run: %s\n", buffer);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
701 }else{
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
702 fprintf(stderr, "norun: %s\n", buffer);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
703 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
704 res = crashRun(buffer);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
705
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
706 /* diagnostic 1/3 */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
707 buffer = loadFile(TLOG);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
708 fprintf(stderr, "%s", buffer);
676
f90958db522d extended debug output
thomask
parents: 639
diff changeset
709 if(modus==RUN){
f90958db522d extended debug output
thomask
parents: 639
diff changeset
710 good_error = checkErrorMessage(error_file, error_line, buffer);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
711 }else{
f90958db522d extended debug output
thomask
parents: 639
diff changeset
712 good_error = 1;
f90958db522d extended debug output
thomask
parents: 639
diff changeset
713 }
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
714 if(hadExecCrash(buffer)){
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
715 printf("ERROR:\t%s [internal compiler error]\n", case_file);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
716 fprintf(stderr, "\n--------\n");
437
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
717 return EXIT_SUCCESS;
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
718 }else if(res==EXIT_FAILURE && good_error){
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
719 printf("FAIL: \t%s\n", case_file);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
720 fprintf(stderr, "\n--------\n");
437
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
721 return EXIT_SUCCESS;
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
722 }else if(res!=EXIT_SUCCESS){
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
723 printf("ERROR:\t%s%s\n", case_file, errorMsg(good_error));
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
724 fprintf(stderr, "\n--------\n");
437
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
725 return EXIT_SUCCESS;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
726 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
727
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
728 /* test 2/3 - run */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
729 buffer = malloc(strlen(case_file) + strlen(TLOG) + 30);
681
be27bc9d0d28 gentoo fixes
thomask
parents: 676
diff changeset
730 sprintf(buffer, "%s.exe 1> %s 2>&1\n", case_file, TLOG);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
731 fprintf(stderr, "%s\n", buffer);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
732 res=crashRun(buffer);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
733
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
734 /* diagnostic 2/3 */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
735 buffer = loadFile(TLOG);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
736 fprintf(stderr, "%s\n", buffer);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
737 good_error = checkRuntimeErrorMessage(error_file, error_line, buffer);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
738
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
739 #ifdef REG_EXTENDED
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
740 if(!good_gdb){
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
741 /* test 3/3 - gdb */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
742 writeFile(GDB_SCRIPTER, gdb_script);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
743 buffer = malloc(strlen(gdb) + strlen(case_file) + strlen(GDB_SCRIPTER) + strlen(TLOG) + 20);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
744 sprintf(buffer, "%s %s.exe < %s > %s 2>&1", gdb, case_file, GDB_SCRIPTER, TLOG);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
745 fprintf(stderr, "%s\n", buffer);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
746 if(EXIT_SUCCESS==crashRun(buffer)){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
747 /* diagnostic 3/3 */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
748 buffer = loadFile(TLOG);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
749 fprintf(stderr, "%s\n", buffer);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
750 good_gdb = (regexec(gdb_pattern, buffer, 0, NULL, 0)==0);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
751 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
752 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
753 #endif /* REG_EXTENDED */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
754
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
755 if(modus==RUN){
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
756 if(hadExecCrash(buffer)){
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
757 printf("ERROR:\t%s [test case crash]%s%s", case_file, errorMsg(good_error), gdbMsg(good_gdb));
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
758 }else if(res==EXIT_SUCCESS && good_gdb){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
759 printf("PASS: \t%s\n", case_file);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
760 }else if(res==EXIT_FAILURE && good_error && good_gdb){
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
761 printf("FAIL: \t%s\n", case_file);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
762 }else{
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
763 printf("ERROR:\t%s%s%s\n", case_file, errorMsg(good_error), gdbMsg(good_gdb));
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
764 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
765 }else{
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
766 if(res==EXIT_SUCCESS && good_gdb){
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
767 printf("XPASS:\t%s%s%s\n", case_file, errorMsg(good_error), gdbMsg(good_gdb));
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
768 }else if(good_error && good_gdb){
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
769 printf("XFAIL:\t%s%s%s\n", case_file, errorMsg(good_error), gdbMsg(good_gdb));
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
770 }else{
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
771 printf("FAIL:\t%s%s%s\n", case_file, errorMsg(good_error), gdbMsg(good_gdb));
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
772 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
773 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
774 fprintf(stderr, "--------\n");
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
775 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
776 printf("@bug@ %d (%s)\n", modus, case_file);
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
777 return EXIT_FAILURE;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
778 }
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
779 return EXIT_SUCCESS;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
780 }