~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to dbug/tests-t.pl

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env perl
 
2
 
 
3
#
 
4
#  A driver program to test DBUG features - runs tests (shell commands)
 
5
#  from the end of file to invoke tests.c, which does the real dbug work.
 
6
#
 
7
 
 
8
use Test::More;
 
9
 
 
10
$exe=$0;
 
11
 
 
12
die unless $exe =~ s/(tests)-t(\.exe)?$/$1$2 /;
 
13
 
 
14
# load tests
 
15
@tests=();
 
16
while (<DATA>) {
 
17
  if (/^% \.\/tests /) {
 
18
    push @tests, [ $' ]
 
19
  } elsif (/^#/) {
 
20
    next;
 
21
  } else {
 
22
    push @{$tests[$#tests]}, $_
 
23
  }
 
24
}
 
25
 
 
26
plan skip_all => "because dbug is disabled" if system $exe;
 
27
 
 
28
plan tests => scalar(@tests);
 
29
 
 
30
for (@tests) {
 
31
  $t=$exe . shift @$_;
 
32
  chomp($t);
 
33
  open F, '-|',  $t or die "open($t|): $!";
 
34
  local $";
 
35
  $out=join($", <F>); close(F);
 
36
  # special cases are handled here:
 
37
  $out =~ s/Memory: 0x[0-9A-Fa-f]+/Memory: 0x####/g if $t =~ /dump/;
 
38
  # compare ("\n" at the beginning makes better output in case of errors)
 
39
  is("\n$out","\n@$_", $t);
 
40
}
 
41
 
 
42
__DATA__
 
43
% ./tests -#d
 
44
func2: info: s=ok
 
45
=> execute
 
46
=> evaluate: ON
 
47
=> evaluate_if: OFF
 
48
main: explain: dbug explained: d
 
49
func2: info: s=ok
 
50
% ./tests d,ret3
 
51
=> evaluate: OFF
 
52
=> evaluate_if: OFF
 
53
#
 
54
## Testing negative lists
 
55
#
 
56
% ./tests d:-d,ret3
 
57
func2: info: s=ko
 
58
=> execute
 
59
=> evaluate: ON
 
60
=> evaluate_if: OFF
 
61
main: explain: dbug explained: d:-d,ret3
 
62
func2: info: s=ko
 
63
% ./tests t:-d,ret3
 
64
>main
 
65
| >func1
 
66
| | >func2
 
67
| | | >func3
 
68
| | | <func3
 
69
| | <func2
 
70
| <func1
 
71
=> evaluate: OFF
 
72
=> evaluate_if: OFF
 
73
| >func2
 
74
| | >func3
 
75
| | <func3
 
76
| <func2
 
77
<main
 
78
% ./tests t:d,info:-d,ret3
 
79
>main
 
80
| >func1
 
81
| | >func2
 
82
| | | >func3
 
83
| | | <func3
 
84
| | | info: s=ko
 
85
| | <func2
 
86
| <func1
 
87
=> evaluate: OFF
 
88
=> evaluate_if: OFF
 
89
| >func2
 
90
| | >func3
 
91
| | <func3
 
92
| | info: s=ko
 
93
| <func2
 
94
<main
 
95
% ./tests t:d,info:-d,ret3:-f,func2
 
96
>main
 
97
| >func1
 
98
| | | >func3
 
99
| | | <func3
 
100
| <func1
 
101
=> evaluate: OFF
 
102
=> evaluate_if: OFF
 
103
| | >func3
 
104
| | <func3
 
105
<main
 
106
% ./tests t:d,info:-d,ret3:-f,func2 d,evaluate
 
107
=> evaluate: ON
 
108
=> evaluate_if: OFF
 
109
% ./tests t:d,info:-d,ret3:-f,func2 d,evaluate_if
 
110
=> evaluate: OFF
 
111
=> evaluate_if: ON
 
112
% ./tests t:d:-d,ret3:-f,func2 d,evaluate_if
 
113
=> evaluate: OFF
 
114
=> evaluate_if: ON
 
115
% ./tests t:d:-d,ret3:-f,func2
 
116
>main
 
117
| >func1
 
118
| | | >func3
 
119
| | | <func3
 
120
| <func1
 
121
=> execute
 
122
=> evaluate: ON
 
123
=> evaluate_if: OFF
 
124
| explain: dbug explained: d:-d,ret3:f:-f,func2:t
 
125
| | >func3
 
126
| | <func3
 
127
<main
 
128
#
 
129
## Adding incremental settings to the brew
 
130
#
 
131
% ./tests t:d:-d,ret3:-f,func2 +d,evaluate_if
 
132
>main
 
133
| >func1
 
134
| | | >func3
 
135
| | | <func3
 
136
| <func1
 
137
=> evaluate: OFF
 
138
=> evaluate_if: ON
 
139
| | >func3
 
140
| | <func3
 
141
<main
 
142
#
 
143
## DBUG_DUMP
 
144
#
 
145
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump
 
146
>main
 
147
| >func1
 
148
| | | >func3
 
149
| | | <func3
 
150
| <func1
 
151
| dump: Memory: 0x####  Bytes: (27)
 
152
64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A 
 
153
74 
 
154
=> evaluate: OFF
 
155
=> evaluate_if: OFF
 
156
| | >func3
 
157
| | <func3
 
158
<main
 
159
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump
 
160
>main
 
161
| >func1
 
162
| | | >func3
 
163
| | | <func3
 
164
| <func1
 
165
| dump: Memory: 0x####  Bytes: (27)
 
166
64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A 
 
167
74 
 
168
=> evaluate: OFF
 
169
=> evaluate_if: OFF
 
170
| | >func3
 
171
| | <func3
 
172
<main
 
173
% ./tests t:d:-d,ret3:f:-f,func2:+d,dump
 
174
>main
 
175
| >func1
 
176
| | | >func3
 
177
| | | <func3
 
178
| <func1
 
179
| dump: Memory: 0x####  Bytes: (27)
 
180
64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A 
 
181
74 
 
182
=> evaluate: OFF
 
183
=> evaluate_if: OFF
 
184
| | >func3
 
185
| | <func3
 
186
<main
 
187
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump,explain
 
188
>main
 
189
| >func1
 
190
| | | >func3
 
191
| | | <func3
 
192
| <func1
 
193
| dump: Memory: 0x####  Bytes: (35)
 
194
64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 
 
195
66 2C 66 75 6E 63 32 3A 74 
 
196
=> evaluate: OFF
 
197
=> evaluate_if: OFF
 
198
| explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:t
 
199
| | >func3
 
200
| | <func3
 
201
<main
 
202
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump,explain:P
 
203
dbug: >main
 
204
dbug-tests: | >func1
 
205
dbug-tests: | | | >func3
 
206
dbug-tests: | | | <func3
 
207
dbug-tests: | <func1
 
208
dbug-tests: | dump: Memory: 0x####  Bytes: (37)
 
209
64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 
 
210
66 2C 66 75 6E 63 32 3A 50 3A 74 
 
211
=> evaluate: OFF
 
212
=> evaluate_if: OFF
 
213
dbug-tests: | explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:P:t
 
214
dbug-tests: | | >func3
 
215
dbug-tests: | | <func3
 
216
dbug-tests: <main
 
217
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump,explain:P:F
 
218
dbug:        tests.c: >main
 
219
dbug-tests:        tests.c: | >func1
 
220
dbug-tests:        tests.c: | | | >func3
 
221
dbug-tests:        tests.c: | | | <func3
 
222
dbug-tests:        tests.c: | <func1
 
223
dbug-tests:        tests.c: | dump: Memory: 0x####  Bytes: (39)
 
224
64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 
 
225
66 2C 66 75 6E 63 32 3A 46 3A 50 3A 74 
 
226
=> evaluate: OFF
 
227
=> evaluate_if: OFF
 
228
dbug-tests:        tests.c: | explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:F:P:t
 
229
dbug-tests:        tests.c: | | >func3
 
230
dbug-tests:        tests.c: | | <func3
 
231
dbug-tests:        tests.c: <main
 
232
#
 
233
## DBUG_EXPLAIN, DBUG_PUSH, DBUG_POP, DBUG_SET
 
234
#
 
235
% ./tests t:d:-d,ret3:f:-f,func2
 
236
>main
 
237
| >func1
 
238
| | | >func3
 
239
| | | <func3
 
240
| <func1
 
241
=> execute
 
242
=> evaluate: ON
 
243
=> evaluate_if: OFF
 
244
| explain: dbug explained: d:-d,ret3:f:-f,func2:t
 
245
| | >func3
 
246
| | <func3
 
247
<main
 
248
% ./tests t:d:-d,ret3
 
249
>main
 
250
| >func1
 
251
| | >func2
 
252
| | | >func3
 
253
| | | <func3
 
254
| | | info: s=ko
 
255
| | <func2
 
256
| <func1
 
257
=> execute
 
258
=> evaluate: ON
 
259
=> evaluate_if: OFF
 
260
| explain: dbug explained: d:-d,ret3:t
 
261
| >func2
 
262
| | >func3
 
263
| | <func3
 
264
| | info: s=ko
 
265
| <func2
 
266
<main
 
267
% ./tests d,info:-d,ret3:d,push
 
268
func2: info: s=ko
 
269
=> evaluate: OFF
 
270
=> evaluate_if: OFF
 
271
| >func2
 
272
| | >func3
 
273
| | <func3
 
274
| | info: s=ko
 
275
| <func2
 
276
<main
 
277
% ./tests d,info:-d,ret3:d,push,explain
 
278
func2: info: s=ko
 
279
=> evaluate: OFF
 
280
=> evaluate_if: OFF
 
281
| explain: dbug explained: d,info,push,explain:-d,ret3:t
 
282
| >func2
 
283
| | >func3
 
284
| | <func3
 
285
| | info: s=ko
 
286
| <func2
 
287
<main
 
288
% ./tests d,info:-d,ret3:d,explain
 
289
func2: info: s=ko
 
290
=> evaluate: OFF
 
291
=> evaluate_if: OFF
 
292
main: explain: dbug explained: d,info,explain:-d,ret3
 
293
func2: info: s=ko
 
294
% ./tests d,info:-d,ret3:d,explain,pop
 
295
func2: info: s=ko
 
296
=> evaluate: OFF
 
297
=> evaluate_if: OFF
 
298
% ./tests d,info:-d,ret3:d,explain t:d,pop
 
299
>main
 
300
| >func1
 
301
| | >func2
 
302
| | | >func3
 
303
| | | <func3
 
304
| | <func2
 
305
| <func1
 
306
=> evaluate: OFF
 
307
=> evaluate_if: OFF
 
308
main: explain: dbug explained: d,info,explain:-d,ret3
 
309
func2: info: s=ko
 
310
% ./tests d,info:-d,ret3:d,explain,pop +t
 
311
>main
 
312
| >func1
 
313
| | >func2
 
314
| | | >func3
 
315
| | | <func3
 
316
| | | info: s=ko
 
317
| | <func2
 
318
| <func1
 
319
=> evaluate: OFF
 
320
=> evaluate_if: OFF
 
321
main: explain: dbug explained: d,info,explain,pop:-d,ret3
 
322
func2: info: s=ko
 
323
% ./tests d,info:-d,ret3:d,explain,set
 
324
func2: info: s=ko
 
325
=> evaluate: OFF
 
326
=> evaluate_if: OFF
 
327
       tests.c: main: explain: dbug explained: d,info,explain,set:-d,ret3:F
 
328
       tests.c: func2: info: s=ko
 
329
% ./tests d,info:-d,ret3:d,explain,set:t
 
330
>main
 
331
| >func1
 
332
| | >func2
 
333
| | | >func3
 
334
| | | <func3
 
335
| | | info: s=ko
 
336
| | <func2
 
337
| <func1
 
338
=> evaluate: OFF
 
339
=> evaluate_if: OFF
 
340
       tests.c: | explain: dbug explained: d,info,explain,set:-d,ret3:F:t
 
341
       tests.c: | >func2
 
342
       tests.c: | | >func3
 
343
       tests.c: | | <func3
 
344
       tests.c: | | info: s=ko
 
345
       tests.c: | <func2
 
346
       tests.c: <main
 
347
% ./tests t d,info:-d,ret3:d,explain,set:t
 
348
>main
 
349
| >func1
 
350
| | >func2
 
351
| | | >func3
 
352
| | | <func3
 
353
| | | info: s=ko
 
354
| | <func2
 
355
| <func1
 
356
=> evaluate: OFF
 
357
=> evaluate_if: OFF
 
358
       tests.c: | explain: dbug explained: d,info,explain,set:-d,ret3:F:t
 
359
       tests.c: | >func2
 
360
       tests.c: | | >func3
 
361
       tests.c: | | <func3
 
362
       tests.c: | | info: s=ko
 
363
       tests.c: | <func2
 
364
       tests.c: <main
 
365
% ./tests t d,info:-d,ret3:d,explain,set,pop
 
366
func2: info: s=ko
 
367
=> evaluate: OFF
 
368
=> evaluate_if: OFF
 
369
| >func2
 
370
| | >func3
 
371
| | <func3
 
372
| <func2
 
373
<main
 
374
% ./tests t:f,func2
 
375
| | >func2
 
376
| | <func2
 
377
=> evaluate: OFF
 
378
=> evaluate_if: OFF
 
379
| >func2
 
380
| <func2
 
381
#
 
382
## Testing SUBDIR rules
 
383
#
 
384
% ./tests t:-f,func2/:d
 
385
>main
 
386
| >func1
 
387
| <func1
 
388
=> execute
 
389
=> evaluate: ON
 
390
=> evaluate_if: OFF
 
391
| explain: dbug explained: d:f:-f,func2/:t
 
392
<main
 
393
% ./tests t:f,func1/:d
 
394
| >func1
 
395
| | >func2
 
396
| | | >func3
 
397
| | | <func3
 
398
| | | info: s=ok
 
399
| | <func2
 
400
| <func1
 
401
=> evaluate: OFF
 
402
=> evaluate_if: OFF
 
403
% ./tests t:f,main/:d,pop
 
404
>main
 
405
| >func1
 
406
| | >func2
 
407
| | | >func3
 
408
| | | <func3
 
409
| | <func2
 
410
| <func1
 
411
=> evaluate: OFF
 
412
=> evaluate_if: OFF
 
413
% ./tests f,main/:d,push
 
414
=> evaluate: OFF
 
415
=> evaluate_if: OFF
 
416
| >func2
 
417
| | >func3
 
418
| | <func3
 
419
| <func2
 
420
<main
 
421
#
 
422
## Testing FixTraceFlags() - when we need to traverse the call stack
 
423
# (these tests fail with FixTraceFlags() disabled)
 
424
#
 
425
# delete the INCLUDE rule up the stack
 
426
% ./tests t:f,func1/ --push1=t:f,func3/
 
427
| >func1
 
428
| | >func2
 
429
| | | >func3
 
430
| | | <func3
 
431
| | <func2
 
432
=> push1
 
433
=> evaluate: OFF
 
434
=> evaluate_if: OFF
 
435
| | >func3
 
436
| | <func3
 
437
# delete the EXCLUDE rule up the stack
 
438
% ./tests t:-f,func1/ --push1=t
 
439
>main
 
440
=> push1
 
441
| <func1
 
442
=> evaluate: OFF
 
443
=> evaluate_if: OFF
 
444
| >func2
 
445
| | >func3
 
446
| | <func3
 
447
| <func2
 
448
<main
 
449
# add the INCLUDE rule up the stack
 
450
% ./tests t:f,func3 --push1=t:f,main/
 
451
| | | >func3
 
452
| | | <func3
 
453
=> push1
 
454
| <func1
 
455
=> evaluate: OFF
 
456
=> evaluate_if: OFF
 
457
| >func2
 
458
| | >func3
 
459
| | <func3
 
460
| <func2
 
461
<main
 
462
# add the EXCLUDE rule up the stack
 
463
% ./tests t --push1=t:-f,main/
 
464
>main
 
465
| >func1
 
466
| | >func2
 
467
| | | >func3
 
468
| | | <func3
 
469
| | <func2
 
470
=> push1
 
471
=> evaluate: OFF
 
472
=> evaluate_if: OFF
 
473
# change the defaults
 
474
% ./tests t:f,func3 --push1=t
 
475
| | | >func3
 
476
| | | <func3
 
477
=> push1
 
478
| <func1
 
479
=> evaluate: OFF
 
480
=> evaluate_if: OFF
 
481
| >func2
 
482
| | >func3
 
483
| | <func3
 
484
| <func2
 
485
<main