annotate dstress.c @ 742:5906350b5048

fixed misplaced #endif for Windows systems
author thomask
date Sat, 12 Nov 2005 21:57:32 +0000
parents d4edcc124e64
children 0e3682dad93a
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
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
35 /* number's choice: XOR and printf :) */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
36 #define MODE_RUN (0x10000)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
37 #define MODE_NORUN (0x1000)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
38 #define MODE_COMPILE (0x100)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
39 #define MODE_NOCOMPILE (0x10)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
40 #define MODE_TORTURE (0x2)
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
41
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
42 #define RES_BASE_MASK (0xFFFFFF0)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
43 #define RES_PASS (0x1000000)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
44 #define RES_XFAIL (0x100000)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
45 #define RES_XPASS (0x10000)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
46 #define RES_FAIL (0x1000)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
47 #define RES_ERROR (0x100)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
48 #define RES_UNTESTED (0x10)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
49 #define RES_BAD_GDB (0x4)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
50 #define RES_BAD_MSG (0x2)
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
51
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
52 #if defined(__GNU_LIBRARY__) || defined(__GLIBC__)
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
53 #define USE_POSIX 1
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
54 #endif
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
55
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
56 #if defined(linux) || defined(__FreeBSD__) || defined(__OpenBSD__)
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
57 #define USE_POSIX 1
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
58 #endif
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
59
273
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
60 #if defined(__APPLE__) && defined(__MACH__)
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
61 #define USE_POSIX 1
273
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
62 #endif
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
63
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
64 #if defined(WIN) || defined(WIN32)
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
65 #define USE_WINDOWS 1
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
66 #endif
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
67
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
68 /* 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
69 #ifdef USE_POSIX
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
70
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
71 #include <sys/types.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
72 #include <sys/stat.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
73 #include <fcntl.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
74 #include <unistd.h>
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
75 #include <regex.h>
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
76 #include <stdint.h>
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
77 #include <limits.h>
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
78
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
79 /* not every STDLIB supports C99's "%z" for printf formating */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
80 #if PTRDIFF_MAX == INT_MAX
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
81 #define ZU "%u"
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
82 #else
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
83 #if PTRDIFF_MAX == LONG_MAX
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
84 #define ZU "%lu"
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
85 #else
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
86 #if PTRDIFF_MAX == SHRT_MAX
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
87 #define ZU "%hu"
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
88 #else
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
89 #error what is the size of a pointer?
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
90 #endif
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
91 #endif
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
92 #endif
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
93 #else
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
94 #ifdef USE_WINDOWS
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
95
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
96 #include <windows.h>
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
97 #define snprintf _snprintf
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
98 #ifndef INVALID_FILE_SIZE
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
99 #define INVALID_FILE_SIZE (-1)
742
5906350b5048 fixed misplaced #endif for Windows systems
thomask
parents: 734
diff changeset
100 #endif
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
101
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
102 /* not every STDLIB supports C99's "%z" for printf formating */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
103 #ifdef win32
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
104 #define ZU "%u"
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
105 #else
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
106 #ifdef win64
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
107 #define ZU "%llu"
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
108 #else
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
109 #error what is the size of a pointer?
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
110 #endif
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
111 #endif
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
112
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
113 #else
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
114 #error neither POSIX nor MSWindows API detected
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
115 #endif /* USE_WINDOWS else */
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
116 #endif /* USE_POSIX else */
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
117
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
118 #define TORTURE_PREFIX "torture-"
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
119
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
120 #ifdef USE_POSIX
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
121 #define CRASH_RUN "./crashRun"
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
122 #define TMP_DIR "./obj"
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
123 #else
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
124 #ifdef USE_WINDOWS
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
125 #define CRASH_RUN ".\\crashRun"
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
126 #define TMP_DIR ".\\obj"
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
127 #else
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
128 #error OS dependent file names not defined
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
129 #endif
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
130 #endif
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
131
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
132 const char* torture[] = {
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
133 "",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
134
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
135 "-g", "-inline", "-fPIC", "-O", "-release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
136
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
137 "-g -inline", "-g -fPIC", "-g -O", "-g -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
138 "-inline -fPIC", "-inline -O", "-inline -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
139 "-fPIC -O", "-fPIC -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
140 "-O -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
141
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
142 "-g -inline -fPIC", "-g -inline -O", "-g -inline -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
143 "-g -fPIC -O", "-g -fPIC -release", "-g -O -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
144 "-inline -fPIC -O", "-inline -fPIC -release", "-inline -O -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
145 "-fPIC -O -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
146
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
147 "-g -inline -fPIC -O", "-g -inline -fPIC -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
148 "-g -fPIC -O -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
149 "-inline -fPIC -O -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
150
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
151 "-g -inline -fPIC -O -release"
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
152 };
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
153
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
154 /* secure malloc */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
155 void *xmalloc(size_t size){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
156 void *p = malloc(size);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
157 if (p == NULL){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
158 fprintf(stderr, "Failed to allocate " ZU " bytes!\n", size);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
159 exit(EXIT_FAILURE);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
160 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
161 return p;
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
162 }
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
163 #define malloc xmalloc
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
164
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
165 /* secure calloc */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
166 void* xcalloc(size_t members, size_t size){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
167 void* ptr = calloc(members, size);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
168 if(ptr == NULL){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
169 fprintf(stderr, "Failed to allocate " ZU " elements"
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
170 "(" ZU " bytes each)!\n", members, size);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
171 exit(EXIT_FAILURE);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
172 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
173 return ptr;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
174 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
175 #define calloc xcalloc
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
176
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
177
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
178 void printResult(int result, int modus, char* case_file, FILE* stream){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
179 char* msg = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
180 #ifdef DEBUG
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
181 fprintf(stderr, "case: %s, modus: %x, result: %x\n", case_file, modus,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
182 result);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
183 #endif
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
184
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
185 if(result & RES_PASS){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
186 msg = "PASS: ";
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
187 }else if(result & RES_XFAIL){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
188 msg = "XFAIL:";
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
189 }else if(result & RES_XPASS){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
190 msg = "XPASS:";
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
191 }else if(result & RES_FAIL){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
192 msg = "FAIL: ";
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
193 }else if(result & RES_ERROR){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
194 msg = "ERROR:";
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
195 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
196
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
197 fprintf(stream, "%s\t%s%s%s\n", msg, case_file,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
198 (result & RES_BAD_MSG) ? " [bad error message]" : "",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
199 (result & RES_BAD_GDB) ? " [bad debugger message]" : "");
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
200 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
201
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
202 char* strip(char* buffer){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
203 char* tmp = NULL;
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
204
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
205 if(buffer!=NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
206 while(isspace(buffer[0])){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
207 buffer++;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
208 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
209
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
210 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
211 tmp[0]='\x00';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
212 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
213 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
214 return buffer;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
215 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
216
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
217 unsigned int genTempFileNameCount;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
218 char* genTempFileName(){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
219 char* back;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
220 size_t len;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
221
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
222 len = strlen(TMP_DIR) + 128;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
223 back = malloc(len);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
224
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
225 snprintf(back, len, "%s/t%x-%x-%x.tmp", TMP_DIR, getpid(), rand(), ++genTempFileNameCount);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
226
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
227 return back;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
228 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
229
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
230 /* cleanup "/" versus "\" in filenames */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
231 char* cleanPathSeperator(char* filename){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
232 char* pos = NULL;
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
233 #ifdef USE_POSIX
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
234 for(pos=strchr(filename, '\\'); pos; pos=strchr(filename, '\\')){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
235 *pos='/';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
236 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
237 #else
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
238 #if USE_WINDOWS
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
239 for(pos=strchr(filename, '/'); pos; pos=strchr(filename, '/')){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
240 *pos='\\';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
241 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
242 #else
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
243
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
244 #error no cleanPathSeperator available for this system
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
245
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
246 #endif /* USE_WINDOWS else */
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
247 #endif /* USE_POSIX else */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
248 return filename;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
249 }
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
250
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
251 char* loadFile(char* filename){
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
252 #ifdef USE_POSIX
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
253 char* back;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
254 struct stat fileInfo;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
255 int file = open(filename, O_RDONLY);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
256
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
257 back = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
258
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
259 if(errno == 0 && file != 0 && file != -1){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
260 if(0==fstat(file, &fileInfo)){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
261 back=malloc(fileInfo.st_size+1);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
262 fileInfo.st_size = read(file, back, fileInfo.st_size);
440
dc186d1266ba fixed handling of empty files
thomask
parents: 439
diff changeset
263 if(fileInfo.st_size>=0){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
264 *(back+fileInfo.st_size) = '\x00';
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
265 }else{
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
266 back = NULL;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
267 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
268 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
269 close(file);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
270 }
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
271
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
272 if(back){
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
273 return back;
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
274 }
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
275
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
276 fprintf(stderr, "File not found \"%s\" (%s)\n", filename, strerror(errno));
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
277 exit(EXIT_FAILURE);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
278 #else /* USE_POSIX */
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
279 #ifdef USE_WINDOWS
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
280 /* @todo@ check for 32bit/64bit */
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
281 char* back;
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
282 DWORD size, numread;
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
283 HANDLE file=CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
284 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
285
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
286 back = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
287 size = 0;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
288 numread = 0;
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
289 if (file != INVALID_HANDLE_VALUE){
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
290 size = GetFileSize(file, NULL);
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
291 if (size != INVALID_FILE_SIZE){
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
292 back=malloc((size+1)*sizeof(char));
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
293 if (ReadFile(file,back,size,&numread,NULL) == 1){
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
294 if (numread==size){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
295 *(back+size) = '\x00';
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
296 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
297 back = NULL;
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
298 }
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
299 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
300 back = NULL;
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
301 }
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
302 }
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
303 CloseHandle(file);
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
304 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
305 if(back){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
306 errno = 0;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
307 return back;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
308 }
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
309
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
310 fprintf(stderr, "File not found \"%s\"\n", filename);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
311 exit(EXIT_FAILURE);
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
312 #else /* USE_WINDOWS */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
313
707
5ba45899cddd minor infrastructure fixes
thomask
parents: 704
diff changeset
314 #error no loadFile implementation present
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
315
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
316 #endif /* USE_WINDOWS */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
317 #endif /* USE_POSIX else */
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
318 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
319
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
320 void writeFile(const char* filename, const char* content){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
321 size_t len;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
322 FILE* file;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
323
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
324 len = strlen(content);
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
325 errno = 0;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
326 file = fopen(filename, "w+");
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
327
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
328 if(errno == 0 && file != NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
329 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
330 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
331 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
332 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
333 if(fclose(file) || (errno != 0)){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
334 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
335 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
336 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
337 return;
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
338 }
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
339
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
340 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
341 exit(EXIT_FAILURE);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
342 }
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
343
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
344 /* query the environment for the compiler name */
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
345 char* getCompiler(void){
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
346 char* back = getenv("DMD");
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
347
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
348 if(back==NULL){
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
349 back = "dmd";
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
350 }
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
351
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
352 return strip(cleanPathSeperator(back));
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
353 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
354
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
355 /* query the environment for the debugger name */
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
356 char* getGDB(void){
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
357 char* back = getenv("GDB");
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
358
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
359 if(back==NULL){
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
360 back = "gdb";
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
361 }
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
362
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
363 return strip(cleanPathSeperator(back));
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
364 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
365
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
366 char* getTortureBlock(void){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
367 char* back = getenv("DSTRESS_TORTURE_BLOCK");
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
368
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
369 if(back!=NULL){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
370 back = strip(back);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
371 if(strlen(back)<1){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
372 back = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
373 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
374 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
375
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
376 return back;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
377 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
378
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
379 /* 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
380 char* getCaseFlag(const char* data, const char* tag){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
381 char* begin;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
382 char* end1;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
383 char* end2;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
384 char* back;
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
385
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
386 begin = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
387 end1 = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
388 end2 = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
389 back = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
390
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
391 if(data!=NULL && tag!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
392 begin = strstr(data, tag);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
393 if(begin!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
394 begin = begin+strlen(tag);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
395 end1 = strstr(begin, "\n");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
396 end2 = strstr(begin, "\r");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
397 if(end2!=NULL && ((end1!=NULL && end2<end1) || end1==NULL)){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
398 end1=end2;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
399 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
400 if(end1==NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
401 end1 = begin + strlen(begin);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
402 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
403 back = malloc(end1-begin+1);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
404 strncpy(back, begin, end1-begin);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
405 back[end1-begin]='\x00';
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
406 return strip(cleanPathSeperator(back));
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
407 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
408 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
409
429
1185c50d4b08 fix dstress.c's memory handling
thomask
parents: 405
diff changeset
410 return calloc(1,1);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
411 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
412
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
413 /* check compile-time error messages */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
414 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
415
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
416 char* file;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
417 char* line;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
418 char* dmd;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
419 char* gdc;
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
420 size_t len;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
421 int back;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
422
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
423 file = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
424 line = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
425 dmd = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
426 gdc = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
427 len = 0;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
428 back = 0;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
429
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
430 /* clean arguments */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
431 if(strcmp(file_, "")!=0){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
432 len = strlen(file_)+1;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
433 file = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
434 strncpy(file, file_, len);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
435 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
436
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
437 if(strcmp(line_, "")!=0){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
438 len = strlen(line_)+1;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
439 line = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
440 strncpy(line, line_, len);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
441 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
442
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
443 /* gen patterns*/
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
444 if(file!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
445 if(line!=NULL){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
446 len = strlen(file)+strlen(line)+5;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
447 dmd = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
448 snprintf(dmd, len, "%s(%s)", file, line);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
449
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
450 gdc = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
451 snprintf(gdc, len, "%s:%s: ", file, line);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
452 }else{
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
453 len = strlen(file)+2;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
454 dmd = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
455 snprintf(dmd, len, "%s(", file);
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
456
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
457 gdc = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
458 snprintf(gdc, len, "%s:", file);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
459 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
460 }else if(line!=NULL){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
461 len = strlen(line)+5;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
462 dmd = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
463 snprintf(dmd, len, "(%s): ", line);
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
464
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
465 gdc = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
466 snprintf(gdc, len, ":%s: ", line);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
467 }else{
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
468 return 1;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
469 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
470
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
471 /* specific error messages */
676
f90958db522d extended debug output
thomask
parents: 639
diff changeset
472 #ifdef DEBUG
f90958db522d extended debug output
thomask
parents: 639
diff changeset
473 fprintf(stderr, "pattern(dmd):\t%s\n", dmd);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
474 fprintf(stderr, "pattern(gdc):\t%s\n", gdc);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
475 #endif
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
476
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
477 if( (dmd!=NULL && strstr(buffer, dmd))
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
478 || (gdc!=NULL && strstr(buffer, gdc))
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
479 || (dmd==NULL && gdc==NULL)){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
480 back=1;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
481 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
482
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
483 return back;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
484 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
485
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
486 int checkRuntimeErrorMessage(const char* file_, const char* line_, const char* buffer){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
487 /* PhobosLong dir/file.d(2)
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
488 * Phobos package.module(2)
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
489 */
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
490
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
491 char* file;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
492 char* line;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
493 char* phobos;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
494 char* phobosLong;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
495
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
496 char* begin;
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
497 char* end;
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
498 size_t len;
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
499
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
500 int back=0;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
501
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
502 file = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
503 line = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
504 phobos = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
505 phobosLong = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
506
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
507 begin = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
508 end = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
509 len = 0;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
510
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
511 /* clean arguments */
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
512 if(strcmp(file_, "")!=0){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
513 len = strlen(file_)+1;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
514 file = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
515 strncpy(file, file_, len);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
516 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
517
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
518 if(strcmp(line_, "")!=0){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
519 len = strlen(line_)+1;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
520 line = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
521 strncpy(line, line_, len);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
522 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
523
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
524 /* gen patterns*/
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
525 if(file!=NULL){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
526 if(line!=NULL){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
527 len = strlen(file)+strlen(line)+5;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
528 phobos = malloc(len);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
529 begin=strrchr(file,'/');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
530 if(begin){
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
531 begin++;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
532 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
533 begin=strrchr(file,'\\');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
534 if(begin){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
535 begin++;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
536 }else{
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
537 begin=file;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
538 }
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
539 }
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
540 end=strrchr(file,'.');
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
541 strncat(phobos, begin, end-begin);
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
542 snprintf(phobos, len, "%.*s(%s)",
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
543 (int)(end-begin), begin,
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
544 line);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
545
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
546 phobosLong = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
547 snprintf(phobosLong, len, "%s(%s)", file, line);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
548 }else{
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
549 len = strlen(file)+2;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
550 phobos = malloc(len);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
551 begin=strrchr(file,'/');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
552 if(begin){
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
553 begin++;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
554 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
555 begin=strrchr(file,'\\');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
556 if(begin){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
557 begin++;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
558 }else{
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
559 begin=file;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
560 }
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
561 }
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
562 end=strrchr(file,'.');
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
563 snprintf(phobos, len, "%.*s(", (int)(end-begin), begin);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
564
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
565 phobosLong = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
566 snprintf(phobosLong, len, "%s(", file);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
567 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
568 }else if(line!=NULL){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
569 len = strlen(line)+3;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
570 phobos = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
571 snprintf(phobos, len, "(%s)", line);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
572
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
573 phobosLong=NULL;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
574 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
575 return 1;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
576 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
577
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
578 /* specific error messages */
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
579
676
f90958db522d extended debug output
thomask
parents: 639
diff changeset
580 #ifdef DEBUG
f90958db522d extended debug output
thomask
parents: 639
diff changeset
581 fprintf(stderr, "pattern(phobosShort):\t%s\n", phobos);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
582 fprintf(stderr, "pattern(phobosLong):\t%s\n", phobosLong);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
583 #endif
f90958db522d extended debug output
thomask
parents: 639
diff changeset
584
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
585 if( (phobos && strstr(buffer, phobos))
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
586 || (phobosLong && strstr(buffer, phobosLong)))
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
587 {
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
588 back=1;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
589 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
590
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
591 return back;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
592 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
593
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
594 int hadExecCrash(const char* buffer){
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
595 if(strstr(buffer, "Segmentation fault")
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
596 || strstr(buffer, "Internal error")
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
597 || strstr(buffer, "gcc.gnu.org/bugs")
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
598 || strstr(buffer, "EXIT CODE: signal"))
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
599 {
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
600 return 1;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
601 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
602 return 0;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
603 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
604
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
605 /* system call with time-out */
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
606 int crashRun(const char* cmd, char** logFile){
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
607 #ifdef USE_POSIX
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
608 size_t len;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
609 char* buffer;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
610
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
611 *logFile = genTempFileName();
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
612
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
613 len = 20 + strlen(CRASH_RUN) + strlen(cmd) + strlen(*logFile);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
614 buffer = malloc(len);
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
615
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
616 snprintf(buffer, len, "\"%s\" %s > %s 2>&1", CRASH_RUN, cmd, *logFile);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
617
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
618 system(buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
619 buffer=loadFile(*logFile);
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
620
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
621 if(strstr(buffer, "EXIT CODE: 0")){
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
622 return EXIT_SUCCESS;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
623 }else if(strstr(buffer, "EXIT CODE: 256")
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
624 || strstr(buffer, "EXIT CODE: timeout"))
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
625 {
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
626 return EXIT_FAILURE;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
627 }else{
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
628 return RAND_MAX;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
629 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
630 #else
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
631
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
632 #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
633 int i = system(cmd);
703
8dc894322ce8 repos maintenance
thomask
parents: 697
diff changeset
634 fprintf(stderr, "EXIT CODE: %i\n", i);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
635 return i;
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
636
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
637 #endif /* USE_POSIX else */
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
638 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
639
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
640 int target_compile(int modus, char* compiler, char* arguments, char* case_file,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
641 char* error_file, char* error_line)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
642 {
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
643 size_t bufferLen;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
644 char* buffer;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
645 int res;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
646 int testResult;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
647 int good_error;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
648 char* logFile;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
649
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
650 bufferLen = 0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
651 buffer = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
652 res = -1;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
653 testResult = -1;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
654 good_error = 0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
655 logFile = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
656
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
657 if(!(modus & MODE_COMPILE) && !(modus & MODE_NOCOMPILE)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
658 fprintf(stderr, "BUG: badly handled mode %i (->compile)\n",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
659 modus);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
660 exit(EXIT_FAILURE);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
661 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
662
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
663 /* gen command */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
664 bufferLen = strlen(compiler) + strlen(arguments) + strlen(TMP_DIR)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
665 + strlen(case_file) + 21;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
666 buffer = malloc(bufferLen);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
667 snprintf(buffer, bufferLen, "%s %s ", compiler, arguments);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
668
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
669 if(NULL == strstr(buffer, "-od")){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
670 snprintf(buffer, bufferLen, "%s %s -od%s -c %s",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
671 compiler, arguments, TMP_DIR, case_file);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
672 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
673 snprintf(buffer, bufferLen, "%s %s -c %s",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
674 compiler, arguments, case_file);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
675 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
676
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
677 /* test */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
678 if(modus & MODE_COMPILE){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
679 fprintf(stderr, "compile: %s\n", buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
680 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
681 fprintf(stderr, "nocompile: %s\n", buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
682 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
683 res = crashRun(buffer, &logFile);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
684
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
685 /* diagnostic */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
686 buffer = loadFile(logFile);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
687 fprintf(stderr, "%s\n", buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
688 remove(logFile);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
689 good_error = checkErrorMessage(error_file, error_line, buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
690
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
691 if(hadExecCrash(buffer)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
692 testResult = RES_ERROR;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
693 }else if(modus & MODE_COMPILE){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
694 if(res == EXIT_SUCCESS){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
695 testResult = RES_PASS;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
696 }else if(res == EXIT_FAILURE){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
697 testResult = RES_FAIL | (good_error ? 0 : RES_BAD_MSG);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
698 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
699 testResult = RES_ERROR | (good_error ? 0 : RES_BAD_MSG);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
700 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
701 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
702 if(res == EXIT_FAILURE){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
703 if(good_error){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
704 testResult = RES_XFAIL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
705 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
706 testResult = RES_FAIL | RES_BAD_MSG;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
707 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
708 }else if(res == EXIT_SUCCESS){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
709 testResult = RES_XPASS;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
710 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
711 testResult = RES_ERROR;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
712 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
713 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
714
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
715 return testResult;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
716 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
717
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
718 int target_run(int modus, char* compiler, char* arguments, char* case_file,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
719 char* error_file, char* error_line
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
720 #ifdef REG_EXTENDED
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
721 , char* gdb, char* gdb_script, regex_t* gdb_pattern
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
722 #endif
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
723 )
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
724 {
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
725 size_t bufferLen;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
726 char* buffer;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
727 int res;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
728 int testResult;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
729 int good_error;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
730 char* logFile;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
731 char* gdb_scripter;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
732 int good_gdb;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
733
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
734 bufferLen = 0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
735 buffer = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
736 res = -1;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
737 testResult = -1;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
738 good_error = 0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
739 logFile = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
740 good_gdb = 0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
741 gdb_scripter = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
742
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
743 if(!(modus & MODE_RUN) && !(modus & MODE_NORUN)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
744 fprintf(stderr, "BUG: badly handled mode %i (->run)\n", modus);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
745 exit(EXIT_FAILURE);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
746 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
747
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
748 /* gen command */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
749
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
750 bufferLen = strlen(compiler) + strlen(arguments) + strlen(TMP_DIR)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
751 + strlen(case_file) * 2 + 64;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
752 buffer = malloc(bufferLen);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
753 snprintf(buffer, bufferLen, "%s %s ", compiler, arguments);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
754
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
755 if(NULL == strstr(buffer, "-od")){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
756 if(NULL == strstr(buffer, "-of")){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
757 snprintf(buffer, bufferLen,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
758 "%s %s -od%s -of%s.exe %s",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
759 compiler, arguments, TMP_DIR, case_file,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
760 case_file);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
761 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
762 snprintf(buffer, bufferLen,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
763 "%s %s -od%s %s",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
764 compiler, arguments, TMP_DIR, case_file);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
765 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
766 }else if(NULL == strstr(buffer, "-of")){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
767 snprintf(buffer, bufferLen,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
768 "%s %s -of%s.exe %s",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
769 compiler, arguments, case_file, case_file);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
770 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
771 snprintf(buffer, bufferLen, "%s %s %s",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
772 compiler, arguments, case_file);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
773 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
774
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
775 /* test 1/3 - compile */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
776 if(modus & MODE_RUN){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
777 fprintf(stderr, "run: %s\n", buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
778 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
779 fprintf(stderr, "norun: %s\n", buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
780 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
781 res = crashRun(buffer, &logFile);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
782
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
783 /* diagnostic 1/3 */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
784 buffer = loadFile(logFile);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
785 fprintf(stderr, "%s", buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
786 remove(logFile);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
787
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
788 if(modus & MODE_RUN){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
789 good_error = checkErrorMessage(error_file, error_line,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
790 buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
791 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
792 good_error = 1;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
793 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
794
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
795 if(hadExecCrash(buffer)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
796 return RES_ERROR;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
797 }else if((res == EXIT_FAILURE) && good_error){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
798 return RES_FAIL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
799 }else if(res!=EXIT_SUCCESS){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
800 return RES_ERROR | (good_error ? 0 : RES_BAD_MSG);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
801 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
802
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
803 /* test 2/3 - run */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
804 bufferLen = strlen(case_file) + 30;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
805 buffer = malloc(bufferLen);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
806 snprintf(buffer, bufferLen, "%s.exe", case_file);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
807 fprintf(stderr, "%s\n", buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
808 res=crashRun(buffer, &logFile);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
809
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
810 /* diagnostic 2/3 */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
811 buffer = loadFile(logFile);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
812 fprintf(stderr, "%s\n", buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
813 remove(logFile);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
814
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
815 if(modus & MODE_NORUN){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
816 good_error = checkRuntimeErrorMessage(error_file, error_line,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
817 buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
818 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
819 good_error = 1;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
820 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
821
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
822 #ifdef REG_EXTENDED
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
823 if(gdb_script != NULL){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
824 good_gdb = 0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
825 /* test 3/3 - gdb */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
826 gdb_scripter = genTempFileName();
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
827 writeFile(gdb_scripter, gdb_script);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
828 bufferLen = strlen(gdb) + strlen(case_file)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
829 + strlen(gdb_scripter) + 20;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
830 snprintf(buffer, bufferLen, "%s %s.exe < %s",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
831 gdb, case_file, gdb_scripter);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
832 fprintf(stderr, "%s\n", buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
833 if(EXIT_SUCCESS==crashRun(buffer, &logFile)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
834 /* diagnostic 3/3 */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
835 buffer = loadFile(logFile);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
836 fprintf(stderr, "%s\n", buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
837 good_gdb = (regexec(gdb_pattern, buffer, 0, NULL, 0)==0);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
838 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
839 remove(logFile);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
840 remove(gdb_scripter);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
841 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
842 good_gdb = 1;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
843 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
844 #endif /* REG_EXTENDED */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
845
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
846 if(modus & MODE_RUN){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
847 if(hadExecCrash(buffer)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
848 testResult = RES_ERROR;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
849 }else if((res==EXIT_SUCCESS) && good_gdb){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
850 testResult = RES_PASS;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
851 }else if((res==EXIT_FAILURE) && good_error && good_gdb){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
852 testResult = RES_FAIL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
853 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
854 testResult = RES_ERROR | (good_error ? 0 : RES_BAD_MSG)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
855 | (good_gdb ? 0 : RES_BAD_GDB);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
856 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
857 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
858 if(res==EXIT_SUCCESS){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
859 testResult = RES_XPASS;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
860 }else if(good_error && good_gdb){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
861 testResult = RES_XFAIL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
862 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
863 testResult = RES_FAIL | (good_error ? 0 : RES_BAD_MSG)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
864 | (good_gdb ? 0 : RES_BAD_GDB);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
865 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
866 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
867
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
868 return testResult;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
869 }
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
870
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
871 int main(int argc, char* arg[]){
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
872
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
873 char* compiler; /* the compiler - from enviroment flag "DMD" */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
874 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
875 char* buffer; /* general purpose buffer */
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
876 size_t bufferLen;
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
877 int index;
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
878 int modus; /* test modus: RUN NORUN COMPILE NOCOMPILE */
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
879 char* case_file;
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
880 int case_result;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
881 int torture_result[sizeof(torture)/sizeof(char*)];
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
882 char* torture_block_global;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
883 char* torture_block_case;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
884 char* torture_require;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
885 char* error_file; /* expected sourcefile containing the error */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
886 char* error_line; /* expected error line */
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
887 char* gdb; /* the debugger - from environment flag "GDB" */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
888 char* gdb_script; /* gdb command sequence */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
889 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
890 #ifdef REG_EXTENDED
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
891 regex_t* gdb_pattern;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
892 #endif
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
893
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
894 compiler = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
895 cmd_arg_case = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
896 buffer = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
897 bufferLen = 0;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
898 modus = -1;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
899 case_file = NULL;
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
900 torture_block_global = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
901 torture_block_case = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
902 torture_require = NULL;
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
903 error_file = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
904 error_line = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
905 gdb = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
906 gdb_script = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
907 gdb_pattern_raw = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
908 #ifdef REG_EXTENDED
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
909 gdb_pattern = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
910 #endif
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
911
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
912 /* check arguments */
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
913 if(argc != 3){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
914 err:
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
915 fprintf(stderr, "DStress test executer (revision 853)\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
916 "Copyright by Thomas Kuehne <thomas@kuehne.cn> 2005\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
917 "\n");
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
918
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
919 if(argc!=0){
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
920 fprintf(stderr,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
921 "%s <run|norun|compile|nocompile> <source>\n",
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
922 arg[0]);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
923 }else{
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
924 fprintf(stderr,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
925 "dstress <run|norun|compile|nocompile>"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
926 " <source>\n");
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
927 }
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
928
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
929 fprintf(stderr, "\n"
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
930 "== eniroment settings (usually $NAME or %%NAME%%) ==\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
931 "* DMD - compiler (including standard arguments)\n"
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
932 "* GDB - debugger (including standard arguments)\n");
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
933 fprintf(stderr, "\n"
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
934 "== case setting (line in the case source) ==\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
935 "* __DSTRESS_DFLAGS__ - additional compiler arguments\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
936 "only evaluated if it is a \"nocompile\" or \"norun\" test:\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
937 "* __DSTRESS_ELINE__ - expected source line to throw an error message\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
938 "* __DSTRESS_EFILE__ - expected source file to throw an error message\n"
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
939 " (defaults to the case file)\n");
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
940 fprintf(stderr,
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
941 "only evaluated if it is a \"run\" or \"norun\" test:\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
942 "* __GDB_SCRIPT__ - command sequence to feed to the debugger\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
943 " (use \\n to encode a line break)\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
944 "* __GDB_PATTERN__ - expected regular expression in the debugger's\n"
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
945 " output\n");
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
946 fprintf(stderr, "\n"
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
947 "== note ==\n"
710
8cba64b24615 fixed typo
thomask
parents: 707
diff changeset
948 "* the current directory is required to contain the sub-directory \"obj\"\n"
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
949 " (used for temporary files)\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
950 );
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
951 exit(EXIT_FAILURE);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
952 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
953
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
954 modus = 0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
955 if(0==strncmp(arg[1], TORTURE_PREFIX, strlen(TORTURE_PREFIX))){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
956 modus |= MODE_TORTURE;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
957 arg[1] += strlen(TORTURE_PREFIX);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
958 }
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
959 if(0==strcmp(arg[1], "run")){
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
960 modus |= MODE_RUN;
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
961 }else if(0==strcmp(arg[1], "norun")){
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
962 modus |= MODE_NORUN;
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
963 }else if(0==strcmp(arg[1], "compile")){
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
964 modus |= MODE_COMPILE;
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
965 }else if(0==strcmp(arg[1], "nocompile")){
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
966 modus |= MODE_NOCOMPILE;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
967 }else{
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
968 goto err;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
969 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
970
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
971 /* gen flags */
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
972 case_file = cleanPathSeperator(strdup(arg[2]));
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
973 compiler = getCompiler();
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
974 gdb = getGDB();
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
975 torture_block_global = getTortureBlock();
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
976 buffer = loadFile(case_file);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
977
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
978 cmd_arg_case = getCaseFlag(buffer, "__DSTRESS_DFLAGS__");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
979 error_line = getCaseFlag(buffer, "__DSTRESS_ELINE__");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
980 error_file = getCaseFlag(buffer, "__DSTRESS_EFILE__");
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
981 gdb_script = getCaseFlag(buffer, "__GDB_SCRIPT__");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
982 gdb_pattern_raw = getCaseFlag(buffer, "__GDB_PATTERN__");
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
983 torture_block_case = getCaseFlag(buffer, "__DSTRESS_TORTURE_BLOCK__");
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
984 torture_require = getCaseFlag(buffer, "__DSTRESS_TORTURE_REQUIRE__");
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
985
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
986 /* set implicit source file */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
987 if(strcmp(error_line, "")!=0 && strcmp(error_file, "")==0){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
988 error_file=case_file;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
989 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
990
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
991 /* gdb pattern */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
992 #ifdef REG_EXTENDED
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
993 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
994
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
995 gdb_pattern = malloc(sizeof(regex_t));
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
996 if(regcomp(gdb_pattern, gdb_pattern_raw, REG_EXTENDED)){
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
997 fprintf(stderr, "failed to compile regular expression:"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
998 "\n\t%s\n", gdb_pattern_raw);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
999 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1000 }else if(gdb_script==NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1001 fprintf(stderr, "GDB pattern without GDB script\n");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1002 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1003 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1004 }else{
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1005 gdb_pattern = NULL;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1006 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1007
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1008 /* gdb script */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1009 if(gdb_script!=NULL && gdb_script[0]!='\x00'){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1010 if(gdb_pattern==NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1011 fprintf(stderr, "GDB script without GDB pattern\n");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1012 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1013 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1014 buffer=gdb_script;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1015 for(; *buffer; buffer++){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1016 if(buffer[0]=='\\'){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1017 if(buffer[1]=='n'){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1018 buffer[0]=' ';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1019 buffer[1]='\n';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1020 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1021 buffer++;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1022 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1023 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1024
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
1025 bufferLen = strlen(gdb_script)+11;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
1026 buffer=malloc(bufferLen);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
1027 snprintf(buffer, bufferLen, "%s\n\nquit\ny\n\n", gdb_script);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
1028 gdb_script=buffer;
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1029 }else{
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1030 gdb_script = NULL;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1031 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1032
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1033 #else
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1034
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1035 if(gdb_script && strlen(gdb_script)){
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1036 if(gdb_pattern_raw && strlen(gdb_pattern_raw)){
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1037 fprintf(stderr, "WARNING: GDB/regex support inactive\n");
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1038 }else{
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1039 fprintf(stderr, "GDB script without GDB pattern\n");
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1040 exit(EXIT_FAILURE);
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1041 }
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1042 }else if(gdb_pattern_raw && strlen(gdb_pattern_raw)){
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1043 fprintf(stderr, "GDB pattern without GDB script\n");
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1044 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1045 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1046
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1047 #endif /* REG_EXTENDED else */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1048
493
1418f225a81e disabled debug output
thomask
parents: 490
diff changeset
1049 #ifdef DEBUG
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1050 fprintf(stderr, "case: \"%s\"\n", case_file);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1051 fprintf(stderr, "compiler: \"%s\"\n", compiler);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1052 fprintf(stderr, "DFLAGS C: \"%s\"\n", cmd_arg_case);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1053 fprintf(stderr, "ELINE : \"%s\"\n", error_line);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1054 fprintf(stderr, "EFILE : \"%s\"\n", error_file);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1055 #ifdef REG_EXTENDED
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1056 fprintf(stderr, "GDB Scri: \"%s\"\n", gdb_script);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1057 fprintf(stderr, "GDB Patt: \"%s\"\n", gdb_pattern_raw);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1058 #endif
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1059 fprintf(stderr, "block G : \"%s\"\n", torture_block_global);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1060 fprintf(stderr, "block C : \"%s\"\n", torture_block_case);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1061 fprintf(stderr, "modus : %x\n", modus);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1062 #endif
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
1063
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1064
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1065 /* let's get serious */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
1066
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1067 if(modus & MODE_TORTURE){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1068 if((modus & (MODE_COMPILE | MODE_NOCOMPILE))
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1069 && (modus & (MODE_RUN | MODE_NORUN)))
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1070 {
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1071 fprintf(stderr, "BUG: unhandled torture modus %x\n", modus);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1072 }else if(!(modus & (MODE_COMPILE | MODE_NOCOMPILE | MODE_RUN | MODE_NORUN))){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1073 fprintf(stderr, "BUG: unhandled torture modus %x\n", modus);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1074 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1075
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1076 bufferLen = strlen(torture[(sizeof(torture) / sizeof(char*))-1])
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1077 + strlen(cmd_arg_case) + 3;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1078
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1079 if(torture_block_case!=NULL && strlen(torture_block_case)<1){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1080 torture_block_case=NULL;
676
f90958db522d extended debug output
thomask
parents: 639
diff changeset
1081 }
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1082
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1083 buffer = malloc(bufferLen);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1084 for(index=0; index < sizeof(torture)/sizeof(char*); index++){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1085 if((torture_block_global && strstr(torture[index], torture_block_global))
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1086 || (torture_block_case && strstr(torture[index], torture_block_case))
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1087 || (torture_block_case && !strstr(torture[index], torture_require)))
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1088 {
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1089 torture_result[index]=RES_UNTESTED;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1090 continue;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1091 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1092
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1093 buffer[0]=0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1094 snprintf(buffer, bufferLen, "%s %s", torture[index], cmd_arg_case);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1095
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1096 if(modus & (MODE_COMPILE | MODE_NOCOMPILE)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1097 torture_result[index] = target_compile(modus,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1098 compiler, buffer, case_file,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1099 error_file, error_line);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1100 }else if(modus & (MODE_RUN | MODE_NORUN)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1101 torture_result[index] = target_run(modus,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1102 compiler, buffer, case_file,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1103 error_file, error_line
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1104 #ifdef REG_EXTENDED
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1105 , gdb, gdb_script, gdb_pattern
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1106 #endif
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1107 );
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1108 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1109
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1110 fprintf(stderr, "Torture-Sub-%i/" ZU "-", index+1,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1111 sizeof(torture)/sizeof(char*));
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1112 printResult(torture_result[index], modus, case_file,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1113 stderr);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1114 fprintf(stderr, "--------\n");
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
1115 }
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1116
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1117 printf("Torture:\t%s\t{", case_file);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1118 for(index=0; index < sizeof(torture)/sizeof(char*); index++){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1119 case_result = 0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1120 switch(torture_result[index] & RES_BASE_MASK){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1121 case RES_UNTESTED: case_result = 0; break;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1122 case RES_PASS: case_result = 1 << 2; break;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1123 case RES_XFAIL: case_result = 2 << 2; break;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1124 case RES_XPASS: case_result = 3 << 2; break;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1125 case RES_FAIL: case_result = 4 << 2; break;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1126 case RES_ERROR: case_result = 5 << 2; break;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1127 default:
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1128 fprintf(stderr, "BUG: unexpected case result %i\n",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1129 torture_result[index]);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1130 exit(EXIT_FAILURE);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1131 }
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1132
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1133 if(torture_result[index] & RES_BAD_MSG){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1134 case_result |= 1;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1135 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1136 if(torture_result[index] & RES_BAD_GDB){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1137 case_result |= 2;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1138 }
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1139
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1140 printf("%c", 'A' + case_result);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1141 }
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1142 printf("}\n");
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1143 }else{
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1144 /* start working */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1145 if(modus & (MODE_RUN | MODE_NORUN)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1146 case_result = target_run(modus, compiler, cmd_arg_case,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1147 case_file, error_file, error_line
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1148 #ifdef REG_EXTENDED
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1149 , gdb, gdb_script, gdb_pattern
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1150 #endif
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1151 );
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1152 printResult(case_result, modus, case_file, stdout);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1153 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1154
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1155 if(modus & (MODE_COMPILE | MODE_NOCOMPILE)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1156 case_result = target_compile(modus, compiler,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1157 cmd_arg_case, case_file, error_file,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1158 error_line);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1159 printResult(case_result, modus, case_file, stdout);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1160 }
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1161 }
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1162
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1163
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
1164 return EXIT_SUCCESS;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1165 }