1333
|
1 import std.file, std.stdio, std.cstream, std.conv, std.string, std.ctype;
|
|
2
|
|
3 static char[][] TORTURE_FLAGS = [
|
|
4 /* 0 args */
|
|
5 "",
|
|
6
|
|
7 /* 1 args */
|
|
8 "-g",
|
|
9 "-inline",
|
|
10 "-fPIC",
|
|
11 "-O",
|
|
12 "-release",
|
|
13
|
|
14 /* 2 args */
|
|
15 "-g -inline",
|
|
16 "-g -fPIC",
|
|
17 "-g -O",
|
|
18 "-g -release",
|
|
19 "-inline -fPIC",
|
|
20 "-inline -O",
|
|
21 "-inline -release",
|
|
22 "-fPIC -O",
|
|
23 "-fPIC -release",
|
|
24 "-O -release",
|
|
25
|
|
26 /* 3 args */
|
|
27 "-g -inline -fPIC",
|
|
28 "-g -inline -O",
|
|
29 "-g -inline -release",
|
|
30 "-g -fPIC -O",
|
|
31 "-g -fPIC -release",
|
|
32 "-g -O -release",
|
|
33 "-inline -fPIC -O",
|
|
34 "-inline -fPIC -release",
|
|
35 "-inline -O -release",
|
|
36 "-fPIC -O -release",
|
|
37
|
|
38 /* 4 args */
|
|
39 "-g -inline -fPIC -O",
|
|
40 "-g -inline -fPIC -release",
|
|
41 "-g -fPIC -O -release",
|
|
42 "-inline -fPIC -O -release",
|
|
43
|
|
44 /* 5 args */
|
|
45 "-g -inline -fPIC -O -release",
|
|
46
|
|
47 /* 4 args - previously ommitted */
|
|
48 "-g -inline -O -release"
|
|
49 ];
|
|
50
|
|
51 char[] stripMessage(char[] raw, char[] file){
|
|
52 char[] ext = file[rfind(file, '.') .. $];
|
|
53 // locations
|
|
54 {
|
|
55 uint loc = 1;
|
|
56 int a = find(raw, file ~ "(");
|
|
57 while(a != -1){
|
|
58 int b = a + file.length + 1;
|
|
59 while(b < raw.length && isdigit(raw[b])){
|
|
60 b++;
|
|
61 }
|
|
62 if(b < raw.length && raw[b] == ')'){
|
|
63 raw = replace(raw, raw[a .. b+1], format("source%s(%s)", ext, loc++));
|
|
64 a = find(raw, file ~ "(");
|
|
65 }else{
|
|
66 a = -1;
|
|
67 }
|
|
68 }
|
|
69 }
|
|
70
|
|
71 // module name
|
|
72 raw = replace(raw, "dstress." ~ replace(file[0 .. $ - ext.length], "/", "."), "source");
|
|
73
|
|
74 // file name
|
|
75 raw = replace(raw, file, "source" ~ ext);
|
|
76
|
|
77 return raw;
|
|
78 }
|
|
79
|
|
80 void toText(char[] raw){
|
|
81 toBlob(cast(ubyte[]) raw);
|
|
82 }
|
|
83
|
|
84 void toBlob(void[] raw){
|
|
85 printf("'");
|
|
86 foreach(ubyte x; cast(ubyte[])raw){
|
|
87 switch(x){
|
|
88 case '\\', '\'':
|
|
89 printf("\\%c", x);
|
|
90 break;
|
|
91 case '\r':
|
|
92 printf("\\r");
|
|
93 break;
|
|
94 case '\n':
|
|
95 printf("\\n");
|
|
96 break;
|
|
97 case 0:
|
|
98 printf("\\0");
|
|
99 break;
|
|
100 default:
|
|
101 printf("%c", x);
|
|
102 }
|
|
103 }
|
|
104 printf("'");
|
|
105 }
|
|
106
|
|
107 int main(char[][] arg){
|
|
108 printf("%.*s", `
|
|
109 drop table Result;
|
|
110 drop table Message;
|
|
111 drop table Testcase;
|
|
112
|
|
113 create TABLE Message(
|
|
114 id smallint(2) unsigned unique,
|
|
115 message TEXT
|
|
116 ) ENGINE=InnoDB CHARSET=utf8;
|
|
117
|
|
118 CREATE TABLE Testcase (
|
|
119 name CHAR(40) unique,
|
|
120 source BLOB,
|
|
121 id SMALLINT(2) unsigned unique,
|
|
122 type enum('compile','complex','nocompile','norun','run','undefined')
|
|
123 ) ENGINE=InnoDB CHARSET=utf8;
|
|
124
|
|
125 create TABLE Result (
|
|
126 testcase SMALLINT(2) unsigned,
|
|
127 message SMALLINT(2) unsigned,
|
|
128 result enum('FAIL','XPASS','ERROR') NOT NULL default 'ERROR',
|
|
129 options enum('','-g','-inline','-fPIC','-O','-release','-g -inline','-g -fPIC','-g -O','-g -release',
|
|
130 '-inline -fPIC','-inline -O','-inline -release','-fPIC -O','-fPIC -release','-O -release',
|
|
131 '-g -inline -fPIC','-g -inline -O','-g -inline -release','-g -fPIC -O','-g -fPIC -release',
|
|
132 '-g -O -release','-inline -fPIC -O','-inline -fPIC -release','-inline -O -release',
|
|
133 '-fPIC -O -release','-g -inline -fPIC -O','-g -inline -fPIC -release','-g -inline -O -release',
|
|
134 '-g -fPIC -O -release','-inline -fPIC -O -release','-g -inline -fPIC -O -release'),
|
|
135 CONSTRAINT Result_c1 FOREIGN KEY (testcase) REFERENCES Testcase (id),
|
|
136 CONSTRAINT Result_c2 FOREIGN KEY (message) REFERENCES Message (id)
|
|
137 ) ENGINE=InnoDB CHARSET=utf8;
|
|
138 `);
|
|
139
|
|
140
|
|
141 ushort[char[]] tests;
|
|
142 ushort[char[]] messages;
|
|
143
|
|
144 char[] msg;
|
|
145 bool badValgrind;
|
|
146 bool badGDB;
|
|
147
|
|
148 for(char[] line = din.readLine(); !din.eof(); line = din.readLine()){
|
|
149 if(find(line, "Torture-Sub-") == 0){
|
|
150 line = line["Torture-Sub-".length .. $];
|
|
151 int torture_id;
|
|
152 char[] result;
|
|
153 char[] name;
|
|
154 char[] root;
|
|
155
|
|
156 {
|
|
157 int i = find(line, '/');
|
|
158 torture_id = toInt(line[0 .. i]);
|
|
159 }
|
|
160
|
|
161 {
|
|
162 int a = find(line, '-');
|
|
163 int b = find(line, ':');
|
|
164 result = line[a + 1 .. b];
|
|
165 line = strip(line[b+1 .. $]);
|
|
166 }
|
|
167
|
|
168 {
|
|
169 int a = find(line, std.path.sep);
|
|
170 root = line[0 .. a];
|
|
171 name = line[a + std.path.sep.length .. $];
|
|
172 a = find(name, ' ');
|
|
173 if(a != -1){
|
|
174 name = name[0 .. a];
|
|
175 }
|
|
176 }
|
|
177
|
|
178 if(root == "complex"){
|
|
179 // ignore complex test cases
|
|
180 continue;
|
|
181 }
|
|
182
|
|
183 if(result == "XPASS" || result == "FAIL" || result == "ERROR"){
|
|
184 ushort* test_id = name in tests;
|
|
185 if(!test_id){
|
|
186 printf("insert into Testcase values(");
|
|
187 toText(name);
|
|
188 printf(",");
|
|
189 toBlob(replace(cast(char[]) read(root ~ std.path.sep ~ name), "$HeadURL: /local/dstress/", "$HeadURL: http://dstress.kuehne.cn/"));
|
|
190 ushort new_id = cast(ushort)(tests.length + 1);
|
|
191 printf(", %hu, '%.*s');\n", new_id, root);
|
|
192 tests[name] = new_id;
|
|
193 test_id = name in tests;
|
|
194 }
|
|
195
|
|
196 if(badValgrind){
|
|
197 msg = "Valgrind";
|
|
198 }else if(badGDB){
|
|
199 msg = "GDB";
|
|
200 }else {
|
|
201 msg = stripMessage(msg, root ~ std.path.sep ~ name);
|
|
202 }
|
|
203 ushort* message_id = msg in messages;
|
|
204 if(!message_id){
|
|
205 ushort new_id = cast(ushort) (messages.length + 1);
|
|
206 printf("insert into Message values(%hu, ", new_id);
|
|
207 toText(msg);
|
|
208 printf(");\n");
|
|
209 messages[msg] = new_id;
|
|
210 message_id = msg in messages;
|
|
211 }
|
|
212 printf("insert into Result values(%hu, %hu, '%.*s', '%.*s');\n", *test_id,
|
|
213 *message_id, result, TORTURE_FLAGS[torture_id - 1]);
|
|
214 }else{
|
|
215 // ignore 'good' results
|
|
216 }
|
|
217 msg.length = 0;
|
|
218 badValgrind = false;
|
|
219 badGDB = false;
|
|
220 continue;
|
|
221 }
|
|
222
|
|
223 if(line.length < 1){
|
|
224 continue;
|
|
225 }
|
|
226 if(line == "--------"){
|
|
227 continue;
|
|
228 }
|
|
229 if(line == "EXIT CODE: 0"){
|
|
230 msg.length = 0;
|
|
231 continue;
|
|
232 }
|
|
233 if(find(line, "EXIT CODE:") == 0){
|
|
234 continue;
|
|
235 }
|
|
236 if(find(line, "compile:") == 0 || find(line, "run:") == 0 || find(line, "norun:") == 0 || find(line, "nocompile:") == 0){
|
|
237 continue;
|
|
238 }
|
|
239 if(find(line, "gcc ./obj/") == 0 || find(line, "creating a DT_TEXTREL in object") != -1){
|
|
240 continue;
|
|
241 }
|
|
242 if(find(line, "valgrind --leak-check=no") == 0){
|
|
243 continue;
|
|
244 }
|
|
245 if(find(line, "==") == 0){
|
|
246 badValgrind=true;
|
|
247 line = line[find(line[1 .. $], "==") + 1 + 3 .. $];
|
|
248 }
|
|
249 if(find(line, "This GDB was configured") == 0){
|
|
250 badGDB = true;
|
|
251 }
|
|
252 if(find(line, "/opt/dmd/bin/") == 0){
|
|
253 line = "Killed";
|
|
254 }
|
|
255 if(msg.length){
|
|
256 msg ~= '\n';
|
|
257 msg ~= line;
|
|
258 }else{
|
|
259 msg = line.dup;
|
|
260 }
|
|
261 }
|
|
262
|
|
263 return 0;
|
|
264 }
|