1819.2.1
by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error. |
1 |
# -*- cperl -*- |
2 |
# Copyright (C) 2005-2006 MySQL AB |
|
3 |
#
|
|
4 |
# This program is free software; you can redistribute it and/or modify |
|
5 |
# it under the terms of the GNU General Public License as published by |
|
6 |
# the Free Software Foundation; version 2 of the License. |
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful, |
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 |
# GNU General Public License for more details. |
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License |
|
14 |
# along with this program; if not, write to the Free Software |
|
15 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
16 |
||
17 |
# This is a library file used by the Perl version of drizzle-test-run, |
|
18 |
# and is part of the translation of the Bourne shell script with the |
|
19 |
# same name. |
|
20 |
||
21 |
use File::Basename; |
|
22 |
use IO::File(); |
|
23 |
use strict; |
|
24 |
||
25 |
use My::Config; |
|
26 |
||
27 |
sub collect_test_cases ($); |
|
28 |
sub collect_one_suite ($); |
|
29 |
sub collect_one_test_case ($$$$$$$$$); |
|
30 |
||
31 |
sub dtr_options_from_test_file($$); |
|
32 |
||
33 |
my $do_test; |
|
34 |
my $skip_test; |
|
35 |
||
36 |
sub init_pattern { |
|
37 |
my ($from, $what)= @_; |
|
38 |
if ( $from =~ /^[a-z0-9]$/ ) { |
|
39 |
# Does not contain any regex, make the pattern match |
|
40 |
# beginning of string |
|
41 |
$from= "^$from"; |
|
42 |
}
|
|
43 |
# Check that pattern is a valid regex |
|
44 |
eval { "" =~/$from/; 1 } or |
|
45 |
dtr_error("Invalid regex '$from' passed to $what\nPerl says: $@"); |
|
46 |
return $from; |
|
47 |
}
|
|
48 |
||
49 |
||
50 |
||
51 |
##############################################################################
|
|
52 |
#
|
|
53 |
# Collect information about test cases we are to run |
|
54 |
#
|
|
55 |
##############################################################################
|
|
56 |
||
57 |
sub collect_test_cases ($) { |
|
58 |
$do_test= init_pattern($::opt_do_test, "--do-test"); |
|
59 |
$skip_test= init_pattern($::opt_skip_test, "--skip-test"); |
|
60 |
||
61 |
my $suites= shift; # Semicolon separated list of test suites |
|
62 |
my $cases = []; # Array of hash |
|
63 |
||
64 |
foreach my $suite (split(",", $suites)) |
|
65 |
{
|
|
66 |
push(@$cases, collect_one_suite($suite)); |
|
67 |
}
|
|
68 |
||
69 |
||
70 |
if ( @::opt_cases ) |
|
71 |
{
|
|
72 |
# Check that the tests specified was found |
|
73 |
# in at least one suite |
|
74 |
foreach my $test_name_spec ( @::opt_cases ) |
|
75 |
{
|
|
76 |
my $found= 0; |
|
77 |
my ($sname, $tname, $extension)= split_testname($test_name_spec); |
|
78 |
foreach my $test ( @$cases ) |
|
79 |
{
|
|
80 |
# test->{name} is always in suite.name format |
|
81 |
if ( $test->{name} =~ /.*\.$tname/ ) |
|
82 |
{
|
|
83 |
$found= 1; |
|
84 |
}
|
|
85 |
}
|
|
86 |
if ( not $found ) |
|
87 |
{
|
|
88 |
dtr_error("Could not find $tname in any suite"); |
|
89 |
}
|
|
90 |
}
|
|
91 |
}
|
|
92 |
||
93 |
if ( $::opt_reorder ) |
|
94 |
{
|
|
95 |
# Reorder the test cases in an order that will make them faster to run |
|
96 |
my %sort_criteria; |
|
97 |
||
98 |
# Make a mapping of test name to a string that represents how that test |
|
99 |
# should be sorted among the other tests. Put the most important criterion |
|
100 |
# first, then a sub-criterion, then sub-sub-criterion, et c. |
|
101 |
foreach my $tinfo (@$cases) |
|
102 |
{
|
|
103 |
my @criteria = (); |
|
104 |
||
105 |
# Look for tests that muct be in run in a defined order |
|
106 |
# that is defined by test having the same name except for |
|
107 |
# the ending digit |
|
108 |
||
109 |
# Put variables into hash |
|
110 |
my $test_name= $tinfo->{'name'}; |
|
111 |
my $depend_on_test_name; |
|
112 |
if ( $test_name =~ /^([\D]+)([0-9]{1})$/ ) |
|
113 |
{
|
|
114 |
my $base_name= $1; |
|
115 |
my $idx= $2; |
|
116 |
dtr_verbose("$test_name => $base_name idx=$idx"); |
|
117 |
if ( $idx > 1 ) |
|
118 |
{
|
|
119 |
$idx-= 1; |
|
120 |
$base_name= "$base_name$idx"; |
|
121 |
dtr_verbose("New basename $base_name"); |
|
122 |
}
|
|
123 |
||
124 |
foreach my $tinfo2 (@$cases) |
|
125 |
{
|
|
126 |
if ( $tinfo2->{'name'} eq $base_name ) |
|
127 |
{
|
|
128 |
dtr_verbose("found dependent test $tinfo2->{'name'}"); |
|
129 |
$depend_on_test_name=$base_name; |
|
130 |
}
|
|
131 |
}
|
|
132 |
}
|
|
133 |
||
134 |
if ( defined $depend_on_test_name ) |
|
135 |
{
|
|
136 |
dtr_verbose("Giving $test_name same critera as $depend_on_test_name"); |
|
137 |
$sort_criteria{$test_name} = $sort_criteria{$depend_on_test_name}; |
|
138 |
}
|
|
139 |
else
|
|
140 |
{
|
|
141 |
#
|
|
142 |
# Append the criteria for sorting, in order of importance. |
|
143 |
#
|
|
144 |
# Group test with equal options together. |
|
145 |
# Ending with "~" makes empty sort later than filled |
|
146 |
push(@criteria, join("!", sort @{$tinfo->{'master_opt'}}) . "~"); |
|
147 |
||
148 |
$sort_criteria{$test_name} = join(" ", @criteria); |
|
149 |
}
|
|
150 |
}
|
|
151 |
||
152 |
@$cases = sort { |
|
153 |
$sort_criteria{$a->{'name'}} . $a->{'name'} cmp |
|
154 |
$sort_criteria{$b->{'name'}} . $b->{'name'}; } @$cases; |
|
155 |
||
156 |
if ( $::opt_script_debug ) |
|
157 |
{
|
|
158 |
# For debugging the sort-order |
|
159 |
foreach my $tinfo (@$cases) |
|
160 |
{
|
|
161 |
print("$sort_criteria{$tinfo->{'name'}} -> \t$tinfo->{'name'}\n"); |
|
162 |
}
|
|
163 |
}
|
|
164 |
}
|
|
165 |
||
166 |
return $cases; |
|
167 |
||
168 |
}
|
|
169 |
||
170 |
# Valid extensions and their corresonding component id |
|
171 |
my %exts = ( 'test' => 'drizzled', |
|
172 |
'imtest' => 'im' |
|
173 |
);
|
|
174 |
||
175 |
||
176 |
# Returns (suitename, testname, extension) |
|
177 |
sub split_testname { |
|
178 |
my ($test_name)= @_; |
|
179 |
||
180 |
# Get rid of directory part and split name on .'s |
|
181 |
my @parts= split(/\./, basename($test_name));
|
|
182 |
||
183 |
if (@parts == 1){
|
|
184 |
# Only testname given, ex: alias
|
|
185 |
return (undef , $parts[0], undef);
|
|
186 |
} elsif (@parts == 2) {
|
|
187 |
# Either testname.test or suite.testname given
|
|
188 |
# Ex. main.alias or alias.test
|
|
189 |
||
190 |
if (defined $exts{$parts[1]})
|
|
191 |
{
|
|
192 |
return (undef , $parts[0], $parts[1]);
|
|
193 |
}
|
|
194 |
else
|
|
195 |
{
|
|
196 |
return ($parts[0], $parts[1], undef);
|
|
197 |
}
|
|
198 |
||
199 |
} elsif (@parts == 3) {
|
|
200 |
# Fully specified suitename.testname.test
|
|
201 |
# ex main.alias.test
|
|
202 |
return ( $parts[0], $parts[1], $parts[2]);
|
|
203 |
}
|
|
204 |
||
205 |
dtr_error("Illegal format of test name: $test_name");
|
|
206 |
}
|
|
207 |
||
208 |
||
209 |
sub collect_one_suite($)
|
|
210 |
{
|
|
211 |
my $suite= shift; # Test suite name
|
|
212 |
my @cases; # Array of hash
|
|
213 |
||
214 |
dtr_verbose("Collecting: $suite");
|
|
215 |
||
216 |
my $suitepath= "$::glob_suite_path";
|
|
217 |
my $suitedir= "$::glob_drizzle_test_dir"; # Default
|
|
218 |
if ( $suite ne "main" )
|
|
219 |
{
|
|
220 |
$suitedir= dtr_path_exists(
|
|
221 |
"$suitepath/$suite/drizzle-tests",
|
|
222 |
"$suitepath/$suite/tests",
|
|
223 |
"$suitedir/suite/$suite",
|
|
224 |
"$suitedir/$suite");
|
|
225 |
dtr_verbose("suitedir: $suitedir");
|
|
226 |
}
|
|
227 |
||
228 |
my $testdir= "$suitedir/t";
|
|
229 |
my $resdir= "$suitedir/r";
|
|
230 |
||
231 |
# ----------------------------------------------------------------------
|
|
232 |
# Build a hash of disabled testcases for this suite
|
|
233 |
# ----------------------------------------------------------------------
|
|
234 |
my %disabled;
|
|
235 |
if ( open(DISABLED, "$testdir/disabled.def" ) )
|
|
236 |
{
|
|
237 |
while ( <DISABLED> )
|
|
238 |
{
|
|
239 |
chomp;
|
|
240 |
if ( /^\s*(\S+)\s*:\s*(.*?)\s*$/ )
|
|
241 |
{
|
|
242 |
$disabled{$1}= $2;
|
|
243 |
}
|
|
244 |
}
|
|
245 |
close DISABLED;
|
|
246 |
}
|
|
247 |
||
248 |
# Read suite.opt file
|
|
249 |
my $suite_opt_file= "$testdir/suite.opt";
|
|
250 |
my $suite_opts= [];
|
|
251 |
if ( -f $suite_opt_file )
|
|
252 |
{
|
|
253 |
$suite_opts= dtr_get_opts_from_file($suite_opt_file);
|
|
254 |
}
|
|
255 |
||
2225.5.2
by patrick crews
Changes to test-run.pl to skip tests if we detect a .cnf file (signals it is dbqp) |
256 |
|
1819.2.1
by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error. |
257 |
if ( @::opt_cases )
|
258 |
{
|
|
259 |
# Collect in specified order
|
|
260 |
foreach my $test_name_spec ( @::opt_cases )
|
|
261 |
{
|
|
262 |
my ($sname, $tname, $extension)= split_testname($test_name_spec);
|
|
263 |
||
264 |
# The test name parts have now been defined
|
|
265 |
#print " suite_name: $sname\n";
|
|
266 |
#print " tname: $tname\n";
|
|
267 |
#print " extension: $extension\n";
|
|
268 |
||
269 |
# Check cirrect suite if suitename is defined
|
|
270 |
next if (defined $sname and $suite ne $sname);
|
|
271 |
||
272 |
my $component_id;
|
|
273 |
if ( defined $extension )
|
|
274 |
{
|
|
275 |
my $full_name= "$testdir/$tname.$extension";
|
|
276 |
# Extension was specified, check if the test exists
|
|
277 |
if ( ! -f $full_name)
|
|
278 |
{
|
|
279 |
# This is only an error if suite was specified, otherwise it
|
|
280 |
# could exist in another suite
|
|
281 |
dtr_error("Test '$full_name' was not found in suite '$sname'") |
|
282 |
if $sname;
|
|
283 |
||
284 |
next;
|
|
285 |
}
|
|
286 |
$component_id= $exts{$extension};
|
|
287 |
}
|
|
288 |
else
|
|
289 |
{
|
|
290 |
# No extension was specified
|
|
291 |
my ($ext, $component);
|
|
292 |
while (($ext, $component)= each %exts) {
|
|
293 |
my $full_name= "$testdir/$tname.$ext";
|
|
294 |
||
295 |
if ( ! -f $full_name ) {
|
|
296 |
next;
|
|
297 |
}
|
|
298 |
$component_id= $component;
|
|
299 |
$extension= $ext;
|
|
300 |
}
|
|
301 |
# Test not found here, could exist in other suite
|
|
302 |
next unless $component_id;
|
|
303 |
}
|
|
304 |
||
305 |
collect_one_test_case($testdir,$resdir,$suite,$tname,
|
|
306 |
"$tname.$extension",\@cases,\%disabled,
|
|
307 |
$component_id,$suite_opts);
|
|
308 |
}
|
|
309 |
}
|
|
310 |
else
|
|
311 |
{
|
|
312 |
opendir(TESTDIR, $testdir) or dtr_error("Can't open dir \"$testdir\": $!"); |
|
313 |
||
314 |
foreach my $elem ( sort readdir(TESTDIR) ) |
|
315 |
{
|
|
316 |
my $component_id= undef; |
|
317 |
my $tname= undef; |
|
318 |
||
319 |
if ($tname= dtr_match_extension($elem, 'test')) |
|
320 |
{
|
|
321 |
$component_id = 'drizzled'; |
|
322 |
}
|
|
323 |
elsif ($tname= dtr_match_extension($elem, 'imtest')) |
|
324 |
{
|
|
325 |
$component_id = 'im'; |
|
326 |
}
|
|
327 |
else
|
|
328 |
{
|
|
329 |
next; |
|
330 |
}
|
|
331 |
||
332 |
# Skip tests that does not match the --do-test= filter |
|
333 |
next if ($do_test and not $tname =~ /$do_test/o); |
|
334 |
||
335 |
collect_one_test_case($testdir,$resdir,$suite,$tname, |
|
336 |
$elem,\@cases,\%disabled,$component_id, |
|
337 |
$suite_opts); |
|
338 |
}
|
|
339 |
closedir TESTDIR; |
|
340 |
}
|
|
341 |
||
342 |
||
343 |
# Return empty list if no testcases found |
|
344 |
return if (@cases == 0); |
|
345 |
||
346 |
# ---------------------------------------------------------------------- |
|
347 |
# Read combinations for this suite and build testcases x combinations |
|
348 |
# if any combinations exists |
|
349 |
# ---------------------------------------------------------------------- |
|
350 |
if ( ! $::opt_skip_combination ) |
|
351 |
{
|
|
352 |
my @combinations; |
|
353 |
my $combination_file= "$suitedir/combinations"; |
|
354 |
#print "combination_file: $combination_file\n"; |
|
355 |
if (@::opt_combinations) |
|
356 |
{
|
|
357 |
# take the combination from command-line |
|
358 |
dtr_verbose("Take the combination from command line"); |
|
359 |
foreach my $combination (@::opt_combinations) { |
|
360 |
my $comb= {}; |
|
361 |
$comb->{name}= $combination; |
|
362 |
push(@{$comb->{comb_opt}}, $combination); |
|
363 |
push(@combinations, $comb); |
|
364 |
}
|
|
365 |
}
|
|
366 |
elsif (-f $combination_file ) |
|
367 |
{
|
|
368 |
# Read combinations file in my.cnf format |
|
369 |
dtr_verbose("Read combinations file"); |
|
370 |
my $config= My::Config->new($combination_file); |
|
371 |
||
372 |
foreach my $group ($config->groups()) { |
|
373 |
my $comb= {}; |
|
374 |
$comb->{name}= $group->name(); |
|
375 |
foreach my $option ( $group->options() ) { |
|
376 |
push(@{$comb->{comb_opt}}, $option->name()."=".$option->value()); |
|
377 |
}
|
|
378 |
push(@combinations, $comb); |
|
379 |
}
|
|
380 |
}
|
|
381 |
||
382 |
if (@combinations) |
|
383 |
{
|
|
384 |
print " - adding combinations\n"; |
|
385 |
#print_testcases(@cases); |
|
386 |
||
387 |
my @new_cases; |
|
388 |
foreach my $comb (@combinations) |
|
389 |
{
|
|
390 |
foreach my $test (@cases) |
|
391 |
{
|
|
392 |
#print $test->{name}, " ", $comb, "\n"; |
|
393 |
my $new_test= {}; |
|
394 |
||
395 |
while (my ($key, $value) = each(%$test)) { |
|
396 |
if (ref $value eq "ARRAY") { |
|
397 |
push(@{$new_test->{$key}}, @$value); |
|
398 |
} else { |
|
399 |
$new_test->{$key}= $value; |
|
400 |
}
|
|
401 |
}
|
|
402 |
||
403 |
# Append the combination options to master_opt and slave_opt |
|
404 |
push(@{$new_test->{master_opt}}, @{$comb->{comb_opt}}); |
|
405 |
push(@{$new_test->{slave_opt}}, @{$comb->{comb_opt}}); |
|
406 |
||
407 |
# Add combination name shrt name |
|
408 |
$new_test->{combination}= $comb->{name}; |
|
409 |
||
410 |
# Add the new test to new test cases list |
|
411 |
push(@new_cases, $new_test); |
|
412 |
}
|
|
413 |
}
|
|
414 |
#print_testcases(@new_cases); |
|
415 |
@cases= @new_cases; |
|
416 |
#print_testcases(@cases); |
|
417 |
}
|
|
418 |
}
|
|
419 |
||
420 |
optimize_cases(\@cases); |
|
421 |
#print_testcases(@cases); |
|
422 |
||
423 |
return @cases; |
|
424 |
}
|
|
425 |
||
426 |
||
427 |
#
|
|
428 |
# Loop through all test cases |
|
429 |
# - optimize which test to run by skipping unnecessary ones |
|
430 |
# - update settings if necessary |
|
431 |
#
|
|
432 |
sub optimize_cases { |
|
433 |
my ($cases)= @_; |
|
434 |
||
435 |
foreach my $tinfo ( @$cases ) |
|
436 |
{
|
|
437 |
# Skip processing if already marked as skipped |
|
438 |
next if $tinfo->{skip}; |
|
439 |
||
440 |
# Replication test needs an adjustment of binlog format |
|
441 |
if (dtr_match_prefix($tinfo->{'name'}, "rpl")) |
|
442 |
{
|
|
443 |
||
444 |
# ======================================================= |
|
445 |
# Get binlog-format used by this test from master_opt |
|
446 |
# ======================================================= |
|
447 |
my $test_binlog_format; |
|
448 |
foreach my $opt ( @{$tinfo->{master_opt}} ) { |
|
449 |
$test_binlog_format= $test_binlog_format || |
|
450 |
dtr_match_prefix($opt, "--binlog-format="); |
|
451 |
}
|
|
452 |
# print $tinfo->{name}." uses ".$test_binlog_format."\n"; |
|
453 |
||
454 |
# ======================================================= |
|
455 |
# If a special binlog format was selected with |
|
456 |
# --drizzled=--binlog-format=x, skip all test with different |
|
457 |
# binlog-format |
|
458 |
# ======================================================= |
|
459 |
if (defined $::used_binlog_format and |
|
460 |
$test_binlog_format and |
|
461 |
$::used_binlog_format ne $test_binlog_format) |
|
462 |
{
|
|
463 |
$tinfo->{'skip'}= 1; |
|
464 |
$tinfo->{'comment'}= "Requires --binlog-format='$test_binlog_format'"; |
|
465 |
next; |
|
466 |
}
|
|
467 |
||
468 |
# ======================================================= |
|
469 |
# Check that testcase supports the designated binlog-format |
|
470 |
# ======================================================= |
|
471 |
if ($test_binlog_format and defined $tinfo->{'sup_binlog_formats'} ) |
|
472 |
{
|
|
473 |
my $supported= |
|
474 |
grep { $_ eq $test_binlog_format } @{$tinfo->{'sup_binlog_formats'}}; |
|
475 |
if ( !$supported ) |
|
476 |
{
|
|
477 |
$tinfo->{'skip'}= 1; |
|
478 |
$tinfo->{'comment'}= |
|
479 |
"Doesn't support --binlog-format='$test_binlog_format'"; |
|
480 |
next; |
|
481 |
}
|
|
482 |
}
|
|
483 |
||
484 |
# ======================================================= |
|
485 |
# Use dynamic switching of binlog-format if dtr started |
|
486 |
# w/o --drizzled=--binlog-format=xxx and combinations. |
|
487 |
# ======================================================= |
|
488 |
if (!defined $tinfo->{'combination'} and |
|
489 |
!defined $::used_binlog_format) |
|
490 |
{
|
|
491 |
$test_binlog_format= $tinfo->{'sup_binlog_formats'}->[0]; |
|
492 |
}
|
|
493 |
||
494 |
# Save binlog format for dynamic switching |
|
495 |
$tinfo->{binlog_format}= $test_binlog_format; |
|
496 |
}
|
|
497 |
}
|
|
498 |
}
|
|
499 |
||
500 |
||
501 |
##############################################################################
|
|
502 |
#
|
|
503 |
# Collect information about a single test case |
|
504 |
#
|
|
505 |
##############################################################################
|
|
506 |
||
507 |
||
508 |
sub collect_one_test_case($$$$$$$$$) { |
|
509 |
my $testdir= shift; |
|
510 |
my $resdir= shift; |
|
511 |
my $suite= shift; |
|
512 |
my $tname= shift; |
|
513 |
my $elem= shift; |
|
514 |
my $cases= shift; |
|
515 |
my $disabled=shift; |
|
516 |
my $component_id= shift; |
|
517 |
my $suite_opts= shift; |
|
518 |
||
519 |
my $path= "$testdir/$elem"; |
|
520 |
||
521 |
# ---------------------------------------------------------------------- |
|
522 |
# Skip some tests silently |
|
523 |
# ---------------------------------------------------------------------- |
|
524 |
||
525 |
if ( $::opt_start_from and $tname lt $::opt_start_from ) |
|
526 |
{
|
|
527 |
return; |
|
528 |
}
|
|
529 |
||
530 |
||
531 |
my $tinfo= {}; |
|
532 |
$tinfo->{'name'}= basename($suite) . ".$tname"; |
|
533 |
if ( -f "$resdir/$::opt_engine/$tname.result") |
|
534 |
{
|
|
535 |
$tinfo->{'result_file'}= "$resdir/$::opt_engine/$tname.result"; |
|
536 |
}
|
|
537 |
else
|
|
538 |
{
|
|
539 |
$tinfo->{'result_file'}= "$resdir/$tname.result"; |
|
540 |
}
|
|
541 |
$tinfo->{'component_id'} = $component_id; |
|
542 |
push(@$cases, $tinfo); |
|
543 |
||
544 |
# ---------------------------------------------------------------------- |
|
545 |
# Skip some tests but include in list, just mark them to skip |
|
546 |
# ---------------------------------------------------------------------- |
|
547 |
||
548 |
if ( $skip_test and $tname =~ /$skip_test/o ) |
|
549 |
{
|
|
550 |
$tinfo->{'skip'}= 1; |
|
551 |
return; |
|
552 |
}
|
|
2225.5.2
by patrick crews
Changes to test-run.pl to skip tests if we detect a .cnf file (signals it is dbqp) |
553 |
my $master_cnf_file = "$testdir/master.cnf"; |
554 |
my $test_cnf_file = "$testdir/$tname.cnf"; |
|
555 |
if (-e $master_cnf_file || -e $test_cnf_file) |
|
556 |
{
|
|
557 |
$tinfo->{'skip'}= 1; |
|
558 |
}
|
|
1819.2.1
by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error. |
559 |
|
560 |
# ---------------------------------------------------------------------- |
|
561 |
# Collect information about test case |
|
562 |
# ---------------------------------------------------------------------- |
|
563 |
||
564 |
$tinfo->{'path'}= $path; |
|
565 |
$tinfo->{'timezone'}= "GMT-3"; # for UNIX_TIMESTAMP tests to work |
|
566 |
||
567 |
$tinfo->{'slave_num'}= 0; # Default, no slave |
|
568 |
$tinfo->{'master_num'}= 1; # Default, 1 master |
|
569 |
if ( defined dtr_match_prefix($tname,"rpl") ) |
|
570 |
{
|
|
571 |
if ( $::opt_skip_rpl ) |
|
572 |
{
|
|
573 |
$tinfo->{'skip'}= 1; |
|
574 |
$tinfo->{'comment'}= "No replication tests(--skip-rpl)"; |
|
575 |
return; |
|
576 |
}
|
|
577 |
||
578 |
$tinfo->{'slave_num'}= 1; # Default for rpl* tests, use one slave |
|
579 |
||
580 |
}
|
|
581 |
||
582 |
if ( defined dtr_match_prefix($tname,"federated") ) |
|
583 |
{
|
|
584 |
# Default, federated uses the first slave as it's federated database |
|
585 |
$tinfo->{'slave_num'}= 1;
|
|
586 |
}
|
|
587 |
||
588 |
my $global_master_opt_file= "$testdir/master.opt";
|
|
589 |
my $test_master_opt_file= "$testdir/$tname-master.opt";
|
|
590 |
my $slave_opt_file= "$testdir/$tname-slave.opt";
|
|
591 |
my $slave_mi_file= "$testdir/$tname.slave-mi";
|
|
592 |
my $master_sh= "$testdir/$tname-master.sh";
|
|
593 |
my $slave_sh= "$testdir/$tname-slave.sh";
|
|
594 |
my $disabled_file= "$testdir/$tname.disabled";
|
|
595 |
my $im_opt_file= "$testdir/$tname-im.opt";
|
|
596 |
||
597 |
$tinfo->{'master_opt'}= [];
|
|
598 |
$tinfo->{'slave_opt'}= [];
|
|
599 |
$tinfo->{'slave_mi'}= [];
|
|
600 |
||
601 |
||
602 |
# Add suite opts
|
|
603 |
foreach my $opt ( @$suite_opts )
|
|
604 |
{
|
|
605 |
dtr_verbose($opt);
|
|
606 |
push(@{$tinfo->{'master_opt'}}, $opt);
|
|
607 |
push(@{$tinfo->{'slave_opt'}}, $opt);
|
|
608 |
}
|
|
609 |
||
610 |
foreach my $master_opt_file ($global_master_opt_file, $test_master_opt_file)
|
|
611 |
{
|
|
612 |
# Add master opts
|
|
613 |
if ( -f $master_opt_file )
|
|
614 |
{
|
|
615 |
||
616 |
my $master_opt= dtr_get_opts_from_file($master_opt_file);
|
|
617 |
||
618 |
foreach my $opt ( @$master_opt )
|
|
619 |
{
|
|
620 |
my $value;
|
|
621 |
||
622 |
# The opt file is used both to send special options to the drizzled
|
|
623 |
# as well as pass special test case specific options to this
|
|
624 |
# script
|
|
625 |
||
626 |
$value= dtr_match_prefix($opt, "--timezone=");
|
|
627 |
if ( defined $value )
|
|
628 |
{
|
|
629 |
$tinfo->{'timezone'}= $value;
|
|
630 |
next;
|
|
631 |
}
|
|
632 |
||
633 |
$value= dtr_match_prefix($opt, "--slave-num=");
|
|
634 |
if ( defined $value )
|
|
635 |
{
|
|
636 |
$tinfo->{'slave_num'}= $value;
|
|
637 |
next;
|
|
638 |
}
|
|
639 |
||
640 |
$value= dtr_match_prefix($opt, "--result-file=");
|
|
641 |
if ( defined $value )
|
|
642 |
{
|
|
643 |
# Specifies the file drizzletest should compare
|
|
644 |
# output against
|
|
645 |
if ( -f "r/$::opt_engine/$value.result")
|
|
646 |
{
|
|
647 |
$tinfo->{'result_file'}= "r/$::opt_engine/$value.result";
|
|
648 |
}
|
|
649 |
else
|
|
650 |
{
|
|
651 |
$tinfo->{'result_file'}= "r/$value.result";
|
|
652 |
}
|
|
653 |
||
654 |
next;
|
|
655 |
}
|
|
656 |
||
657 |
# If we set default time zone, remove the one we have
|
|
658 |
$value= dtr_match_prefix($opt, "--default-time-zone=");
|
|
659 |
if ( defined $value )
|
|
660 |
{
|
|
661 |
# Set timezone for this test case to something different
|
|
662 |
$tinfo->{'timezone'}= "GMT-8";
|
|
663 |
# Fallthrough, add the --default-time-zone option
|
|
664 |
}
|
|
665 |
||
666 |
# The --restart option forces a restart even if no special
|
|
667 |
# option is set. If the options are the same as next testcase
|
|
668 |
# there is no need to restart after the testcase
|
|
669 |
# has completed
|
|
670 |
if ( $opt eq "--force-restart" )
|
|
671 |
{
|
|
672 |
$tinfo->{'force_restart'}= 1;
|
|
673 |
next;
|
|
674 |
}
|
|
675 |
||
676 |
# Ok, this was a real option, add it
|
|
677 |
push(@{$tinfo->{'master_opt'}}, $opt);
|
|
678 |
}
|
|
679 |
}
|
|
680 |
}
|
|
681 |
||
682 |
# Add slave opts
|
|
683 |
if ( -f $slave_opt_file )
|
|
684 |
{
|
|
685 |
my $slave_opt= dtr_get_opts_from_file($slave_opt_file);
|
|
686 |
||
687 |
foreach my $opt ( @$slave_opt )
|
|
688 |
{
|
|
689 |
# If we set default time zone, remove the one we have
|
|
690 |
my $value= dtr_match_prefix($opt, "--default-time-zone=");
|
|
691 |
$tinfo->{'slave_opt'}= [] if defined $value;
|
|
692 |
}
|
|
693 |
push(@{$tinfo->{'slave_opt'}}, @$slave_opt);
|
|
694 |
}
|
|
695 |
||
696 |
if ( -f $slave_mi_file )
|
|
697 |
{
|
|
698 |
$tinfo->{'slave_mi'}= dtr_get_opts_from_file($slave_mi_file);
|
|
699 |
}
|
|
700 |
||
701 |
if ( -f $master_sh )
|
|
702 |
{
|
|
703 |
if ( $::glob_win32_perl )
|
|
704 |
{
|
|
705 |
$tinfo->{'skip'}= 1;
|
|
706 |
$tinfo->{'comment'}= "No tests with sh scripts on Windows";
|
|
707 |
return;
|
|
708 |
}
|
|
709 |
else
|
|
710 |
{
|
|
711 |
$tinfo->{'master_sh'}= $master_sh;
|
|
712 |
}
|
|
713 |
}
|
|
714 |
||
715 |
if ( -f $slave_sh )
|
|
716 |
{
|
|
717 |
if ( $::glob_win32_perl )
|
|
718 |
{
|
|
719 |
$tinfo->{'skip'}= 1;
|
|
720 |
$tinfo->{'comment'}= "No tests with sh scripts on Windows";
|
|
721 |
return;
|
|
722 |
}
|
|
723 |
else
|
|
724 |
{
|
|
725 |
$tinfo->{'slave_sh'}= $slave_sh;
|
|
726 |
}
|
|
727 |
}
|
|
728 |
||
729 |
if ( -f $im_opt_file )
|
|
730 |
{
|
|
731 |
$tinfo->{'im_opts'} = dtr_get_opts_from_file($im_opt_file);
|
|
732 |
}
|
|
733 |
else
|
|
734 |
{
|
|
735 |
$tinfo->{'im_opts'} = [];
|
|
736 |
}
|
|
737 |
||
738 |
# FIXME why this late?
|
|
739 |
my $marked_as_disabled= 0;
|
|
740 |
if ( $disabled->{$tname} )
|
|
741 |
{
|
|
742 |
$marked_as_disabled= 1;
|
|
743 |
$tinfo->{'comment'}= $disabled->{$tname};
|
|
744 |
}
|
|
745 |
||
746 |
if ( -f $disabled_file )
|
|
747 |
{
|
|
748 |
$marked_as_disabled= 1;
|
|
749 |
$tinfo->{'comment'}= dtr_fromfile($disabled_file);
|
|
750 |
}
|
|
751 |
||
752 |
# If test was marked as disabled, either opt_enable_disabled is off and then
|
|
753 |
# we skip this test, or it is on and then we run this test but warn
|
|
754 |
||
755 |
if ( $marked_as_disabled )
|
|
756 |
{
|
|
757 |
if ( $::opt_enable_disabled )
|
|
758 |
{
|
|
759 |
$tinfo->{'dont_skip_though_disabled'}= 1;
|
|
760 |
}
|
|
761 |
else
|
|
762 |
{
|
|
763 |
$tinfo->{'skip'}= 1;
|
|
764 |
$tinfo->{'disable'}= 1; # Sub type of 'skip'
|
|
765 |
return;
|
|
766 |
}
|
|
767 |
}
|
|
768 |
||
769 |
if ( $component_id eq 'im' )
|
|
770 |
{
|
|
771 |
if ( $::glob_use_embedded_server )
|
|
772 |
{
|
|
773 |
$tinfo->{'skip'}= 1;
|
|
774 |
$tinfo->{'comment'}= "No IM with embedded server";
|
|
775 |
return;
|
|
776 |
}
|
|
777 |
elsif ( $::opt_ps_protocol )
|
|
778 |
{
|
|
779 |
$tinfo->{'skip'}= 1;
|
|
780 |
$tinfo->{'comment'}= "No IM with --ps-protocol";
|
|
781 |
return;
|
|
782 |
}
|
|
783 |
elsif ( $::opt_skip_im )
|
|
784 |
{
|
|
785 |
$tinfo->{'skip'}= 1;
|
|
786 |
$tinfo->{'comment'}= "No IM tests(--skip-im)";
|
|
787 |
return;
|
|
788 |
}
|
|
789 |
}
|
|
790 |
else
|
|
791 |
{
|
|
792 |
dtr_options_from_test_file($tinfo,"$testdir/${tname}.test");
|
|
793 |
||
794 |
if ( defined $::used_default_engine )
|
|
795 |
{
|
|
796 |
# Different default engine is used
|
|
797 |
# tag test to require that engine
|
|
798 |
$tinfo->{'ndb_test'}= 1
|
|
799 |
if ( $::used_default_engine =~ /^ndb/i );
|
|
800 |
||
801 |
$tinfo->{'innodb_test'}= 1
|
|
802 |
if ( $::used_default_engine =~ /^innodb/i );
|
|
803 |
}
|
|
804 |
||
805 |
if ( $tinfo->{'ndb_extra'} and ! $::opt_ndb_extra_test )
|
|
806 |
{
|
|
807 |
$tinfo->{'skip'}= 1;
|
|
808 |
$tinfo->{'comment'}= "Test need 'ndb_extra' option";
|
|
809 |
return;
|
|
810 |
}
|
|
811 |
||
812 |
if ( $tinfo->{'require_manager'} )
|
|
813 |
{
|
|
814 |
$tinfo->{'skip'}= 1;
|
|
815 |
$tinfo->{'comment'}= "Test need the _old_ manager(to be removed)";
|
|
816 |
return;
|
|
817 |
}
|
|
818 |
||
819 |
if ( $tinfo->{'need_debug'} && ! $::debug_compiled_binaries )
|
|
820 |
{
|
|
821 |
$tinfo->{'skip'}= 1;
|
|
822 |
$tinfo->{'comment'}= "Test need debug binaries";
|
|
823 |
return;
|
|
824 |
}
|
|
825 |
}
|
|
826 |
}
|
|
827 |
||
828 |
||
829 |
# List of tags in the .test files that if found should set
|
|
830 |
# the specified value in "tinfo"
|
|
831 |
our @tags=
|
|
832 |
(
|
|
833 |
["include/have_innodb.inc", "innodb_test", 1],
|
|
834 |
["include/have_binlog_format_row.inc", "sup_binlog_formats", ["row"]],
|
|
835 |
["include/have_log_bin.inc", "need_binlog", 1],
|
|
836 |
["include/have_binlog_format_statement.inc",
|
|
837 |
"sup_binlog_formats", ["statement"]],
|
|
838 |
["include/have_binlog_format_mixed.inc", "sup_binlog_formats", ["mixed"]],
|
|
839 |
["include/have_binlog_format_mixed_or_row.inc",
|
|
840 |
"sup_binlog_formats", ["mixed","row"]],
|
|
841 |
["include/have_binlog_format_mixed_or_statement.inc",
|
|
842 |
"sup_binlog_formats", ["mixed","statement"]],
|
|
843 |
["include/have_binlog_format_row_or_statement.inc",
|
|
844 |
"sup_binlog_formats", ["row","statement"]],
|
|
845 |
["include/have_debug.inc", "need_debug", 1],
|
|
846 |
["require_manager", "require_manager", 1],
|
|
847 |
);
|
|
848 |
||
849 |
sub dtr_options_from_test_file($$) {
|
|
850 |
my $tinfo= shift;
|
|
851 |
my $file= shift;
|
|
852 |
#dtr_verbose("$file");
|
|
853 |
my $F= IO::File->new($file) or dtr_error("can't open file \"$file\": $!"); |
|
854 |
||
855 |
while ( my $line= <$F> ) |
|
856 |
{
|
|
857 |
||
858 |
# Skip line if it start's with # |
|
859 |
next if ( $line =~ /^#/ ); |
|
860 |
||
861 |
# Match this line against tag in "tags" array |
|
862 |
foreach my $tag (@tags) |
|
863 |
{
|
|
864 |
if ( index($line, $tag->[0]) >= 0 ) |
|
865 |
{
|
|
866 |
# Tag matched, assign value to "tinfo" |
|
867 |
$tinfo->{"$tag->[1]"}= $tag->[2]; |
|
868 |
}
|
|
869 |
}
|
|
870 |
||
871 |
# If test sources another file, open it as well |
|
872 |
if ( $line =~ /^\-\-([[:space:]]*)source(.*)$/ or |
|
873 |
$line =~ /^([[:space:]]*)source(.*);$/ ) |
|
874 |
{
|
|
875 |
my $value= $2; |
|
876 |
$value =~ s/^\s+//; # Remove leading space |
|
877 |
$value =~ s/[[:space:]]+$//; # Remove ending space |
|
878 |
||
879 |
my $sourced_file= "$::glob_drizzle_test_dir/$value"; |
|
880 |
if ( -f $sourced_file ) |
|
881 |
{
|
|
882 |
# Only source the file if it exists, we may get |
|
883 |
# false positives in the regexes above if someone |
|
884 |
# writes "source nnnn;" in a test case(such as drizzletest.test) |
|
885 |
dtr_options_from_test_file($tinfo, $sourced_file); |
|
886 |
}
|
|
887 |
}
|
|
888 |
}
|
|
889 |
}
|
|
890 |
||
891 |
||
892 |
sub print_testcases { |
|
893 |
my (@cases)= @_; |
|
894 |
||
895 |
print "=" x 60, "\n"; |
|
896 |
foreach my $test (@cases){ |
|
897 |
print "[", $test->{name}, "]", "\n"; |
|
898 |
while ((my ($key, $value)) = each(%$test)) { |
|
899 |
print " ", $key, "="; |
|
900 |
if (ref $value eq "ARRAY") { |
|
901 |
print join(", ", @$value); |
|
902 |
} else { |
|
903 |
print $value; |
|
904 |
}
|
|
905 |
print "\n"; |
|
906 |
}
|
|
907 |
print "\n"; |
|
908 |
}
|
|
909 |
print "=" x 60, "\n"; |
|
910 |
}
|
|
911 |
||
912 |
||
913 |
1; |