annotate dstress.c @ 710:8cba64b24615

fixed typo
author thomask
date Sun, 23 Oct 2005 10:03:52 +0000
parents 5ba45899cddd
children d4edcc124e64
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
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
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){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
42 void *p = malloc(size);
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
43 if (p == NULL){
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 return p;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
48 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
49 #define malloc xmalloc
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
50
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
51 #if defined(__GNU_LIBRARY__) || defined(__GLIBC__)
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
52 #define USE_POSIX 1
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
53 #endif
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
54
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
55 #if defined(linux) || defined(__FreeBSD__) || defined(__OpenBSD__)
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
56 #define USE_POSIX 1
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
57 #endif
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
58
273
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
59 #if defined(__APPLE__) && defined(__MACH__)
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
60 #define USE_POSIX 1
273
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
61 #endif
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
62
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
63 #if defined(WIN) || defined(WIN32)
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
64 #define USE_WINDOWS 1
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
65 #endif
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
66
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
67 /* prefere USE_POSIX over USE_WINDOWS if both APIs are detected */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
68 #ifdef USE_POSIX
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
69
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
70 #include <sys/types.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
71 #include <sys/stat.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
72 #include <fcntl.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
73 #include <unistd.h>
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
74 #include <regex.h>
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
75
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
76 #else
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
77 #ifdef USE_WINDOWS
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
78
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
79 #include <windows.h>
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
80 #define snprintf _snprintf
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
81 #ifndef INVALID_FILE_SIZE
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
82 #define INVALID_FILE_SIZE (-1)
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
83 #endif
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
84
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
85 #else
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
86 #error neither POSIX nor MSWindows API detected
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
87 #endif /* USE_WINDOWS else */
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
88 #endif /* USE_POSIX else */
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
89
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
90 #define OBJ "obj "
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
91
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
92 #ifdef USE_POSIX
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
93 #define TLOG "./obj/log.tmp"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
94 #define CRASH_RUN "./crashRun"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
95 #define GDB_SCRIPTER "./obj/gdb.tmp"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
96 #else
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
97 #ifdef USE_WINDOWS
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
98 #define TLOG ".\\obj\\log.tmp"
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
99 #define CRASH_RUN ".\\crashRun"
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
100 #define GDB_SCRIPTER ".\\obj\\gdb.tmp"
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
101 #else
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
102 #error OS dependent file names not defined
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
103 #endif
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
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
106 char* errorMsg(int good_error){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
107 return (good_error) ? ("") : " [bad error message]";
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
108 }
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 char* gdbMsg(int good_gdb){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
111 return (good_gdb) ? ("") : " [bad debugger message]";
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
112 }
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 char* strip(char* buffer){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
115 char* tmp = NULL;
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
116
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
117 if(buffer!=NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
118 while(isspace(buffer[0])){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
119 buffer++;
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
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){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
131 char* pos = NULL;
620
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
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
152 char* back;
251
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);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
155
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
156 back = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
157
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
158 if(errno == 0 && file != 0 && file != -1){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
159 if(0==fstat(file, &fileInfo)){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
160 back=malloc(fileInfo.st_size+1);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
161 fileInfo.st_size = read(file, back, fileInfo.st_size);
440
dc186d1266ba fixed handling of empty files
thomask
parents: 439
diff changeset
162 if(fileInfo.st_size>=0){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
163 *(back+fileInfo.st_size) = '\x00';
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
164 }else{
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
165 back = NULL;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
166 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
167 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
168 close(file);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
169 }
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
170
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
171 if(back){
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
172 return back;
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
173 }
440
dc186d1266ba fixed handling of empty files
thomask
parents: 439
diff changeset
174 if(0==strcmp(filename, TLOG)){
dc186d1266ba fixed handling of empty files
thomask
parents: 439
diff changeset
175 return calloc(1,sizeof(char));
dc186d1266ba fixed handling of empty files
thomask
parents: 439
diff changeset
176 }
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
177
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
178 fprintf(stderr, "File not found \"%s\" (%s)\n", filename, strerror(errno));
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
179 exit(EXIT_FAILURE);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
180 #else /* USE_POSIX */
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
181 #ifdef USE_WINDOWS
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
182 // @todo@ check for 32bit/64bit
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
183 char* back;
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
184 DWORD size, numread;
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
185 HANDLE file=CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
186 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
187
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
188 back = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
189 size = 0;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
190 numread = 0;
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
191 if (file != INVALID_HANDLE_VALUE){
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
192 size = GetFileSize(file, NULL);
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
193 if (size != INVALID_FILE_SIZE){
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
194 back=malloc((size+1)*sizeof(char));
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
195 if (ReadFile(file,back,size,&numread,NULL) == 1){
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
196 if (numread==size){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
197 *(back+size) = '\x00';
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
198 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
199 back = NULL;
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
200 }
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
201 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
202 back = NULL;
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
203 }
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
204 }
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
205 CloseHandle(file);
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
206 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
207 if(back){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
208 errno = 0;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
209 return back;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
210 }
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
211
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
212 fprintf(stderr, "File not found \"%s\"\n", filename);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
213 exit(EXIT_FAILURE);
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
214 #else /* USE_WINDOWS */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
215
707
5ba45899cddd minor infrastructure fixes
thomask
parents: 704
diff changeset
216 #error no loadFile implementation present
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
217
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
218 #endif /* USE_WINDOWS */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
219 #endif /* USE_POSIX else */
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
220 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
221
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
222 void writeFile(const char* filename, const char* content){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
223 size_t len;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
224 FILE* file;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
225
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
226 len = strlen(content);
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
227 errno = 0;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
228 file = fopen(filename, "w+");
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
229
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
230 if(errno == 0 && file != NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
231 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
232 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
233 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
234 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
235 if(fclose(file) || (errno != 0)){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
236 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
237 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
238 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
239 return;
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
240 }
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
241
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
242 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
243 exit(EXIT_FAILURE);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
244 }
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
245
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
246 /* query the environment for the compiler name */
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
247 char* getCompiler(void){
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
248 char* back = getenv("DMD");
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
249
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
250 #ifdef USE_WINDOWS
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
251 if(back == NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
252 back = getenv("dmd");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
253 }
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
254 #endif
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
255 if(back==NULL){
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
256 back = "dmd";
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
257 }
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
258
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
259 return strip(cleanPathSeperator(back));
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
260 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
261
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
262 /* query the environment for the debugger name */
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
263 char* getGDB(void){
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
264 char* back = getenv("GDB");
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
265
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
266 #ifdef USE_WINDOWS
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
267 if(back == NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
268 back = getenv("gdb");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
269 }
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
270 #endif
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
271 if(back==NULL){
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
272 back = "gdb";
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
273 }
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
274
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
275 return strip(cleanPathSeperator(back));
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
276 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
277
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
278 /* 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
279 char* getCaseFlag(const char* data, const char* tag){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
280 char* begin;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
281 char* end1;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
282 char* end2;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
283 char* back;
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
284
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
285 begin = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
286 end1 = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
287 end2 = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
288 back = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
289
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
290 if(data!=NULL && tag!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
291 begin = strstr(data, tag);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
292 if(begin!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
293 begin = begin+strlen(tag);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
294 end1 = strstr(begin, "\n");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
295 end2 = strstr(begin, "\r");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
296 if(end2!=NULL && ((end1!=NULL && end2<end1) || end1==NULL)){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
297 end1=end2;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
298 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
299 if(end1==NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
300 end1 = begin + strlen(begin);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
301 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
302 back = malloc(end1-begin+1);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
303 strncpy(back, begin, end1-begin);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
304 back[end1-begin]='\x00';
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
305 return strip(cleanPathSeperator(back));
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
306 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
307 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
308
429
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
309 return calloc(1,1);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
310 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
311
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
312 /* check compile-time error messages */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
313 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
314
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
315 char* file;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
316 char* line;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
317 char* dmd;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
318 char* gdc;
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
319 size_t len;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
320 int back;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
321
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
322 file = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
323 line = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
324 dmd = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
325 gdc = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
326 len = 0;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
327 back = 0;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
328
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
329 /* clean arguments */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
330 if(strcmp(file_, "")!=0){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
331 len = strlen(file_)+1;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
332 file = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
333 strncpy(file, file_, len);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
334 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
335
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
336 if(strcmp(line_, "")!=0){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
337 len = strlen(line_)+1;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
338 line = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
339 strncpy(line, line_, len);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
340 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
341
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
342 /* gen patterns*/
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
343 if(file!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
344 if(line!=NULL){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
345 len = strlen(file)+strlen(line)+5;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
346 dmd = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
347 snprintf(dmd, len, "%s(%s)", file, line);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
348
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
349 gdc = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
350 snprintf(gdc, len, "%s:%s: ", file, line);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
351 }else{
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
352 len = strlen(file)+2;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
353 dmd = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
354 snprintf(dmd, len, "%s(", file);
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
355
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
356 gdc = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
357 snprintf(gdc, len, "%s:", file);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
358 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
359 }else if(line!=NULL){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
360 len = strlen(line)+5;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
361 dmd = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
362 snprintf(dmd, len, "(%s): ", line);
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
363
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
364 gdc = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
365 snprintf(gdc, len, ":%s: ", line);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
366 }else{
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
367 return 1;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
368 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
369
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
370 /* specific error messages */
676
f90958db522d extended debug output
thomask
parents: 639
diff changeset
371 #ifdef DEBUG
f90958db522d extended debug output
thomask
parents: 639
diff changeset
372 fprintf(stderr, "pattern(dmd):\t%s\n", dmd);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
373 fprintf(stderr, "pattern(gdc):\t%s\n", gdc);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
374 #endif
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
375
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
376 if( (dmd!=NULL && strstr(buffer, dmd))
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
377 || (gdc!=NULL && strstr(buffer, gdc))
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
378 || (dmd==NULL && gdc==NULL)){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
379 back=1;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
380 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
381
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
382 return back;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
383 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
384
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
385 int checkRuntimeErrorMessage(const char* file_, const char* line_, const char* buffer){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
386 /* PhobosLong dir/file.d(2)
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
387 * Phobos package.module(2)
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
388 */
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
389
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
390 char* file;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
391 char* line;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
392 char* phobos;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
393 char* phobosLong;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
394
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
395 char* begin;
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
396 char* end;
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
397 size_t len;
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
398
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
399 int back=0;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
400
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
401 file = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
402 line = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
403 phobos = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
404 phobosLong = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
405
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
406 begin = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
407 end = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
408 len = 0;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
409
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
410 /* clean arguments */
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
411 if(strcmp(file_, "")!=0){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
412 len = strlen(file_)+1;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
413 file = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
414 strncpy(file, file_, len);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
415 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
416
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
417 if(strcmp(line_, "")!=0){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
418 len = strlen(line_)+1;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
419 line = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
420 strncpy(line, line_, len);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
421 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
422
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
423 /* gen patterns*/
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
424 if(file!=NULL){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
425 if(line!=NULL){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
426 len = strlen(file)+strlen(line)+5;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
427 phobos = malloc(len);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
428 begin=strrchr(file,'/');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
429 if(begin){
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
430 begin++;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
431 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
432 begin=strrchr(file,'\\');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
433 if(begin){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
434 begin++;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
435 }else{
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
436 begin=file;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
437 }
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
438 }
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
439 end=strrchr(file,'.');
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
440 strncat(phobos, begin, end-begin);
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
441 snprintf(phobos, len, "%.*s(%s)",
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
442 (int)(end-begin), begin,
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
443 line);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
444
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
445 phobosLong = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
446 snprintf(phobosLong, len, "%s(%s)", file, line);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
447 }else{
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
448 len = strlen(file)+2;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
449 phobos = malloc(len);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
450 begin=strrchr(file,'/');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
451 if(begin){
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
452 begin++;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
453 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
454 begin=strrchr(file,'\\');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
455 if(begin){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
456 begin++;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
457 }else{
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
458 begin=file;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
459 }
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
460 }
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
461 end=strrchr(file,'.');
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
462 snprintf(phobos, len, "%.*s(", (int)(end-begin), begin);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
463
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
464 phobosLong = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
465 snprintf(phobosLong, len, "%s(", file);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
466 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
467 }else if(line!=NULL){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
468 len = strlen(line)+3;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
469 phobos = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
470 snprintf(phobos, len, "(%s)", line);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
471
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
472 phobosLong=NULL;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
473 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
474 return 1;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
475 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
476
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
477 /* specific error messages */
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
478
676
f90958db522d extended debug output
thomask
parents: 639
diff changeset
479 #ifdef DEBUG
f90958db522d extended debug output
thomask
parents: 639
diff changeset
480 fprintf(stderr, "pattern(phobosShort):\t%s\n", phobos);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
481 fprintf(stderr, "pattern(phobosLong):\t%s\n", phobosLong);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
482 #endif
f90958db522d extended debug output
thomask
parents: 639
diff changeset
483
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
484 if( (phobos && strstr(buffer, phobos))
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
485 || (phobosLong && strstr(buffer, phobosLong)))
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
486 {
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
487 back=1;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
488 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
489
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
490 return back;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
491 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
492
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
493 int hadExecCrash(const char* buffer){
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
494 if(strstr(buffer, "Segmentation fault")
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
495 || strstr(buffer, "Internal error")
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
496 || strstr(buffer, "gcc.gnu.org/bugs")
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
497 || strstr(buffer, "EXIT CODE: signal"))
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
498 {
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
499 return 1;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
500 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
501 return 0;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
502 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
503
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
504 /* system call with time-out */
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
505 int crashRun(const char* cmd){
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
506 #ifdef USE_POSIX
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
507 size_t len;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
508 char* buffer;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
509
703
8dc894322ce8 repos maintenance
thomask
parents: 697
diff changeset
510 len = 4 + strlen(CRASH_RUN) + strlen(cmd);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
511 buffer = malloc(len);
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
512
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
513 snprintf(buffer, len, "\"%s\" %s", CRASH_RUN, cmd);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
514
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
515 system(buffer);
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
516 buffer=loadFile(TLOG);
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
517
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
518 if(strstr(buffer, "EXIT CODE: 0")){
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
519 return EXIT_SUCCESS;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
520 }else if(strstr(buffer, "EXIT CODE: 256")
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
521 || strstr(buffer, "EXIT CODE: timeout"))
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
522 {
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
523 return EXIT_FAILURE;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
524 }else{
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
525 return RAND_MAX;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
526 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
527 #else
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
528
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
529 #error comment me out, if your test cases produce neither eternal loops nor Access Violations
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
530 int i = system(cmd);
703
8dc894322ce8 repos maintenance
thomask
parents: 697
diff changeset
531 fprintf(stderr, "EXIT CODE: %i\n", i);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
532 return i;
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
533
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
534 #endif /* USE_POSIX else */
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
535 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
536
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
537
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
538 int main(int argc, char* arg[]){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
539 char* compiler; /* the compiler - from enviroment flag "DMD" */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
540 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
541 char* buffer; /* general purpose buffer */
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
542 size_t bufferLen;
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
543 int modus; /* test modus: RUN NORUN COMPILE NOCOMPILE */
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
544 int res; /* return code from external executions */
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
545 char* case_file;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
546 char* error_file; /* expected sourcefile containing the error */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
547 char* error_line; /* expected error line */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
548 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
549 char* gdb; /* the debugger - from environment flag "GDB" */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
550 char* gdb_script; /* gdb command sequence */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
551 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
552 #ifdef REG_EXTENDED
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
553 regex_t* gdb_pattern;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
554 #endif
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
555 int good_gdb; /* (gdb test and positive) or (no gdb test)*/
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
556
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
557 compiler = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
558 cmd_arg_case = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
559 buffer = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
560 bufferLen = 0;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
561 modus = -1;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
562 res = -1;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
563 case_file = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
564 error_file = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
565 error_line = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
566 good_error = -1;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
567 gdb = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
568 gdb_script = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
569 gdb_pattern_raw = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
570 #ifdef REG_EXTENDED
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
571 gdb_pattern = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
572 #endif
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
573 good_gdb = -1;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
574
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
575 /* check arguments */
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
576 if(argc != 3){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
577 err:
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
578 fprintf(stderr, "DStress test executer (revision 853)\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
579 "Copyright by Thomas Kuehne <thomas@kuehne.cn> 2005\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
580 "\n");
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
581
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
582 if(argc!=0)
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
583 fprintf(stderr,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
584 "%s <run|norun|compile|nocompile> <source>\n",
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
585 arg[0]);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
586 else
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
587 fprintf(stderr,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
588 "dstress <run|norun|compile|nocompile>"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
589 " <source>\n");
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
590
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
591 fprintf(stderr,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
592 "\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
593 "== eniroment settings (usually $NAME or %%NAME%%) ==\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
594 "* DMD - compiler (including standard arguments)\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
595 "* GDB - debugger (including standard arguments)\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
596 "\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
597 "== case setting (line in the case source) ==\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
598 "* __DSTRESS_DFLAGS__ - additional compiler arguments\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
599 "only evaluated if it is a \"nocompile\" or \"norun\" test:\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
600 "* __DSTRESS_ELINE__ - expected source line to throw an error message\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
601 "* __DSTRESS_EFILE__ - expected source file to throw an error message\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
602 " (defaults to the case file)\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
603 "only evaluated if it is a \"run\" or \"norun\" test:\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
604 "* __GDB_SCRIPT__ - command sequence to feed to the debugger\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
605 " (use \\n to encode a line break)\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
606 "* __GDB_PATTERN__ - expected regular expression in the debugger's\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
607 " output\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
608 "== note ==\n"
710
8cba64b24615 fixed typo
thomask
parents: 707
diff changeset
609 "* the current directory is required to contain the sub-directory \"obj\"\n"
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
610 " (used for temporary files)\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
611 );
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
612 exit(EXIT_FAILURE);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
613 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
614
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
615 if(0==strcmp(arg[1], "run")){
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
616 modus = RUN;
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
617 }else if(0==strcmp(arg[1], "norun")){
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
618 modus = NORUN;
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
619 }else if(0==strcmp(arg[1], "compile")){
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
620 modus = COMPILE;
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
621 }else if(0==strcmp(arg[1], "nocompile")){
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
622 modus = NOCOMPILE;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
623 }else{
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
624 goto err;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
625 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
626
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
627 /* gen flags */
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
628 case_file = cleanPathSeperator(strdup(arg[2]));
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
629 compiler = getCompiler();
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
630 gdb = getGDB();
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
631 buffer = loadFile(case_file);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
632
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
633 cmd_arg_case = getCaseFlag(buffer, "__DSTRESS_DFLAGS__");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
634 error_line = getCaseFlag(buffer, "__DSTRESS_ELINE__");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
635 error_file = getCaseFlag(buffer, "__DSTRESS_EFILE__");
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
636 gdb_script = getCaseFlag(buffer, "__GDB_SCRIPT__");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
637 gdb_pattern_raw = getCaseFlag(buffer, "__GDB_PATTERN__");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
638
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
639
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
640 /* set implicit source file */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
641 if(strcmp(error_line, "")!=0 && strcmp(error_file, "")==0){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
642 error_file=case_file;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
643 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
644
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
645 /* gdb pattern */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
646 #ifdef REG_EXTENDED
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
647 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
648
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
649 gdb_pattern = malloc(sizeof(regex_t));
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
650 if(regcomp(gdb_pattern, gdb_pattern_raw, REG_EXTENDED)){
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
651 fprintf(stderr, "failed to compile regular expression:"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
652 "\n\t%s\n", gdb_pattern_raw);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
653 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
654 }else if(gdb_script==NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
655 fprintf(stderr, "GDB pattern without GDB script\n");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
656 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
657 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
658 }else{
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
659 gdb_pattern = NULL;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
660 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
661
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
662 /* gdb script */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
663 if(gdb_script!=NULL && gdb_script[0]!='\x00'){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
664 if(gdb_pattern==NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
665 fprintf(stderr, "GDB script without GDB pattern\n");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
666 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
667 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
668 buffer=gdb_script;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
669 for(; *buffer; buffer++){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
670 if(buffer[0]=='\\'){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
671 if(buffer[1]=='n'){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
672 buffer[0]=' ';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
673 buffer[1]='\n';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
674 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
675 buffer++;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
676 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
677 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
678
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
679 bufferLen = strlen(gdb_script)+11;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
680 buffer=malloc(bufferLen);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
681 snprintf(buffer, bufferLen, "%s\n\nquit\ny\n\n", gdb_script);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
682 gdb_script=buffer;
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
683 good_gdb = 0;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
684 }else{
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
685 good_gdb = 1;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
686 gdb_script = NULL;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
687 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
688
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
689 #else
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
690
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
691 if(gdb_script && strlen(gdb_script)){
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
692 if(gdb_pattern_raw && strlen(gdb_pattern_raw)){
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
693 fprintf(stderr, "WARNING: debugger/regex support inactive\n");
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
694 }else{
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
695 fprintf(stderr, "debugger script without debugger pattern\n");
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
696 exit(EXIT_FAILURE);
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
697 }
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
698 }else if(gdb_pattern_raw && strlen(gdb_pattern_raw)){
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
699 fprintf(stderr, "debugger pattern without debugger script\n");
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
700 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
701 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
702
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
703 #endif /* REG_EXTENDED else */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
704
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
705
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
706
493
1418f225a81e disabled debug output
thomask
parents: 490
diff changeset
707 #ifdef DEBUG
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
708 fprintf(stderr, "case: \"%s\"\n", case_file);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
709 fprintf(stderr, "compiler: \"%s\"\n", compiler);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
710 fprintf(stderr, "DFLAGS C: \"%s\"\n", cmd_arg_case);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
711 fprintf(stderr, "ELINE : \"%s\"\n", error_line);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
712 fprintf(stderr, "EFILE : \"%s\"\n", error_file);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
713 fprintf(stderr, "GDB Scri: \"%s\"\n", gdb_script);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
714 fprintf(stderr, "GDB Patt: \"%s\"\n", gdb_pattern_raw);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
715 #endif
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
716
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
717 /* start working */
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
718 if(modus==COMPILE || modus==NOCOMPILE){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
719 /* gen command */
693
cfe101f6f1f3 fixed snprintf statement (hrr....)
thomask
parents: 685
diff changeset
720 bufferLen = strlen(compiler)+strlen(cmd_arg_case)
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
721 +strlen(OBJ)+strlen(case_file)+strlen(TLOG)+21;
693
cfe101f6f1f3 fixed snprintf statement (hrr....)
thomask
parents: 685
diff changeset
722 buffer = malloc(bufferLen);
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
723 snprintf(buffer, bufferLen, "%s %s ", compiler, cmd_arg_case);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
724
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
725 if(NULL==strstr(buffer, "-od")){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
726 snprintf(buffer, bufferLen,
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
727 "%s %s -od%s -c %s 1> %s 2>&1",
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
728 compiler, cmd_arg_case, OBJ, case_file, TLOG);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
729 }else{
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
730 snprintf(buffer, bufferLen, "%s %s -c %s 1> %s 2>&1",
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
731 compiler, cmd_arg_case, case_file, TLOG);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
732 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
733
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
734 /* test */
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
735 if(modus==COMPILE){
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
736 fprintf(stderr, "compile: %s\n", buffer);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
737 }else{
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
738 fprintf(stderr, "nocompile: %s\n", buffer);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
739 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
740 res = crashRun(buffer);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
741
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
742 /* diagnostic */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
743 buffer = loadFile(TLOG);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
744 fprintf(stderr, "%s\n", buffer);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
745 good_error = checkErrorMessage(error_file, error_line, buffer);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
746
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
747 if(hadExecCrash(buffer)){
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
748 printf("ERROR:\t%s [internal compiler error]\n",
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
749 case_file);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
750 }else if(modus==COMPILE){
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
751 if(res==EXIT_SUCCESS){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
752 printf("PASS: \t%s\n", case_file);
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
753 }else if(res==EXIT_FAILURE && good_error){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
754 if(checkErrorMessage(case_file, "", buffer)){
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
755 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
756 }else{
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
757 printf("ERROR:\t%s%s\n", case_file,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
758 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
759 }
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
760 }else{
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
761 printf("ERROR:\t%s%s\n", case_file,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
762 errorMsg(good_error));
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
763 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
764 }else{
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
765 if(res==EXIT_FAILURE){
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
766 if(good_error){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
767 printf("XFAIL:\t%s\n", case_file);
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
768 }else{
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
769 printf("FAIL: \t%s%s\n", case_file,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
770 errorMsg(good_error));
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
771 }
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
772 }else if(res==EXIT_SUCCESS){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
773 printf("XPASS:\t%s\n", case_file);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
774 }else{
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
775 printf("ERROR:\t%s\n", case_file);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
776 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
777 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
778 fprintf(stderr,"--------\n");
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
779 }else if(modus==RUN || modus==NORUN){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
780 /* gen command */
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
781
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
782 bufferLen = strlen(compiler)+strlen(cmd_arg_case)
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
783 +strlen(OBJ)
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
784 +strlen(case_file)*2+strlen(TLOG)+64;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
785 buffer = malloc(bufferLen);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
786 snprintf(buffer, bufferLen, "%s %s ", compiler, cmd_arg_case);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
787
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
788 if(NULL==strstr(buffer, "-od")){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
789 if(NULL==strstr(buffer, "-of")){
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
790 snprintf(buffer, bufferLen,
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
791 "%s %s -od%s -of%s.exe %s 1> %s 2>&1",
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
792 compiler, cmd_arg_case, OBJ, case_file,
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
793 case_file, TLOG);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
794 }else{
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
795 snprintf(buffer, bufferLen,
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
796 "%s %s -od%s %s 1> %s 2>&1",
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
797 compiler, cmd_arg_case, OBJ, case_file,
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
798 TLOG);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
799 }
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
800 }else if(NULL==strstr(buffer, "-of")){
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
801 snprintf(buffer, bufferLen,
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
802 "%s %s -of%s.exe %s 1> %s 2>&1",
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
803 compiler, cmd_arg_case, case_file, case_file,
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
804 TLOG);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
805 }else{
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
806 snprintf(buffer, bufferLen, "%s %s %s 1> %s 2>&1",
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
807 compiler, cmd_arg_case, case_file, TLOG);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
808 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
809
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
810 /* test 1/3 - compile */
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
811 if(modus==RUN){
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
812 fprintf(stderr, "run: %s\n", buffer);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
813 }else{
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
814 fprintf(stderr, "norun: %s\n", buffer);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
815 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
816 res = crashRun(buffer);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
817
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
818 /* diagnostic 1/3 */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
819 buffer = loadFile(TLOG);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
820 fprintf(stderr, "%s", buffer);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
821
676
f90958db522d extended debug output
thomask
parents: 639
diff changeset
822 if(modus==RUN){
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
823 good_error = checkErrorMessage(error_file, error_line,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
824 buffer);
676
f90958db522d extended debug output
thomask
parents: 639
diff changeset
825 }else{
f90958db522d extended debug output
thomask
parents: 639
diff changeset
826 good_error = 1;
f90958db522d extended debug output
thomask
parents: 639
diff changeset
827 }
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
828 if(hadExecCrash(buffer)){
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
829 printf("ERROR:\t%s [internal compiler error]\n",
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
830 case_file);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
831 fprintf(stderr, "\n--------\n");
437
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
832 return EXIT_SUCCESS;
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
833 }else if(res==EXIT_FAILURE && good_error){
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
834 printf("FAIL: \t%s\n", case_file);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
835 fprintf(stderr, "\n--------\n");
437
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
836 return EXIT_SUCCESS;
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
837 }else if(res!=EXIT_SUCCESS){
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
838 printf("ERROR:\t%s%s\n", case_file,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
839 errorMsg(good_error));
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
840 fprintf(stderr, "\n--------\n");
437
1b4034b27e93 added "[bad error message]" output
thomask
parents: 436
diff changeset
841 return EXIT_SUCCESS;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
842 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
843
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
844 /* test 2/3 - run */
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
845 bufferLen = strlen(case_file) + strlen(TLOG) + 30;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
846 buffer = malloc(bufferLen);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
847 snprintf(buffer, bufferLen, "%s.exe 1> %s 2>&1\n", case_file,
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
848 TLOG);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
849 fprintf(stderr, "%s\n", buffer);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
850 res=crashRun(buffer);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
851
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
852 /* diagnostic 2/3 */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
853 buffer = loadFile(TLOG);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
854 fprintf(stderr, "%s\n", buffer);
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
855 if(modus==NORUN){
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
856 good_error = checkRuntimeErrorMessage(error_file,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
857 error_line, buffer);
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
858 }else{
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
859 good_error = 1;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
860 }
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
861
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
862 #ifdef REG_EXTENDED
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
863 if(!good_gdb){
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
864 /* test 3/3 - gdb */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
865 writeFile(GDB_SCRIPTER, gdb_script);
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
866 bufferLen = strlen(gdb) + strlen(case_file)
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
867 + strlen(GDB_SCRIPTER) + strlen(TLOG) + 20;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
868 snprintf(buffer, bufferLen, "%s %s.exe < %s > %s 2>&1",
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
869 gdb, case_file, GDB_SCRIPTER, TLOG);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
870 fprintf(stderr, "%s\n", buffer);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
871 if(EXIT_SUCCESS==crashRun(buffer)){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
872 /* diagnostic 3/3 */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
873 buffer = loadFile(TLOG);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
874 fprintf(stderr, "%s\n", buffer);
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
875 good_gdb = (regexec(
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
876 gdb_pattern, buffer, 0, NULL, 0
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
877 )==0);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
878 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
879 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
880 #endif /* REG_EXTENDED */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
881
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
882 if(modus==RUN){
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
883 if(hadExecCrash(buffer)){
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
884 printf("ERROR:\t%s [test case crash]%s%s",
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
885 case_file, errorMsg(good_error),
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
886 gdbMsg(good_gdb));
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
887 }else if(res==EXIT_SUCCESS && good_gdb){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
888 printf("PASS: \t%s\n", case_file);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
889 }else if(res==EXIT_FAILURE && good_error && good_gdb){
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
890 printf("FAIL: \t%s\n", case_file);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
891 }else{
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
892 printf("ERROR:\t%s%s%s\n", case_file,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
893 errorMsg(good_error), gdbMsg(good_gdb));
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
894 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
895 }else{
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
896 if(res==EXIT_SUCCESS && good_gdb){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
897 printf("XPASS:\t%s%s\n", case_file, gdbMsg(good_gdb));
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
898 }else if(good_error && good_gdb){
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
899 printf("XFAIL:\t%s%s%s\n", case_file,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
900 errorMsg(good_error), gdbMsg(good_gdb));
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
901 }else{
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
902 printf("FAIL:\t%s%s%s\n", case_file,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
903 errorMsg(good_error), gdbMsg(good_gdb));
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
904 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
905 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
906 fprintf(stderr, "--------\n");
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
907 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
908 printf("@bug@ %d (%s)\n", modus, case_file);
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
909 return EXIT_FAILURE;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
910 }
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
911 return EXIT_SUCCESS;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
912 }