annotate dstress.c @ 977:1aba99b7f01c

workaround for Valgrind bugs with various opcodes
author thomask
date Fri, 28 Apr 2006 09:54:50 +0000
parents 8da09834526d
children f410034559af
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 *
940
dddc404783c9 added basic Windows support to crashRun.c
thomask
parents: 922
diff changeset
5 * Copyright (C)
dddc404783c9 added basic Windows support to crashRun.c
thomask
parents: 922
diff changeset
6 * 2005, 2006 Thomas Kuehne <thomas@kuehne.cn>
dddc404783c9 added basic Windows support to crashRun.c
thomask
parents: 922
diff changeset
7 * 2005 Carlos Santander (Window files)
dddc404783c9 added basic Windows support to crashRun.c
thomask
parents: 922
diff changeset
8 * 2005 Stewart Gordon <smjg_1998@yahoo.com> (Window crashRun)
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
9 *
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
13 * (at your option) any later version.
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
14 *
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
18 * GNU General Public License for more details.
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
19 *
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
23 *
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
24 * $HeadURL$
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
25 * $Date$
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
26 * $Author$
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
27 *
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
28 */
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
29
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
30 /* Beware: the code doesn't care about freeing allocated memory etc. ... */
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
31
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
32 #include <stdlib.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
33 #include <stdio.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
34 #include <string.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
35 #include <errno.h>
681
be27bc9d0d28 gentoo fixes
thomask
parents: 676
diff changeset
36 #include <ctype.h>
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
37
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
38 /* number's choice: XOR and printf :) */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
39 #define MODE_RUN (0x10000)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
40 #define MODE_NORUN (0x1000)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
41 #define MODE_COMPILE (0x100)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
42 #define MODE_NOCOMPILE (0x10)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
43 #define MODE_TORTURE (0x2)
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
44
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
45 #define RES_BASE_MASK (0xFFFFFF0)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
46 #define RES_PASS (0x1000000)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
47 #define RES_XFAIL (0x100000)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
48 #define RES_XPASS (0x10000)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
49 #define RES_FAIL (0x1000)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
50 #define RES_ERROR (0x100)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
51 #define RES_UNTESTED (0x10)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
52 #define RES_BAD_GDB (0x4)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
53 #define RES_BAD_MSG (0x2)
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
54
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
55 #if defined(__GNU_LIBRARY__) || defined(__GLIBC__)
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
56 #define USE_POSIX 1
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
57 #endif
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
58
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
59 #if defined(linux) || defined(__FreeBSD__) || defined(__OpenBSD__)
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
60 #define USE_POSIX 1
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
61 #endif
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
62
273
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
63 #if defined(__APPLE__) && defined(__MACH__)
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
64 #define USE_POSIX 1
273
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
65 #endif
68b883fe4fad added *BSD support to the test framework
thomask
parents: 261
diff changeset
66
888
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
67 #if defined(WIN) || defined(WIN32) || defined(WIN64)
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
68 #define USE_WINDOWS 1
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
69 #endif
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
70
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
71 /* 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
72 #ifdef USE_POSIX
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
73
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
74 #include <sys/types.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
75 #include <sys/stat.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
76 #include <fcntl.h>
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
77 #include <unistd.h>
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
78 #include <regex.h>
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
79 #include <limits.h>
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
80
904
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
81 /* not every STDLIB propperly supports C99's "%z" for printf formating */
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
82 /* (I just love those non-conforming headers...) */
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
83 #undef ZU
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
84
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
85 #if !defined(ZU) && defined(SSIZE_MAX)
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
86 #if defined(INT_MAX) && SSIZE_MAX == INT_MAX
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
87 #define ZU "%u"
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
88 #elif defined(LONG_MAX) && SSIZE_MAX == LONG_MAX
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
89 #define ZU "%lu"
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
90 #elif defined(LLONG_MAX) && SSIZE_MAX == LLONG_MAX
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
91 #define ZU "%llu"
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
92 #elif defined(SHRT_MAX) && SSIZE_MAX == SHRT_MAX
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
93 #define ZU "%hu"
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
94 #endif
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
95 #endif /* SSIZE_MAX */
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
96
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
97 #if !defined(ZU) && defined(SIZE_T_MAX)
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
98 #if defined(UINT_MAX) && SIZE_T_MAX == UINT_MAX
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
99 #define ZU "%u"
904
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
100 #elif defined(ULONG_MAX) && SIZE_T_MAX == ULONG_MAX
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
101 #define ZU "%lu"
904
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
102 #elif defined(ULLONG_MAX) && SIZE_T_MAX == ULLONG_MAX
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
103 #define ZU "%llu"
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
104 #elif defined(USHRT_MAX) && SIZE_T_MAX == USHRT_MAX
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
105 #define ZU "%hu"
904
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
106 #endif
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
107 #endif /* SIZE_T_MAX */
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
108
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
109 #ifndef ZU
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
110 #include <stdint.h>
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
111 #undef ZU
904
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
112 #ifdef PTRDIFF_MAX
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
113 #if defined(INT_MAX) && PTRDIFF_MAX == INT_MAX
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
114 #define ZU "%u"
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
115 #elif defined(LONG_MAX) && PTRDIFF_MAX == LONG_MAX
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
116 #define ZU "%lu"
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
117 #elif defined(LLONG_MAX) && PTRDIFF_MAX == LLONG_MAX
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
118 #define ZU "%llu"
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
119 #elif defined(SHRT_MAX) && PTRDIFF_MAX == SHRT_MAX
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
120 #define ZU "%hu"
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
121 #endif
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
122 #endif
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
123 #endif /* PTRDIFF_MAX */
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
124
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
125 #ifndef ZU
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
126 #error what is the size of a pointer?
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
127 #endif
904
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
128
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
129 #else
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
130 #ifdef USE_WINDOWS
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
131
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
132 #include <windows.h>
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
133 #define snprintf _snprintf
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
134 #ifndef INVALID_FILE_SIZE
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
135 #define INVALID_FILE_SIZE (-1)
742
5906350b5048 fixed misplaced #endif for Windows systems
thomask
parents: 734
diff changeset
136 #endif
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
137
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
138 /* not every STDLIB supports C99's "%z" for printf formating */
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
139 #ifdef WIN32
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
140 #define ZU "%u"
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
141 #else
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
142 #ifdef WIN64
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
143 #define ZU "%llu"
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
144 #else
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
145 #error what is the size of a pointer?
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
146 #endif
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
147 #endif
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
148
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
149 #else
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
150 #error neither POSIX nor MSWindows API detected
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
151 #endif /* USE_WINDOWS else */
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
152 #endif /* USE_POSIX else */
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
153
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
154 #define TORTURE_PREFIX "torture-"
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
155
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
156 #ifdef USE_POSIX
968
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
157 #define CRASH_RUN "./crashRun 30 2000"
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
158 #ifdef USE_VALGRIND
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
159 #define VALGRIND "valgrind --leak-check=no -q --suppressions=valgrind.suppress"
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
160 #else
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
161 #define VALGRIND ""
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
162 #endif
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
163 #define TMP_DIR "./obj"
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
164 #define RM_DIR "rm -rf"
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
165 #else
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
166 #ifdef USE_WINDOWS
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
167 #define VALGRIND ""
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
168 #define TMP_DIR ".\\obj"
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
169 #else
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
170 #error OS dependent file names not defined
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
171 #endif
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
172 #endif
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
173
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
174 char* tmp_dir;
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
175
888
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
176 #ifdef USE_WINDOWS
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
177 HANDLE originalStdout, originalStderr;
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
178 #endif
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
179
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
180 const char* torture[] = {
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
181 "",
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
182
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
183 "-g", "-inline", "-fPIC", "-O", "-release",
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
184
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
185 "-g -inline", "-g -fPIC", "-g -O", "-g -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
186 "-inline -fPIC", "-inline -O", "-inline -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
187 "-fPIC -O", "-fPIC -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
188 "-O -release",
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
189
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
190 "-g -inline -fPIC", "-g -inline -O", "-g -inline -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
191 "-g -fPIC -O", "-g -fPIC -release", "-g -O -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
192 "-inline -fPIC -O", "-inline -fPIC -release", "-inline -O -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
193 "-fPIC -O -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
194
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
195 "-g -inline -fPIC -O", "-g -inline -fPIC -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
196 "-g -fPIC -O -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
197 "-inline -fPIC -O -release",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
198
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
199 "-g -inline -fPIC -O -release"
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
200 };
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
201
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
202 /* secure malloc */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
203 void *xmalloc(size_t size){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
204 void *p = malloc(size);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
205 if (p == NULL){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
206 fprintf(stderr, "Failed to allocate " ZU " bytes!\n", size);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
207 exit(EXIT_FAILURE);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
208 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
209 return p;
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
210 }
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
211 #define malloc xmalloc
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
212
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
213 /* secure calloc */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
214 void* xcalloc(size_t members, size_t size){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
215 void* ptr = calloc(members, size);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
216 if(ptr == NULL){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
217 fprintf(stderr, "Failed to allocate " ZU " elements"
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
218 "(" ZU " bytes each)!\n", members, size);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
219 exit(EXIT_FAILURE);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
220 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
221 return ptr;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
222 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
223 #define calloc xcalloc
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
224
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
225
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
226 void printResult(int result, int modus, char* case_file, FILE* stream){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
227 char* msg = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
228 #ifdef DEBUG
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
229 fprintf(stderr, "case: %s, modus: %x, result: %x\n", case_file, modus,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
230 result);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
231 #endif
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
232
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
233 if(result & RES_PASS){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
234 msg = "PASS: ";
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
235 }else if(result & RES_XFAIL){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
236 msg = "XFAIL:";
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
237 }else if(result & RES_XPASS){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
238 msg = "XPASS:";
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
239 }else if(result & RES_FAIL){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
240 msg = "FAIL: ";
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
241 }else if(result & RES_ERROR){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
242 msg = "ERROR:";
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
243 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
244
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
245 fprintf(stream, "%s\t%s%s%s\n", msg, case_file,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
246 (result & RES_BAD_MSG) ? " [bad error message]" : "",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
247 (result & RES_BAD_GDB) ? " [bad debugger message]" : "");
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
248 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
249
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
250 char* strip(char* buffer){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
251 char* tmp = NULL;
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
252
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
253 if(buffer!=NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
254 while(isspace(buffer[0])){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
255 buffer++;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
256 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
257
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
258 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
259 tmp[0]='\x00';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
260 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
261 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
262 return buffer;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
263 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
264
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
265 unsigned int genTempFileNameCount;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
266 char* genTempFileName(){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
267 char* back;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
268 size_t len;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
269
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
270 len = strlen(tmp_dir) + 128;
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
271 back = malloc(len);
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
272
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
273 #ifdef USE_POSIX
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
274 snprintf(back, len, "%s/t%x-%x-%x.tmp", tmp_dir, getpid(), rand(), ++genTempFileNameCount);
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
275 #else
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
276 snprintf(back, len, "%s\\t%x-%x-%x.tmp", tmp_dir, getpid(), rand(), ++genTempFileNameCount);
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
277 #endif
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
278
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
279 return back;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
280 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
281
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
282 /* cleanup "/" versus "\" in filenames */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
283 char* cleanPathSeperator(char* filename){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
284 char* pos = NULL;
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
285 #ifdef USE_POSIX
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
286 for(pos=strchr(filename, '\\'); pos; pos=strchr(filename, '\\')){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
287 *pos='/';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
288 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
289 #else
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
290 #if USE_WINDOWS
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
291 for(pos=strchr(filename, '/'); pos; pos=strchr(filename, '/')){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
292 *pos='\\';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
293 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
294 #else
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
295
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
296 #error no cleanPathSeperator implementation available for this system
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
297
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
298 #endif /* USE_WINDOWS else */
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
299 #endif /* USE_POSIX else */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
300 return filename;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
301 }
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
302
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
303 char* loadFile(char* filename, size_t* len){
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
304 #ifdef USE_POSIX
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
305 char* back;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
306 struct stat fileInfo;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
307 int file = open(filename, O_RDONLY);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
308
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
309 back = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
310
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
311 if(errno == 0 && file != 0 && file != -1){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
312 if(0==fstat(file, &fileInfo)){
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
313 back=malloc(fileInfo.st_size+1);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
314 fileInfo.st_size = read(file, back, fileInfo.st_size);
440
dc186d1266ba fixed handling of empty files
thomask
parents: 439
diff changeset
315 if(fileInfo.st_size>=0){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
316 *(back+fileInfo.st_size) = '\x00';
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
317 *len = fileInfo.st_size;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
318 }else{
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
319 back = NULL;
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
320 *len = 0;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
321 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
322 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
323 close(file);
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
324 }
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
325
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
326 if(back){
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
327 return back;
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
328 }
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
329
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
330 fprintf(stderr, "File not found \"%s\" (%s)\n", filename, strerror(errno));
436
5e210bace0f1 added "File not found" clause
thomask
parents: 432
diff changeset
331 exit(EXIT_FAILURE);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
332 #else /* USE_POSIX */
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
333 #ifdef USE_WINDOWS
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
334 /* @todo@ check for 32bit/64bit */
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
335 char* back;
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
336 DWORD size, numread;
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
337 HANDLE file=CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
338 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
339
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
340 back = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
341 size = 0;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
342 numread = 0;
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
343 if (file != INVALID_HANDLE_VALUE){
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
344 size = GetFileSize(file, NULL);
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
345 if (size != INVALID_FILE_SIZE){
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
346 back=malloc((size+1)*sizeof(char));
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
347 if (ReadFile(file,back,size,&numread,NULL) == 1){
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
348 if (numread==size){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
349 *(back+size) = '\x00';
904
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
350 *len = size;
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
351 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
352 back = NULL;
904
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
353 *len = 0;
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
354 }
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
355 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
356 back = NULL;
904
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
357 *len = 0;
292
7e28d437d6d7 fixed Windows loadFile return code bug
thomask
parents: 273
diff changeset
358 }
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
359 }
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
360 CloseHandle(file);
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
361 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
362 if(back){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
363 errno = 0;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
364 return back;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
365 }
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
366
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
367 fprintf(stderr, "File not found \"%s\"\n", filename);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
368 exit(EXIT_FAILURE);
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
369 #else /* USE_WINDOWS */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
370
707
5ba45899cddd minor infrastructure fixes
thomask
parents: 704
diff changeset
371 #error no loadFile implementation present
361
0147a35cbeb7 dif. fixes 5
thomask
parents: 340
diff changeset
372
633
653cbe20c878 updated location of tmp files
thomask
parents: 622
diff changeset
373 #endif /* USE_WINDOWS */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
374 #endif /* USE_POSIX else */
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
375 }
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
376
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
377 void writeFile(const char* filename, const char* content){
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
378 size_t len;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
379 FILE* file;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
380
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
381 len = strlen(content);
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
382 errno = 0;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
383 file = fopen(filename, "w+");
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
384
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
385 if(errno == 0 && file != NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
386 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
387 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
388 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
389 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
390 if(fclose(file) || (errno != 0)){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
391 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
392 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
393 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
394 return;
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
395 }
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
396
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
397 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
398 exit(EXIT_FAILURE);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
399 }
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
400
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
401 /* query the environment for the compiler name */
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
402 char* getCompiler(void){
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
403 char* back = getenv("DMD");
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
404
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
405 if(back==NULL){
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
406 back = "dmd";
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
407 }
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
408
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
409 return strip(cleanPathSeperator(back));
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
410 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
411
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
412 /* query the environment for the debugger name */
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
413 char* getGDB(void){
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
414 char* back = getenv("GDB");
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
415
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
416 if(back==NULL){
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
417 back = "gdb";
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
418 }
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
419
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
420 return strip(cleanPathSeperator(back));
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
421 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
422
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
423 char* getTortureBlock(void){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
424 char* back = getenv("DSTRESS_TORTURE_BLOCK");
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
425
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
426 if(back!=NULL){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
427 back = strip(back);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
428 if(strlen(back)<1){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
429 back = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
430 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
431 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
432
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
433 return back;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
434 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
435
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
436 /* 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
437 char* getCaseFlag(const char* data, const char* tag){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
438 char* begin;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
439 char* end1;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
440 char* end2;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
441 char* back;
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
442
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
443 begin = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
444 end1 = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
445 end2 = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
446 back = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
447
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
448 if(data!=NULL && tag!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
449 begin = strstr(data, tag);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
450 if(begin!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
451 begin = begin+strlen(tag);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
452 end1 = strstr(begin, "\n");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
453 end2 = strstr(begin, "\r");
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
454 if(end2!=NULL && ((end1!=NULL && end2<end1) || end1==NULL)){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
455 end1=end2;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
456 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
457 if(end1==NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
458 end1 = begin + strlen(begin);
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 back = malloc(end1-begin+1);
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
461 strncpy(back, begin, end1-begin);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
462 back[end1-begin]='\x00';
968
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
463 return strip(back);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
464 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
465 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
466
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
467 back = malloc(1);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
468 back[0] = 0;
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
469 return back;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
470 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
471
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
472 /* check compile-time error messages */
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
473 int checkErrorMessage(const char* file, const char* line, const char* buffer){
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
474
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
475 char* dmd;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
476 char* gdc;
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
477 size_t len;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
478 int back;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
479
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
480 dmd = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
481 gdc = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
482 len = 0;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
483 back = 0;
339
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 /* clean arguments */
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
486 if(file && !file[0]){
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
487 file = NULL;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
488 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
489
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
490 if(line && !line[0]){
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
491 line = NULL;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
492 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
493
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
494 /* gen patterns*/
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
495 if(file!=NULL){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
496 if(line!=NULL){
770
1a8a4d885f79 fixed patters to find secondary hits
thomask
parents: 746
diff changeset
497 len = strlen(file)+strlen(line)+3;
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
498 dmd = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
499 snprintf(dmd, len, "%s(%s)", file, line);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
500
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
501 gdc = malloc(--len);
770
1a8a4d885f79 fixed patters to find secondary hits
thomask
parents: 746
diff changeset
502 snprintf(gdc, len, "%s:%s", file, line);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
503 }else{
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
504 len = strlen(file)+2;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
505 dmd = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
506 snprintf(dmd, len, "%s(", file);
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
507
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
508 gdc = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
509 snprintf(gdc, len, "%s:", file);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
510 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
511 }else if(line!=NULL){
770
1a8a4d885f79 fixed patters to find secondary hits
thomask
parents: 746
diff changeset
512 len = strlen(line)+3;
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
513 dmd = malloc(len);
770
1a8a4d885f79 fixed patters to find secondary hits
thomask
parents: 746
diff changeset
514 snprintf(dmd, len, "(%s)", line);
622
7acb8b34c87a - fixed diagnostic 3/3
thomask
parents: 620
diff changeset
515
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
516 gdc = malloc(--len);
770
1a8a4d885f79 fixed patters to find secondary hits
thomask
parents: 746
diff changeset
517 snprintf(gdc, len, ":%s", line);
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
518 }else{
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
519 return 1;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
520 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
521
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
522 /* specific error messages */
676
f90958db522d extended debug output
thomask
parents: 639
diff changeset
523 #ifdef DEBUG
f90958db522d extended debug output
thomask
parents: 639
diff changeset
524 fprintf(stderr, "pattern(dmd):\t%s\n", dmd);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
525 fprintf(stderr, "pattern(gdc):\t%s\n", gdc);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
526 #endif
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
527
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
528 if( (dmd!=NULL && strstr(buffer, dmd))
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
529 || (gdc!=NULL && strstr(buffer, gdc))
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
530 || (dmd==NULL && gdc==NULL)){
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
531 back=1;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
532 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
533
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
534 free(dmd);
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
535 free(gdc);
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
536
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
537 return back;
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
538 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
539
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
540 int checkRuntimeErrorMessage(const char* file, const char* line, const char* buffer){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
541 /* PhobosLong dir/file.d(2)
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
542 * Phobos package.module(2)
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
543 */
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
544
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
545 char* phobos;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
546 char* phobosLong;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
547
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
548 const char* begin;
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
549 const char* end;
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
550 size_t len;
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
551
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
552 int back=0;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
553
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
554 phobos = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
555 phobosLong = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
556
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
557 begin = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
558 end = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
559 len = 0;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
560
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
561 /* clean arguments */
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
562 if(file && !file[0]){
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
563 file = NULL;
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
564 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
565
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
566 if(line && !line[0]){
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
567 line = NULL;
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
568 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
569
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
570 /* gen patterns*/
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
571 if(file!=NULL){
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
572 if(line!=NULL){
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
573 len = strlen(file)+strlen(line)+3;
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
574 phobos = malloc(len);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
575 begin=strrchr(file,'/');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
576 if(begin){
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
577 begin++;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
578 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
579 begin=strrchr(file,'\\');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
580 if(begin){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
581 begin++;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
582 }else{
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
583 begin=file;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
584 }
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
585 }
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
586 end=strrchr(file,'.');
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
587 strncat(phobos, begin, end-begin);
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
588 snprintf(phobos, len, "%.*s(%s)",
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
589 (int)(end-begin), begin,
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
590 line);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
591
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
592 phobosLong = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
593 snprintf(phobosLong, len, "%s(%s)", file, line);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
594 }else{
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
595 len = strlen(file)+2;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
596 phobos = malloc(len);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
597 begin=strrchr(file,'/');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
598 if(begin){
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
599 begin++;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
600 }else{
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
601 begin=strrchr(file,'\\');
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
602 if(begin){
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
603 begin++;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
604 }else{
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
605 begin=file;
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
606 }
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
607 }
439
edb0923c9159 cleanup for Linux(gcc)
thomask
parents: 438
diff changeset
608 end=strrchr(file,'.');
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
609 snprintf(phobos, len, "%.*s(", (int)(end-begin), begin);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
610
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
611 phobosLong = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
612 snprintf(phobosLong, len, "%s(", file);
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
613 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
614 }else if(line!=NULL){
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
615 len = strlen(line)+3;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
616 phobos = malloc(len);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
617 snprintf(phobos, len, "(%s)", line);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
618
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
619 phobosLong=NULL;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
620 }else{
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
621 return 1;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
622 }
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
623
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
624 /* specific error messages */
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
625
676
f90958db522d extended debug output
thomask
parents: 639
diff changeset
626 #ifdef DEBUG
f90958db522d extended debug output
thomask
parents: 639
diff changeset
627 fprintf(stderr, "pattern(phobosShort):\t%s\n", phobos);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
628 fprintf(stderr, "pattern(phobosLong):\t%s\n", phobosLong);
f90958db522d extended debug output
thomask
parents: 639
diff changeset
629 #endif
f90958db522d extended debug output
thomask
parents: 639
diff changeset
630
432
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
631 if( (phobos && strstr(buffer, phobos))
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
632 || (phobosLong && strstr(buffer, phobosLong)))
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
633 {
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
634 back=1;
db4b6169a99d 1) implemented checkRuntimeErrorMessage
thomask
parents: 429
diff changeset
635 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
636
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
637 free(phobos);
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
638 if(phobosLong){
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
639 free(phobosLong);
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
640 }
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
641
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
642 return back;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
643 }
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
644
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
645 int hadExecCrash(const char* buffer){
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
646 if(strstr(buffer, "Segmentation fault")
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
647 || strstr(buffer, "Internal error")
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
648 || strstr(buffer, "gcc.gnu.org/bugs")
774
eb7dc8747fa7 added Stewart's crash indicators
thomask
parents: 770
diff changeset
649 || strstr(buffer, "EXIT CODE: signal")
eb7dc8747fa7 added Stewart's crash indicators
thomask
parents: 770
diff changeset
650 || strstr(buffer, "Assertion failure")
968
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
651 || strstr(buffer, "Access Violation")
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
652 || strstr(buffer, "Invalid read of size")
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
653 || strstr(buffer, "Conditional jump or move depends on uninitialised value")
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
654 || strstr(buffer, "Use of uninitialised value of size"))
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
655 {
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
656 return 1;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
657 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
658 return 0;
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
659 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
660
499
0434764d4a66 removed redundancy in the output
thomask
parents: 493
diff changeset
661 /* system call with time-out */
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
662 int crashRun(const char* cmd, char** logFile){
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
663
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
664 size_t len;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
665 char* buffer;
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
666 int back;
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
667
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
668 *logFile = genTempFileName();
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
669 #ifdef USE_POSIX
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
670 len = 20 + strlen(CRASH_RUN) + strlen(cmd) + strlen(*logFile);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
671 buffer = malloc(len);
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
672
940
dddc404783c9 added basic Windows support to crashRun.c
thomask
parents: 922
diff changeset
673 snprintf(buffer, len, "%s %s > %s 2>&1", CRASH_RUN, cmd, *logFile);
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
674
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
675 system(buffer);
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
676 free(buffer);
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
677
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
678 buffer=loadFile(*logFile, &len);
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
679
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
680 /* @todo@ use: len */
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
681 if(strstr(buffer, "EXIT CODE: 0")){
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
682 back = EXIT_SUCCESS;
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
683 }else if(strstr(buffer, "EXIT CODE: 256")
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
684 || strstr(buffer, "EXIT CODE: timeout"))
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
685 {
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
686 back = EXIT_FAILURE;
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
687 }else{
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
688 back = RAND_MAX;
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
689 }
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
690 free(buffer);
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
691
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
692 return back;
888
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
693 #elif defined USE_WINDOWS
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
694 PROCESS_INFORMATION processInfo;
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
695 STARTUPINFO startupInfo;
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
696 SECURITY_ATTRIBUTES sa = {
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
697 sizeof(SECURITY_ATTRIBUTES), NULL, TRUE
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
698 };
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
699 HANDLE tLogFile;
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
700 unsigned long exitCode;
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
701 int timeLeft = 600; /* time limit in iterations of WFX loop */
888
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
702
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
703 memset(&processInfo, 0, sizeof(PROCESS_INFORMATION));
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
704 memset(&startupInfo, 0, sizeof(STARTUPINFO));
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
705 startupInfo.cb = sizeof(STARTUPINFO);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
706
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
707 tLogFile = CreateFile(*logFile, GENERIC_WRITE,
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
708 0, &sa, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
709
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
710 if (tLogFile == NULL) {
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
711 printf("ERROR: could not open log file");
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
712 return RAND_MAX;
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
713 }
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
714
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
715 SetStdHandle(STD_OUTPUT_HANDLE, tLogFile);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
716 SetStdHandle(STD_ERROR_HANDLE, originalStdout);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
717
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
718 if (!CreateProcess(NULL, (char*) cmd, NULL, NULL, TRUE, 0, NULL, NULL,
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
719 &startupInfo, &processInfo)) {
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
720 void *message;
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
721
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
722 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
723 | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
724 (char*) &message, 0, NULL);
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
725
888
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
726 SetStdHandle(STD_OUTPUT_HANDLE, originalStdout);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
727 SetStdHandle(STD_ERROR_HANDLE, originalStderr);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
728 CloseHandle(tLogFile);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
729
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
730 /* this should never happen */
888
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
731 fprintf(stderr, "ERROR running %s:\n", cmd);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
732 fprintf(stderr, "%s\n", message);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
733 LocalFree((HLOCAL) message);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
734 return RAND_MAX;
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
735 }
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
736
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
737 /* wait for exit */
888
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
738 while (TRUE) {
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
739 GetExitCodeProcess(processInfo.hProcess, &exitCode);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
740 if (exitCode == 0x103) {
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
741 if (--timeLeft == 0) {
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
742 TerminateProcess(processInfo.hProcess, EXIT_FAILURE);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
743 SetStdHandle(STD_OUTPUT_HANDLE, originalStdout);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
744 SetStdHandle(STD_ERROR_HANDLE, originalStderr);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
745 CloseHandle(tLogFile);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
746 printf("EXIT CODE: timeout\n");
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
747 Sleep(100);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
748 return RAND_MAX;
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
749 }
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
750 Sleep(100);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
751 } else {
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
752 SetStdHandle(STD_OUTPUT_HANDLE, originalStdout);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
753 SetStdHandle(STD_ERROR_HANDLE, originalStderr);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
754
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
755 CloseHandle(tLogFile);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
756
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
757 printf("EXIT CODE: %i\n", exitCode);
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
758 return exitCode;
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
759 }
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
760 }
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
761
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
762 #else /* USE_WINDOWS */
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
763 #error comment me out, if your test cases produce neither eternal loops nor Access Violations
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
764
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
765 len = 10 + strlen(cmd) + strlen(*logFile);
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
766 buffer = malloc(len);
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
767
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
768 snprintf(buffer, len, "%s > %s 2>&1", cmd, *logFile);
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
769
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
770 int i = system(buffer);
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
771 printf("EXIT CODE: %i\n", i);
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
772
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
773 return i;
490
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
774 #endif /* USE_POSIX else */
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
775 }
d091ff903fa4 added crashRun for POSIX systems
thomask
parents: 476
diff changeset
776
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
777 int target_compile(int modus, char* compiler, char* arguments, char* case_file,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
778 char* error_file, char* error_line)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
779 {
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
780 size_t bufferLen;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
781 char* buffer;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
782 int res;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
783 int testResult;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
784 int good_error;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
785 char* logFile;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
786
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
787 bufferLen = 0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
788 buffer = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
789 res = -1;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
790 testResult = -1;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
791 good_error = 0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
792 logFile = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
793
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
794 if(!(modus & MODE_COMPILE) && !(modus & MODE_NOCOMPILE)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
795 fprintf(stderr, "BUG: badly handled mode %i (->compile)\n",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
796 modus);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
797 exit(EXIT_FAILURE);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
798 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
799
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
800 /* gen command */
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
801 bufferLen = strlen(compiler) + strlen(arguments) + strlen(tmp_dir)
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
802 + strlen(case_file) + 21;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
803 buffer = malloc(bufferLen);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
804 snprintf(buffer, bufferLen, "%s %s ", compiler, arguments);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
805
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
806 if(NULL == strstr(buffer, "-od")){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
807 snprintf(buffer, bufferLen, "%s %s -od%s -c %s",
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
808 compiler, arguments, tmp_dir, case_file);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
809 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
810 snprintf(buffer, bufferLen, "%s %s -c %s",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
811 compiler, arguments, case_file);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
812 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
813
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
814 /* test */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
815 if(modus & MODE_COMPILE){
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
816 printf("compile: %s\n", buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
817 }else{
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
818 printf("nocompile: %s\n", buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
819 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
820 res = crashRun(buffer, &logFile);
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
821 free(buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
822
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
823 /* diagnostic */
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
824 buffer = loadFile(logFile, &bufferLen);
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
825 printf("%.*s\n", (int)bufferLen, buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
826 remove(logFile);
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
827 free(logFile);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
828 good_error = checkErrorMessage(error_file, error_line, buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
829
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
830 if(hadExecCrash(buffer)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
831 testResult = RES_ERROR;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
832 }else if(modus & MODE_COMPILE){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
833 if(res == EXIT_SUCCESS){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
834 testResult = RES_PASS;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
835 }else if(res == EXIT_FAILURE){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
836 testResult = RES_FAIL | (good_error ? 0 : RES_BAD_MSG);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
837 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
838 testResult = RES_ERROR | (good_error ? 0 : RES_BAD_MSG);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
839 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
840 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
841 if(res == EXIT_FAILURE){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
842 if(good_error){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
843 testResult = RES_XFAIL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
844 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
845 testResult = RES_FAIL | RES_BAD_MSG;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
846 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
847 }else if(res == EXIT_SUCCESS){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
848 testResult = RES_XPASS;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
849 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
850 testResult = RES_ERROR;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
851 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
852 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
853
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
854 free(buffer);
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
855
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
856 return testResult;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
857 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
858
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
859 int target_run(int modus, char* compiler, char* arguments, char* case_file,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
860 char* error_file, char* error_line
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
861 #ifdef REG_EXTENDED
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
862 , char* gdb, char* gdb_script, regex_t* gdb_pattern
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
863 #endif
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
864 )
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
865 {
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
866 size_t bufferLen;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
867 char* buffer;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
868 int res;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
869 int testResult;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
870 int good_error;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
871 char* logFile;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
872 char* gdb_scripter;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
873 int good_gdb;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
874
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
875 bufferLen = 0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
876 buffer = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
877 res = -1;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
878 testResult = -1;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
879 good_error = 0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
880 logFile = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
881 good_gdb = 0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
882 gdb_scripter = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
883
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
884 if(!(modus & MODE_RUN) && !(modus & MODE_NORUN)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
885 fprintf(stderr, "BUG: badly handled mode %i (->run)\n", modus);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
886 exit(EXIT_FAILURE);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
887 }
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
888
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
889 /* gen command */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
890
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
891 bufferLen = strlen(compiler) + strlen(arguments) + strlen(tmp_dir)
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
892 + strlen(case_file) * 2 + 64;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
893 buffer = malloc(bufferLen);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
894 snprintf(buffer, bufferLen, "%s %s ", compiler, arguments);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
895
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
896 if(NULL == strstr(buffer, "-od")){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
897 if(NULL == strstr(buffer, "-of")){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
898 snprintf(buffer, bufferLen,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
899 "%s %s -od%s -of%s.exe %s",
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
900 compiler, arguments, tmp_dir, case_file,
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
901 case_file);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
902 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
903 snprintf(buffer, bufferLen,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
904 "%s %s -od%s %s",
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
905 compiler, arguments, tmp_dir, case_file);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
906 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
907 }else if(NULL == strstr(buffer, "-of")){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
908 snprintf(buffer, bufferLen,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
909 "%s %s -of%s.exe %s",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
910 compiler, arguments, case_file, case_file);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
911 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
912 snprintf(buffer, bufferLen, "%s %s %s",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
913 compiler, arguments, case_file);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
914 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
915
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
916 /* test 1/3 - compile */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
917 if(modus & MODE_RUN){
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
918 printf("run: %s\n", buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
919 }else{
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
920 printf("norun: %s\n", buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
921 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
922 res = crashRun(buffer, &logFile);
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
923 free(buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
924
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
925 /* diagnostic 1/3 */
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
926 buffer = loadFile(logFile, &bufferLen);
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
927 printf("%.*s", (int)bufferLen, buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
928 remove(logFile);
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
929 free(logFile);
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
930
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
931 if(modus & MODE_RUN){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
932 good_error = checkErrorMessage(error_file, error_line,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
933 buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
934 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
935 good_error = 1;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
936 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
937
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
938 if(hadExecCrash(buffer)){
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
939 free(buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
940 return RES_ERROR;
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
941 }else{
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
942 free(buffer);
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
943 if((res == EXIT_FAILURE) && good_error){
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
944 return RES_FAIL;
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
945 }else if(res!=EXIT_SUCCESS){
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
946 return RES_ERROR | (good_error ? 0 : RES_BAD_MSG);
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
947 }
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
948 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
949
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
950 /* test 2/3 - run */
977
1aba99b7f01c workaround for Valgrind bugs with various opcodes
thomask
parents: 971
diff changeset
951 /* FIXME asm workaround due to Valgrind bugs */
1aba99b7f01c workaround for Valgrind bugs with various opcodes
thomask
parents: 971
diff changeset
952 if(VALGRIND && VALGRIND[0] && !strstr(case_file, "/asm_") && !strstr(case_file, "\\asm_")){
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
953 bufferLen = strlen(VALGRIND) + strlen(case_file) + 8;
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
954 buffer = malloc(bufferLen);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
955 snprintf(buffer, bufferLen, "%s %s.exe", VALGRIND, case_file);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
956 }else{
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
957 bufferLen = strlen(case_file) + 8;
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
958 buffer = malloc(bufferLen);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
959 snprintf(buffer, bufferLen, "%s.exe", case_file);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
960 }
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
961 printf("%s\n", buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
962 res=crashRun(buffer, &logFile);
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
963 free(buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
964
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
965 /* diagnostic 2/3 */
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
966 buffer = loadFile(logFile, &bufferLen);
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
967 printf("%.*s\n", (int) bufferLen, buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
968 remove(logFile);
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
969 free(logFile);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
970
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
971 if(modus & MODE_NORUN){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
972 good_error = checkRuntimeErrorMessage(error_file, error_line,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
973 buffer);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
974 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
975 good_error = 1;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
976 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
977
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
978 #ifdef REG_EXTENDED
968
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
979 if(((res==EXIT_SUCCESS && (modus & MODE_RUN))
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
980 ||(res==EXIT_SUCCESS && (modus & MODE_RUN)))
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
981 && gdb_script != NULL)
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
982 {
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
983 free(buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
984 good_gdb = 0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
985 /* test 3/3 - gdb */
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
986 gdb_scripter = genTempFileName();
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
987 writeFile(gdb_scripter, gdb_script);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
988 bufferLen = strlen(gdb) + strlen(case_file)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
989 + strlen(gdb_scripter) + 20;
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
990 buffer = malloc(bufferLen);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
991 snprintf(buffer, bufferLen, "%s %s.exe < %s",
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
992 gdb, case_file, gdb_scripter);
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
993 printf("%s\n", buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
994 if(EXIT_SUCCESS==crashRun(buffer, &logFile)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
995 /* diagnostic 3/3 */
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
996 buffer = loadFile(logFile, &bufferLen);
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
997 printf("%.*s\n", (int)bufferLen, buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
998 good_gdb = (regexec(gdb_pattern, buffer, 0, NULL, 0)==0);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
999 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1000 remove(logFile);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1001 remove(gdb_scripter);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1002 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1003 good_gdb = 1;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1004 }
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
1005 #else
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
1006 good_gdb = 1;
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1007 #endif /* REG_EXTENDED else */
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1008
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1009 if(modus & MODE_RUN){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1010 if(hadExecCrash(buffer)){
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
1011 testResult = RES_ERROR;
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1012 }else if((res==EXIT_SUCCESS) && good_gdb){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1013 testResult = RES_PASS;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1014 }else if((res==EXIT_FAILURE) && good_error && good_gdb){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1015 testResult = RES_FAIL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1016 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1017 testResult = RES_ERROR | (good_error ? 0 : RES_BAD_MSG)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1018 | (good_gdb ? 0 : RES_BAD_GDB);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1019 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1020 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1021 if(res==EXIT_SUCCESS){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1022 testResult = RES_XPASS;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1023 }else if(good_error && good_gdb){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1024 testResult = RES_XFAIL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1025 }else{
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1026 testResult = RES_FAIL | (good_error ? 0 : RES_BAD_MSG)
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1027 | (good_gdb ? 0 : RES_BAD_GDB);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1028 }
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1029 }
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
1030 free(buffer);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1031
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1032 return testResult;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1033 }
254
a39162afcc94 MSWindows port of "dstress.c"
thomask
parents: 251
diff changeset
1034
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1035 int main(int argc, char* arg[]){
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
1036
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1037 char* compiler; /* the compiler - from enviroment flag "DMD" */
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
1038 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
1039 char* buffer; /* general purpose buffer */
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
1040 size_t bufferLen;
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1041 int index;
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1042 int modus; /* test modus: RUN NORUN COMPILE NOCOMPILE */
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1043 char* case_file;
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1044 int case_result;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1045 int torture_result[sizeof(torture)/sizeof(char*)];
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1046 char* torture_block_global;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1047 char* torture_block_case;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1048 char* torture_require;
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
1049 char* error_file; /* expected sourcefile containing the error */
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
1050 char* error_line; /* expected error line */
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1051 char* gdb; /* the debugger - from environment flag "GDB" */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1052 char* gdb_script; /* gdb command sequence */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1053 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
1054 #ifdef REG_EXTENDED
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1055 regex_t* gdb_pattern;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1056 #endif
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1057
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
1058 compiler = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
1059 cmd_arg_case = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
1060 buffer = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
1061 bufferLen = 0;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
1062 modus = -1;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
1063 case_file = NULL;
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1064 torture_block_global = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1065 torture_block_case = NULL;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1066 torture_require = NULL;
697
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
1067 error_file = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
1068 error_line = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
1069 gdb = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
1070 gdb_script = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
1071 gdb_pattern_raw = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
1072 #ifdef REG_EXTENDED
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
1073 gdb_pattern = NULL;
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
1074 #endif
fbee62becd2c partial repos review
thomask
parents: 693
diff changeset
1075
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1076 /* check arguments */
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1077 if(argc != 3){
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1078 err:
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1079 fprintf(stderr, "DStress test executer (revision 1083)\n"
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1080 "Copyright by Thomas Kuehne <thomas@kuehne.cn> 2005, 2006\n"
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1081 "\n");
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1082
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1083 if(argc!=0){
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1084 fprintf(stderr,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1085 "%s <run|norun|compile|nocompile> <source>\n",
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1086 arg[0]);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1087 }else{
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1088 fprintf(stderr,
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1089 "dstress <run|norun|compile|nocompile>"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1090 " <source>\n");
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1091 }
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1092
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1093 fprintf(stderr, "\n"
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1094 "== eniroment settings (usually $NAME or %%NAME%%) ==\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1095 "* DMD - compiler (including standard arguments)\n"
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1096 "* GDB - debugger (including standard arguments)\n");
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1097 fprintf(stderr, "\n"
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1098 "== case setting (line in the case source) ==\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1099 "* __DSTRESS_DFLAGS__ - additional compiler arguments\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1100 "only evaluated if it is a \"nocompile\" or \"norun\" test:\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1101 "* __DSTRESS_ELINE__ - expected source line to throw an error message\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1102 "* __DSTRESS_EFILE__ - expected source file to throw an error message\n"
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1103 " (defaults to the case file)\n");
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1104 fprintf(stderr,
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1105 "only evaluated if it is a \"run\" or \"norun\" test:\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1106 "* __GDB_SCRIPT__ - command sequence to feed to the debugger\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1107 " (use \\n to encode a line break)\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1108 "* __GDB_PATTERN__ - expected regular expression in the debugger's\n"
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1109 " output\n");
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1110 fprintf(stderr, "\n"
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1111 "== note ==\n"
710
8cba64b24615 fixed typo
thomask
parents: 707
diff changeset
1112 "* the current directory is required to contain the sub-directory \"obj\"\n"
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1113 " (used for temporary files)\n"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1114 );
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1115 exit(EXIT_FAILURE);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1116 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1117
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1118 modus = 0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1119 if(0==strncmp(arg[1], TORTURE_PREFIX, strlen(TORTURE_PREFIX))){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1120 modus |= MODE_TORTURE;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1121 arg[1] += strlen(TORTURE_PREFIX);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1122 }
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1123 if(0==strcmp(arg[1], "run")){
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1124 modus |= MODE_RUN;
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1125 }else if(0==strcmp(arg[1], "norun")){
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1126 modus |= MODE_NORUN;
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1127 }else if(0==strcmp(arg[1], "compile")){
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1128 modus |= MODE_COMPILE;
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1129 }else if(0==strcmp(arg[1], "nocompile")){
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1130 modus |= MODE_NOCOMPILE;
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1131 }else{
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1132 goto err;
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1133 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1134
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1135 /* gen flags */
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1136 case_file = cleanPathSeperator(arg[2]);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1137 compiler = getCompiler();
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1138 gdb = getGDB();
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1139 torture_block_global = getTortureBlock();
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1140 buffer = loadFile(case_file, &bufferLen);
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1141 bufferLen = 0;
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1142
968
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
1143 cmd_arg_case = cleanPathSeperator(getCaseFlag(buffer, "__DSTRESS_DFLAGS__"));
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
1144 error_line = getCaseFlag(buffer, "__DSTRESS_ELINE__");
968
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
1145 error_file = cleanPathSeperator(getCaseFlag(buffer, "__DSTRESS_EFILE__"));
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1146 gdb_script = getCaseFlag(buffer, "__GDB_SCRIPT__");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1147 gdb_pattern_raw = getCaseFlag(buffer, "__GDB_PATTERN__");
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1148 torture_block_case = getCaseFlag(buffer, "__DSTRESS_TORTURE_BLOCK__");
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1149 torture_require = getCaseFlag(buffer, "__DSTRESS_TORTURE_REQUIRE__");
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1150
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
1151 free(buffer);
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
1152
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1153 /* tmp_dir */
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1154 if(!cmd_arg_case || !cmd_arg_case[0]){
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1155 tmp_dir = TMP_DIR;
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1156 }else{
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1157 pid_t pid;
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1158 pid = getpid();
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1159 bufferLen = strlen(TMP_DIR) + 4 + sizeof(pid_t) * 4;
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1160 buffer = malloc(bufferLen);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1161 snprintf(buffer, bufferLen, "%s/_%X", TMP_DIR, pid);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1162 tmp_dir = cleanPathSeperator(buffer);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1163 if(mkdir(tmp_dir, 0770)){
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1164 fprintf(stderr, "failed to create tmp dir: %s (%d, %s)\n",
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1165 tmp_dir, errno, strerror(errno));
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1166 return EXIT_FAILURE;
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1167 }
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1168 }
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1169
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1170 /* set implicit source file */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1171 if(strcmp(error_line, "")!=0 && strcmp(error_file, "")==0){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1172 error_file=case_file;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1173 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1174
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1175 /* gdb pattern */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1176 #ifdef REG_EXTENDED
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1177 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
1178
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1179 gdb_pattern = malloc(sizeof(regex_t));
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
1180 if(regcomp(gdb_pattern, gdb_pattern_raw, REG_EXTENDED | REG_NOSUB)){
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1181 fprintf(stderr, "failed to compile regular expression:"
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1182 "\n\t%s\n", gdb_pattern_raw);
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1183 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1184 }else if(gdb_script==NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1185 fprintf(stderr, "GDB pattern without GDB script\n");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1186 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1187 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1188 }else{
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1189 gdb_pattern = NULL;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1190 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1191
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1192 /* gdb script */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1193 if(gdb_script!=NULL && gdb_script[0]!='\x00'){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1194 if(gdb_pattern==NULL){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1195 fprintf(stderr, "GDB script without GDB pattern\n");
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1196 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1197 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1198 buffer=gdb_script;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1199 for(; *buffer; buffer++){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1200 if(buffer[0]=='\\'){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1201 if(buffer[1]=='n'){
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1202 buffer[0]=' ';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1203 buffer[1]='\n';
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1204 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1205 buffer++;
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1206 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1207 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1208
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
1209 bufferLen = strlen(gdb_script)+11;
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
1210 buffer=malloc(bufferLen);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
1211 snprintf(buffer, bufferLen, "%s\n\nquit\ny\n\n", gdb_script);
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
1212 gdb_script=buffer;
922
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
1213 }else if(gdb_script){
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
1214 free(gdb_script);
95160f4d06f8 minimized memory leaks in repeatedly called functions
thomask
parents: 904
diff changeset
1215 gdb_script = NULL;
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1216 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1217
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1218 #else
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1219
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1220 if(gdb_script && strlen(gdb_script)){
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1221 if(gdb_pattern_raw && strlen(gdb_pattern_raw)){
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1222 fprintf(stderr, "WARNING: GDB/regex support inactive\n");
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1223 }else{
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1224 fprintf(stderr, "GDB script without GDB pattern\n");
704
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1225 exit(EXIT_FAILURE);
3e690f0d2cbf documentation maintenance for dstress.c
thomask
parents: 703
diff changeset
1226 }
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1227 }else if(gdb_pattern_raw && strlen(gdb_pattern_raw)){
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1228 fprintf(stderr, "GDB pattern without GDB script\n");
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1229 exit(EXIT_FAILURE);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1230 }
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1231
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1232 #endif /* REG_EXTENDED else */
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1233
493
1418f225a81e disabled debug output
thomask
parents: 490
diff changeset
1234 #ifdef DEBUG
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1235 fprintf(stderr, "case : \"%s\"\n", case_file);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1236 fprintf(stderr, "compiler: \"%s\"\n", compiler);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1237 fprintf(stderr, "DFLAGS C: \"%s\"\n", cmd_arg_case);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1238 fprintf(stderr, "ELINE : \"%s\"\n", error_line);
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1239 fprintf(stderr, "EFILE : \"%s\"\n", error_file);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1240 #ifdef REG_EXTENDED
620
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1241 fprintf(stderr, "GDB Scri: \"%s\"\n", gdb_script);
03ad4005cd8e POSIX only: added __GDB_SCRIPT__ and __GDB__PATTERN__ support
thomask
parents: 499
diff changeset
1242 fprintf(stderr, "GDB Patt: \"%s\"\n", gdb_pattern_raw);
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1243 #endif
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1244 fprintf(stderr, "block G : \"%s\"\n", torture_block_global);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1245 fprintf(stderr, "block C : \"%s\"\n", torture_block_case);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1246 fprintf(stderr, "modus : %x\n", modus);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1247 #endif
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
1248
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1249
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1250 /* let's get serious */
888
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
1251 #ifdef USE_WINDOWS
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1252 originalStdout = GetStdHandle(STD_OUTPUT_HANDLE);
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1253 originalStderr = GetStdHandle(STD_ERROR_HANDLE);
888
a995eae8e75c blind: partial merger of Stewart's crashRun for Windows
thomask
parents: 881
diff changeset
1254 #endif
339
a74c84e75682 added error line tests (__DSTRESS_ELINE__ / __DSTRESS_EFILE__)
thomask
parents: 292
diff changeset
1255
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1256 if(modus & MODE_TORTURE){
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
1257 if((modus & (MODE_COMPILE | MODE_NOCOMPILE))
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1258 && (modus & (MODE_RUN | MODE_NORUN)))
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1259 {
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1260 fprintf(stderr, "BUG: unhandled torture modus %x\n", modus);
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1261 exit(EXIT_FAILURE);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1262 }else if(!(modus & (MODE_COMPILE | MODE_NOCOMPILE | MODE_RUN | MODE_NORUN))){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1263 fprintf(stderr, "BUG: unhandled torture modus %x\n", modus);
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1264 exit(EXIT_FAILURE);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1265 }
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1266
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1267 bufferLen = strlen(torture[(sizeof(torture) / sizeof(char*))-1])
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1268 + strlen(cmd_arg_case) + 3;
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
1269
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1270 if(torture_block_case!=NULL && strlen(torture_block_case)<1){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1271 torture_block_case=NULL;
676
f90958db522d extended debug output
thomask
parents: 639
diff changeset
1272 }
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
1273
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1274 buffer = malloc(bufferLen);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1275 for(index=0; index < sizeof(torture)/sizeof(char*); index++){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1276 if((torture_block_global && strstr(torture[index], torture_block_global))
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1277 || (torture_block_case && strstr(torture[index], torture_block_case))
959
f4fc739bbaaf fixed handling of __DSTRESS_TORTURE_REQUIRE__
thomask
parents: 940
diff changeset
1278 || (torture_require && !strstr(torture[index], torture_require)))
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1279 {
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1280 torture_result[index]=RES_UNTESTED;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1281 continue;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1282 }
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
1283
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1284 buffer[0]=0;
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1285 snprintf(buffer, bufferLen, "%s %s", torture[index], cmd_arg_case);
746
0e3682dad93a fixed windows part of dstress.c
thomask
parents: 742
diff changeset
1286
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1287 if(modus & (MODE_COMPILE | MODE_NOCOMPILE)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1288 torture_result[index] = target_compile(modus,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1289 compiler, buffer, case_file,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1290 error_file, error_line);
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1291 }else if(modus & (MODE_RUN | MODE_NORUN)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1292 torture_result[index] = target_run(modus,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1293 compiler, buffer, case_file,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1294 error_file, error_line
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1295 #ifdef REG_EXTENDED
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1296 , gdb, gdb_script, gdb_pattern
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1297 #endif
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1298 );
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1299 }
438
27039d5cbe81 partial cleanup for Windows(dmc)
thomask
parents: 437
diff changeset
1300
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1301 printf("Torture-Sub-%i/" ZU "-", index+1,
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1302 sizeof(torture)/sizeof(char*));
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1303 printResult(torture_result[index], modus, case_file,
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1304 stdout);
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1305 printf("--------\n");
685
4f97e51515d8 ported dstress.c to OpenBsd
thomask
parents: 681
diff changeset
1306 }
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1307 }else{
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1308 if(torture_require && !torture_require[0]){
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1309 if(!cmd_arg_case || !cmd_arg_case[0]){
968
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
1310 torture_require = cmd_arg_case;
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
1311 }else{
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1312 bufferLen = strlen(cmd_arg_case);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1313 bufferLen += strlen(torture_require);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1314 bufferLen += 2;
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1315 buffer = malloc(bufferLen);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1316 snprintf(buffer, bufferLen, "%s %s", cmd_arg_case, torture_require);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1317 cmd_arg_case = buffer;
968
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
1318 }
8b6d2dcf9954 * fixed new line escapes in GDB_SCRIPT
thomask
parents: 959
diff changeset
1319 }
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1320 if(modus & (MODE_RUN | MODE_NORUN)){
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1321 case_result = target_run(modus, compiler, cmd_arg_case,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1322 case_file, error_file, error_line
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1323 #ifdef REG_EXTENDED
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1324 , gdb, gdb_script, gdb_pattern
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1325 #endif
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1326 );
880
fdb649fc5b8d changed output format of non-torture runs
thomask
parents: 774
diff changeset
1327 }else if(modus & (MODE_COMPILE | MODE_NOCOMPILE)){
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1328 case_result = target_compile(modus, compiler,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1329 cmd_arg_case, case_file, error_file,
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1330 error_line);
881
996d9134bf80 added flag safeguard
thomask
parents: 880
diff changeset
1331 }else{
996d9134bf80 added flag safeguard
thomask
parents: 880
diff changeset
1332 fprintf(stderr, "BUG: unhandled non-torture modus %x\n", modus);
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1333 exit(EXIT_FAILURE);
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1334 }
904
67e77ee70d66 minor OpenBSD and Windows fixes
thomask
parents: 902
diff changeset
1335
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1336 printf("Torture-Sub-1/" ZU "-",
880
fdb649fc5b8d changed output format of non-torture runs
thomask
parents: 774
diff changeset
1337 sizeof(torture)/sizeof(char*));
fdb649fc5b8d changed output format of non-torture runs
thomask
parents: 774
diff changeset
1338 printResult(case_result, modus, case_file, stdout);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1339 }
734
d4edcc124e64 added Torture capabilities
thomask
parents: 710
diff changeset
1340
971
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1341 if(strcmp(TMP_DIR, tmp_dir)){
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1342 bufferLen = strlen(tmp_dir);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1343 bufferLen += strlen(RM_DIR);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1344 bufferLen += 2;
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1345 buffer = malloc(bufferLen);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1346 snprintf(buffer, bufferLen, "%s %s", RM_DIR, tmp_dir);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1347 system(buffer);
8da09834526d * Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents: 968
diff changeset
1348 }
902
58966fea59f7 preparing parallel build
thomask
parents: 888
diff changeset
1349 exit(EXIT_SUCCESS);
251
6cd84461e17b enabled new "dstress.c" test tool
thomask
parents:
diff changeset
1350 }