2005-02-03 21:50:56 +01:00
|
|
|
# -*- cperl -*-
|
2006-12-31 01:02:27 +01:00
|
|
|
# Copyright (C) 2005-2006 MySQL AB
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; version 2 of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2005-02-03 21:50:56 +01:00
|
|
|
|
|
|
|
# This is a library file used by the Perl version of mysql-test-run,
|
|
|
|
# and is part of the translation of the Bourne shell script with the
|
|
|
|
# same name.
|
|
|
|
|
2005-06-20 21:37:39 +02:00
|
|
|
use File::Basename;
|
2006-10-04 12:47:32 +02:00
|
|
|
use IO::File();
|
2005-02-03 21:50:56 +01:00
|
|
|
use strict;
|
|
|
|
|
|
|
|
sub collect_test_cases ($);
|
2007-06-27 14:28:02 +02:00
|
|
|
sub collect_one_suite ($$);
|
|
|
|
sub collect_one_test_case ($$$$$$$$$);
|
2006-10-04 12:47:32 +02:00
|
|
|
|
|
|
|
sub mtr_options_from_test_file($$);
|
2005-02-03 21:50:56 +01:00
|
|
|
|
2007-10-05 19:23:44 +02:00
|
|
|
my $do_test;
|
|
|
|
my $skip_test;
|
|
|
|
|
|
|
|
sub init_pattern {
|
|
|
|
my ($from, $what)= @_;
|
|
|
|
if ( $from =~ /[a-z0-9]/ ) {
|
|
|
|
# Does not contain any regex, make the pattern match
|
|
|
|
# beginning of string
|
|
|
|
$from= "^$from";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# Check that pattern is a valid regex
|
|
|
|
eval { "" =~/$from/; 1 } or
|
|
|
|
mtr_error("Invalid regex '$from' passed to $what\nPerl says: $@");
|
|
|
|
}
|
|
|
|
return $from;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-02-03 21:50:56 +01:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Collect information about test cases we are to run
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
sub collect_test_cases ($) {
|
2007-10-05 19:23:44 +02:00
|
|
|
$do_test= init_pattern($::opt_do_test, "--do-test");
|
|
|
|
$skip_test= init_pattern($::opt_skip_test, "--skip-test");
|
|
|
|
|
2007-06-27 14:28:02 +02:00
|
|
|
my $suites= shift; # Semicolon separated list of test suites
|
|
|
|
my $cases = []; # Array of hash
|
|
|
|
|
|
|
|
foreach my $suite (split(",", $suites))
|
|
|
|
{
|
|
|
|
collect_one_suite($suite, $cases);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( @::opt_cases )
|
|
|
|
{
|
|
|
|
# Check that the tests specified was found
|
|
|
|
# in at least one suite
|
2007-10-05 14:42:38 +02:00
|
|
|
foreach my $test_name_spec ( @::opt_cases )
|
2007-06-27 14:28:02 +02:00
|
|
|
{
|
|
|
|
my $found= 0;
|
2007-10-05 14:42:38 +02:00
|
|
|
my ($sname, $tname, $extension)= split_testname($test_name_spec);
|
2007-06-27 14:28:02 +02:00
|
|
|
foreach my $test ( @$cases )
|
|
|
|
{
|
2007-10-05 14:42:38 +02:00
|
|
|
# test->{name} is always in suite.name format
|
|
|
|
if ( $test->{name} =~ /.*\.$tname/ )
|
2007-06-27 14:28:02 +02:00
|
|
|
{
|
|
|
|
$found= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( not $found )
|
|
|
|
{
|
|
|
|
mtr_error("Could not find $tname in any suite");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $::opt_reorder )
|
|
|
|
{
|
|
|
|
# Reorder the test cases in an order that will make them faster to run
|
|
|
|
my %sort_criteria;
|
|
|
|
|
|
|
|
# Make a mapping of test name to a string that represents how that test
|
|
|
|
# should be sorted among the other tests. Put the most important criterion
|
|
|
|
# first, then a sub-criterion, then sub-sub-criterion, et c.
|
|
|
|
foreach my $tinfo (@$cases)
|
|
|
|
{
|
|
|
|
my @criteria = ();
|
|
|
|
|
|
|
|
# Look for tests that muct be in run in a defined order
|
|
|
|
# that is defined by test having the same name except for
|
|
|
|
# the ending digit
|
|
|
|
|
|
|
|
# Put variables into hash
|
|
|
|
my $test_name= $tinfo->{'name'};
|
|
|
|
my $depend_on_test_name;
|
|
|
|
if ( $test_name =~ /^([\D]+)([0-9]{1})$/ )
|
|
|
|
{
|
|
|
|
my $base_name= $1;
|
|
|
|
my $idx= $2;
|
|
|
|
mtr_verbose("$test_name => $base_name idx=$idx");
|
|
|
|
if ( $idx > 1 )
|
|
|
|
{
|
|
|
|
$idx-= 1;
|
|
|
|
$base_name= "$base_name$idx";
|
|
|
|
mtr_verbose("New basename $base_name");
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $tinfo2 (@$cases)
|
|
|
|
{
|
|
|
|
if ( $tinfo2->{'name'} eq $base_name )
|
|
|
|
{
|
|
|
|
mtr_verbose("found dependent test $tinfo2->{'name'}");
|
|
|
|
$depend_on_test_name=$base_name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( defined $depend_on_test_name )
|
|
|
|
{
|
|
|
|
mtr_verbose("Giving $test_name same critera as $depend_on_test_name");
|
|
|
|
$sort_criteria{$test_name} = $sort_criteria{$depend_on_test_name};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#
|
|
|
|
# Append the criteria for sorting, in order of importance.
|
|
|
|
#
|
|
|
|
push(@criteria, "ndb=" . ($tinfo->{'ndb_test'} ? "1" : "0"));
|
|
|
|
# Group test with equal options together.
|
|
|
|
# Ending with "~" makes empty sort later than filled
|
|
|
|
push(@criteria, join("!", sort @{$tinfo->{'master_opt'}}) . "~");
|
|
|
|
|
|
|
|
$sort_criteria{$test_name} = join(" ", @criteria);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@$cases = sort {
|
|
|
|
$sort_criteria{$a->{'name'}} . $a->{'name'} cmp
|
|
|
|
$sort_criteria{$b->{'name'}} . $b->{'name'}; } @$cases;
|
|
|
|
|
|
|
|
if ( $::opt_script_debug )
|
|
|
|
{
|
|
|
|
# For debugging the sort-order
|
|
|
|
foreach my $tinfo (@$cases)
|
|
|
|
{
|
|
|
|
print("$sort_criteria{$tinfo->{'name'}} -> \t$tinfo->{'name'}\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $cases;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-10-05 14:42:38 +02:00
|
|
|
# Valid extensions and their corresonding component id
|
|
|
|
my %exts = ( 'test' => 'mysqld',
|
|
|
|
'imtest' => 'im'
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
# Returns (suitename, testname, extension)
|
|
|
|
sub split_testname {
|
|
|
|
my ($test_name)= @_;
|
|
|
|
|
|
|
|
# Get rid of directory part and split name on .'s
|
|
|
|
my @parts= split(/\./, basename($test_name));
|
|
|
|
|
|
|
|
if (@parts == 1){
|
|
|
|
# Only testname given, ex: alias
|
|
|
|
return (undef , $parts[0], undef);
|
|
|
|
} elsif (@parts == 2) {
|
|
|
|
# Either testname.test or suite.testname given
|
|
|
|
# Ex. main.alias or alias.test
|
|
|
|
|
|
|
|
if (defined $exts{$parts[1]})
|
|
|
|
{
|
|
|
|
return (undef , $parts[0], $parts[1]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ($parts[0], $parts[1], undef);
|
|
|
|
}
|
|
|
|
|
|
|
|
} elsif (@parts == 3) {
|
|
|
|
# Fully specified suitename.testname.test
|
|
|
|
# ex main.alias.test
|
|
|
|
return ( $parts[0], $parts[1], $parts[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
mtr_error("Illegal format of test name: $test_name");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-27 14:28:02 +02:00
|
|
|
sub collect_one_suite($$)
|
|
|
|
{
|
|
|
|
my $suite= shift; # Test suite name
|
|
|
|
my $cases= shift; # List of test cases
|
|
|
|
|
|
|
|
mtr_verbose("Collecting: $suite");
|
2005-02-03 21:50:56 +01:00
|
|
|
|
2007-09-11 15:00:52 +02:00
|
|
|
my $suitedir= "$::glob_mysql_test_dir"; # Default
|
|
|
|
if ( $suite ne "main" )
|
2005-02-03 21:50:56 +01:00
|
|
|
{
|
2007-09-11 15:00:52 +02:00
|
|
|
$suitedir= mtr_path_exists("$suitedir/suite/$suite",
|
|
|
|
"$suitedir/$suite");
|
|
|
|
mtr_verbose("suitedir: $suitedir");
|
2005-02-03 21:50:56 +01:00
|
|
|
}
|
|
|
|
|
2007-09-11 15:00:52 +02:00
|
|
|
my $testdir= "$suitedir/t";
|
|
|
|
my $resdir= "$suitedir/r";
|
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
# ----------------------------------------------------------------------
|
2007-06-27 14:28:02 +02:00
|
|
|
# Build a hash of disabled testcases for this suite
|
2006-10-04 12:47:32 +02:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
my %disabled;
|
|
|
|
if ( open(DISABLED, "$testdir/disabled.def" ) )
|
|
|
|
{
|
|
|
|
while ( <DISABLED> )
|
|
|
|
{
|
|
|
|
chomp;
|
|
|
|
if ( /^\s*(\S+)\s*:\s*(.*?)\s*$/ )
|
|
|
|
{
|
|
|
|
$disabled{$1}= $2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close DISABLED;
|
|
|
|
}
|
|
|
|
|
2007-06-27 14:28:02 +02:00
|
|
|
# Read suite.opt file
|
|
|
|
my $suite_opt_file= "$testdir/suite.opt";
|
|
|
|
my $suite_opts= [];
|
|
|
|
if ( -f $suite_opt_file )
|
|
|
|
{
|
|
|
|
$suite_opts= mtr_get_opts_from_file($suite_opt_file);
|
|
|
|
}
|
|
|
|
|
2005-02-03 21:50:56 +01:00
|
|
|
if ( @::opt_cases )
|
|
|
|
{
|
2007-10-05 14:42:38 +02:00
|
|
|
# Collect in specified order
|
|
|
|
foreach my $test_name_spec ( @::opt_cases )
|
2006-10-18 13:24:06 +02:00
|
|
|
{
|
2007-10-05 14:42:38 +02:00
|
|
|
my ($sname, $tname, $extension)= split_testname($test_name_spec);
|
2006-10-04 12:47:32 +02:00
|
|
|
|
2007-10-05 14:42:38 +02:00
|
|
|
# The test name parts have now been defined
|
|
|
|
#print " suite_name: $sname\n";
|
|
|
|
#print " tname: $tname\n";
|
|
|
|
#print " extension: $extension\n";
|
2006-10-04 12:47:32 +02:00
|
|
|
|
2007-10-05 14:42:38 +02:00
|
|
|
# Check cirrect suite if suitename is defined
|
|
|
|
next if (defined $sname and $suite ne $sname);
|
2006-10-04 12:47:32 +02:00
|
|
|
|
2007-10-05 14:42:38 +02:00
|
|
|
my $component_id;
|
|
|
|
if ( defined $extension )
|
2006-10-04 12:47:32 +02:00
|
|
|
{
|
2007-10-05 14:42:38 +02:00
|
|
|
my $full_name= "$testdir/$tname.$extension";
|
|
|
|
# Extension was specified, check if the test exists
|
|
|
|
if ( ! -f $full_name)
|
2006-10-04 12:47:32 +02:00
|
|
|
{
|
2007-10-05 14:42:38 +02:00
|
|
|
# This is only an error if suite was specified, otherwise it
|
|
|
|
# could exist in another suite
|
|
|
|
mtr_error("Test '$full_name' was not found in suite '$sname'")
|
|
|
|
if $sname;
|
|
|
|
|
|
|
|
next;
|
2006-10-04 12:47:32 +02:00
|
|
|
}
|
2007-10-05 14:42:38 +02:00
|
|
|
$component_id= $exts{$extension};
|
2006-10-04 12:47:32 +02:00
|
|
|
}
|
|
|
|
else
|
2005-02-03 21:50:56 +01:00
|
|
|
{
|
2007-10-05 14:42:38 +02:00
|
|
|
# No extension was specified
|
|
|
|
my ($ext, $component);
|
|
|
|
while (($ext, $component)= each %exts) {
|
|
|
|
my $full_name= "$testdir/$tname.$ext";
|
2006-10-04 12:47:32 +02:00
|
|
|
|
2007-10-05 14:42:38 +02:00
|
|
|
if ( ! -f $full_name ) {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
$component_id= $component;
|
|
|
|
$extension= $ext;
|
|
|
|
}
|
|
|
|
# Test not found here, could exist in other suite
|
|
|
|
next unless $component_id;
|
2005-02-03 21:50:56 +01:00
|
|
|
}
|
2006-10-04 12:47:32 +02:00
|
|
|
|
2007-06-27 14:28:02 +02:00
|
|
|
collect_one_test_case($testdir,$resdir,$suite,$tname,
|
2007-10-05 14:42:38 +02:00
|
|
|
"$tname.$extension",$cases,\%disabled,
|
|
|
|
$component_id,$suite_opts);
|
2005-02-03 21:50:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-06-27 14:28:02 +02:00
|
|
|
opendir(TESTDIR, $testdir) or mtr_error("Can't open dir \"$testdir\": $!");
|
|
|
|
|
2006-10-18 13:24:06 +02:00
|
|
|
foreach my $elem ( sort readdir(TESTDIR) )
|
|
|
|
{
|
2006-10-04 12:47:32 +02:00
|
|
|
my $component_id= undef;
|
|
|
|
my $tname= undef;
|
|
|
|
|
|
|
|
if ($tname= mtr_match_extension($elem, 'test'))
|
2005-07-07 18:41:22 +02:00
|
|
|
{
|
2006-10-04 12:47:32 +02:00
|
|
|
$component_id = 'mysqld';
|
2005-07-07 18:41:22 +02:00
|
|
|
}
|
2006-10-04 12:47:32 +02:00
|
|
|
elsif ($tname= mtr_match_extension($elem, 'imtest'))
|
|
|
|
{
|
|
|
|
$component_id = 'im';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
next;
|
|
|
|
}
|
2006-10-07 19:11:37 +02:00
|
|
|
|
2006-10-18 13:24:06 +02:00
|
|
|
# Skip tests that does not match the --do-test= filter
|
2007-10-05 19:29:55 +02:00
|
|
|
next if ($do_test and not $tname =~ /$do_test/o);
|
2005-02-03 21:50:56 +01:00
|
|
|
|
2007-06-27 14:28:02 +02:00
|
|
|
collect_one_test_case($testdir,$resdir,$suite,$tname,
|
|
|
|
$elem,$cases,\%disabled,$component_id,
|
|
|
|
$suite_opts);
|
2005-02-03 21:50:56 +01:00
|
|
|
}
|
|
|
|
closedir TESTDIR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $cases;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Collect information about a single test case
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
|
2007-06-27 14:28:02 +02:00
|
|
|
sub collect_one_test_case($$$$$$$$$) {
|
2005-02-03 21:50:56 +01:00
|
|
|
my $testdir= shift;
|
|
|
|
my $resdir= shift;
|
2007-06-27 14:28:02 +02:00
|
|
|
my $suite= shift;
|
2005-02-03 21:50:56 +01:00
|
|
|
my $tname= shift;
|
|
|
|
my $elem= shift;
|
|
|
|
my $cases= shift;
|
2005-08-17 01:18:13 +02:00
|
|
|
my $disabled=shift;
|
2006-10-04 12:47:32 +02:00
|
|
|
my $component_id= shift;
|
2007-06-27 14:28:02 +02:00
|
|
|
my $suite_opts= shift;
|
2005-02-03 21:50:56 +01:00
|
|
|
|
|
|
|
my $path= "$testdir/$elem";
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# Skip some tests silently
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
|
|
|
if ( $::opt_start_from and $tname lt $::opt_start_from )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
my $tinfo= {};
|
2007-09-11 15:00:52 +02:00
|
|
|
$tinfo->{'name'}= basename($suite) . ".$tname";
|
2005-02-03 21:50:56 +01:00
|
|
|
$tinfo->{'result_file'}= "$resdir/$tname.result";
|
2006-10-04 12:47:32 +02:00
|
|
|
$tinfo->{'component_id'} = $component_id;
|
2005-02-03 21:50:56 +01:00
|
|
|
push(@$cases, $tinfo);
|
|
|
|
|
2006-10-19 20:29:33 +02:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# Skip some tests but include in list, just mark them to skip
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
2007-10-05 19:23:44 +02:00
|
|
|
if ( $skip_test and $tname =~ /$skip_test/o )
|
2005-02-03 21:50:56 +01:00
|
|
|
{
|
|
|
|
$tinfo->{'skip'}= 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# Collect information about test case
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
|
|
|
$tinfo->{'path'}= $path;
|
|
|
|
$tinfo->{'timezone'}= "GMT-3"; # for UNIX_TIMESTAMP tests to work
|
|
|
|
|
2006-10-06 16:26:17 +02:00
|
|
|
$tinfo->{'slave_num'}= 0; # Default, no slave
|
2006-12-20 23:44:53 +01:00
|
|
|
$tinfo->{'master_num'}= 1; # Default, 1 master
|
2005-02-03 21:50:56 +01:00
|
|
|
if ( defined mtr_match_prefix($tname,"rpl") )
|
|
|
|
{
|
|
|
|
if ( $::opt_skip_rpl )
|
|
|
|
{
|
|
|
|
$tinfo->{'skip'}= 1;
|
2006-10-04 12:47:32 +02:00
|
|
|
$tinfo->{'comment'}= "No replication tests(--skip-rpl)";
|
2005-02-03 21:50:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-06 16:26:17 +02:00
|
|
|
$tinfo->{'slave_num'}= 1; # Default for rpl* tests, use one slave
|
2005-02-03 21:50:56 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-07-07 18:41:22 +02:00
|
|
|
if ( defined mtr_match_prefix($tname,"federated") )
|
|
|
|
{
|
2006-10-04 12:47:32 +02:00
|
|
|
# Default, federated uses the first slave as it's federated database
|
|
|
|
$tinfo->{'slave_num'}= 1;
|
2005-07-07 18:41:22 +02:00
|
|
|
}
|
|
|
|
|
2005-02-03 21:50:56 +01:00
|
|
|
my $master_opt_file= "$testdir/$tname-master.opt";
|
|
|
|
my $slave_opt_file= "$testdir/$tname-slave.opt";
|
|
|
|
my $slave_mi_file= "$testdir/$tname.slave-mi";
|
|
|
|
my $master_sh= "$testdir/$tname-master.sh";
|
|
|
|
my $slave_sh= "$testdir/$tname-slave.sh";
|
2005-08-17 01:18:13 +02:00
|
|
|
my $disabled_file= "$testdir/$tname.disabled";
|
2006-10-04 12:47:32 +02:00
|
|
|
my $im_opt_file= "$testdir/$tname-im.opt";
|
2005-02-03 21:50:56 +01:00
|
|
|
|
2006-03-08 19:15:56 +01:00
|
|
|
$tinfo->{'master_opt'}= [];
|
|
|
|
$tinfo->{'slave_opt'}= [];
|
2005-02-03 21:50:56 +01:00
|
|
|
$tinfo->{'slave_mi'}= [];
|
|
|
|
|
2007-06-27 14:28:02 +02:00
|
|
|
# Add suite opts
|
|
|
|
foreach my $opt ( @$suite_opts )
|
|
|
|
{
|
|
|
|
mtr_verbose($opt);
|
|
|
|
push(@{$tinfo->{'master_opt'}}, $opt);
|
|
|
|
push(@{$tinfo->{'slave_opt'}}, $opt);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Add master opts
|
2005-02-03 21:50:56 +01:00
|
|
|
if ( -f $master_opt_file )
|
|
|
|
{
|
|
|
|
|
2006-10-11 14:50:19 +02:00
|
|
|
my $master_opt= mtr_get_opts_from_file($master_opt_file);
|
2005-02-03 21:50:56 +01:00
|
|
|
|
2006-10-11 14:50:19 +02:00
|
|
|
foreach my $opt ( @$master_opt )
|
|
|
|
{
|
|
|
|
my $value;
|
2005-02-03 21:50:56 +01:00
|
|
|
|
2006-10-11 14:50:19 +02:00
|
|
|
# The opt file is used both to send special options to the mysqld
|
|
|
|
# as well as pass special test case specific options to this
|
|
|
|
# script
|
2005-02-03 21:50:56 +01:00
|
|
|
|
2006-10-11 14:50:19 +02:00
|
|
|
$value= mtr_match_prefix($opt, "--timezone=");
|
|
|
|
if ( defined $value )
|
|
|
|
{
|
|
|
|
$tinfo->{'timezone'}= $value;
|
|
|
|
next;
|
|
|
|
}
|
2005-06-20 21:37:39 +02:00
|
|
|
|
2007-04-18 13:50:54 +02:00
|
|
|
$value= mtr_match_prefix($opt, "--slave-num=");
|
|
|
|
if ( defined $value )
|
|
|
|
{
|
|
|
|
$tinfo->{'slave_num'}= $value;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2006-10-11 14:50:19 +02:00
|
|
|
$value= mtr_match_prefix($opt, "--result-file=");
|
|
|
|
if ( defined $value )
|
|
|
|
{
|
|
|
|
# Specifies the file mysqltest should compare
|
|
|
|
# output against
|
|
|
|
$tinfo->{'result_file'}= "r/$value.result";
|
|
|
|
next;
|
|
|
|
}
|
2005-06-20 21:37:39 +02:00
|
|
|
|
2006-10-11 14:50:19 +02:00
|
|
|
# If we set default time zone, remove the one we have
|
|
|
|
$value= mtr_match_prefix($opt, "--default-time-zone=");
|
|
|
|
if ( defined $value )
|
|
|
|
{
|
2006-10-19 20:29:33 +02:00
|
|
|
# Set timezone for this test case to something different
|
|
|
|
$tinfo->{'timezone'}= "GMT-8";
|
|
|
|
# Fallthrough, add the --default-time-zone option
|
2006-10-11 14:50:19 +02:00
|
|
|
}
|
2005-06-20 21:37:39 +02:00
|
|
|
|
2006-10-11 14:50:19 +02:00
|
|
|
# The --restart option forces a restart even if no special
|
|
|
|
# option is set. If the options are the same as next testcase
|
|
|
|
# there is no need to restart after the testcase
|
|
|
|
# has completed
|
|
|
|
if ( $opt eq "--force-restart" )
|
|
|
|
{
|
|
|
|
$tinfo->{'force_restart'}= 1;
|
|
|
|
next;
|
2005-02-03 21:50:56 +01:00
|
|
|
}
|
2005-06-20 21:37:39 +02:00
|
|
|
|
2006-10-11 14:50:19 +02:00
|
|
|
# Ok, this was a real option, add it
|
|
|
|
push(@{$tinfo->{'master_opt'}}, $opt);
|
2005-02-03 21:50:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-27 14:28:02 +02:00
|
|
|
# Add slave opts
|
2005-02-03 21:50:56 +01:00
|
|
|
if ( -f $slave_opt_file )
|
|
|
|
{
|
2005-06-20 21:37:39 +02:00
|
|
|
my $slave_opt= mtr_get_opts_from_file($slave_opt_file);
|
|
|
|
|
|
|
|
foreach my $opt ( @$slave_opt )
|
|
|
|
{
|
|
|
|
# If we set default time zone, remove the one we have
|
|
|
|
my $value= mtr_match_prefix($opt, "--default-time-zone=");
|
|
|
|
$tinfo->{'slave_opt'}= [] if defined $value;
|
|
|
|
}
|
|
|
|
push(@{$tinfo->{'slave_opt'}}, @$slave_opt);
|
2005-02-03 21:50:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( -f $slave_mi_file )
|
|
|
|
{
|
|
|
|
$tinfo->{'slave_mi'}= mtr_get_opts_from_file($slave_mi_file);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( -f $master_sh )
|
|
|
|
{
|
|
|
|
if ( $::glob_win32_perl )
|
|
|
|
{
|
|
|
|
$tinfo->{'skip'}= 1;
|
2006-10-04 12:47:32 +02:00
|
|
|
$tinfo->{'comment'}= "No tests with sh scripts on Windows";
|
|
|
|
return;
|
2005-02-03 21:50:56 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$tinfo->{'master_sh'}= $master_sh;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( -f $slave_sh )
|
|
|
|
{
|
|
|
|
if ( $::glob_win32_perl )
|
|
|
|
{
|
|
|
|
$tinfo->{'skip'}= 1;
|
2006-10-04 12:47:32 +02:00
|
|
|
$tinfo->{'comment'}= "No tests with sh scripts on Windows";
|
|
|
|
return;
|
2005-02-03 21:50:56 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$tinfo->{'slave_sh'}= $slave_sh;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
if ( -f $im_opt_file )
|
|
|
|
{
|
|
|
|
$tinfo->{'im_opts'} = mtr_get_opts_from_file($im_opt_file);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$tinfo->{'im_opts'} = [];
|
|
|
|
}
|
|
|
|
|
2005-07-07 18:41:22 +02:00
|
|
|
# FIXME why this late?
|
2006-10-04 12:47:32 +02:00
|
|
|
my $marked_as_disabled= 0;
|
2005-08-17 01:18:13 +02:00
|
|
|
if ( $disabled->{$tname} )
|
2005-07-07 18:41:22 +02:00
|
|
|
{
|
2006-10-04 12:47:32 +02:00
|
|
|
$marked_as_disabled= 1;
|
|
|
|
$tinfo->{'comment'}= $disabled->{$tname};
|
2005-07-07 18:41:22 +02:00
|
|
|
}
|
|
|
|
|
2005-08-17 01:18:13 +02:00
|
|
|
if ( -f $disabled_file )
|
2005-02-03 21:50:56 +01:00
|
|
|
{
|
2006-10-04 12:47:32 +02:00
|
|
|
$marked_as_disabled= 1;
|
2005-08-17 01:18:13 +02:00
|
|
|
$tinfo->{'comment'}= mtr_fromfile($disabled_file);
|
2005-02-03 21:50:56 +01:00
|
|
|
}
|
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
# If test was marked as disabled, either opt_enable_disabled is off and then
|
|
|
|
# we skip this test, or it is on and then we run this test but warn
|
|
|
|
|
|
|
|
if ( $marked_as_disabled )
|
|
|
|
{
|
|
|
|
if ( $::opt_enable_disabled )
|
|
|
|
{
|
|
|
|
$tinfo->{'dont_skip_though_disabled'}= 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$tinfo->{'skip'}= 1;
|
|
|
|
$tinfo->{'disable'}= 1; # Sub type of 'skip'
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $component_id eq 'im' )
|
|
|
|
{
|
|
|
|
if ( $::glob_use_embedded_server )
|
|
|
|
{
|
|
|
|
$tinfo->{'skip'}= 1;
|
|
|
|
$tinfo->{'comment'}= "No IM with embedded server";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
elsif ( $::opt_ps_protocol )
|
|
|
|
{
|
|
|
|
$tinfo->{'skip'}= 1;
|
|
|
|
$tinfo->{'comment'}= "No IM with --ps-protocol";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
elsif ( $::opt_skip_im )
|
|
|
|
{
|
|
|
|
$tinfo->{'skip'}= 1;
|
|
|
|
$tinfo->{'comment'}= "No IM tests(--skip-im)";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mtr_options_from_test_file($tinfo,"$testdir/${tname}.test");
|
|
|
|
|
2007-03-29 11:31:50 +02:00
|
|
|
if ( defined $::used_default_engine )
|
|
|
|
{
|
|
|
|
# Different default engine is used
|
|
|
|
# tag test to require that engine
|
|
|
|
$tinfo->{'ndb_test'}= 1
|
|
|
|
if ( $::used_default_engine =~ /^ndb/i );
|
|
|
|
|
|
|
|
$tinfo->{'innodb_test'}= 1
|
|
|
|
if ( $::used_default_engine =~ /^innodb/i );
|
|
|
|
}
|
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
if ( $tinfo->{'big_test'} and ! $::opt_big_test )
|
|
|
|
{
|
|
|
|
$tinfo->{'skip'}= 1;
|
|
|
|
$tinfo->{'comment'}= "Test need 'big-test' option";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $tinfo->{'ndb_extra'} and ! $::opt_ndb_extra_test )
|
|
|
|
{
|
|
|
|
$tinfo->{'skip'}= 1;
|
|
|
|
$tinfo->{'comment'}= "Test need 'ndb_extra' option";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $tinfo->{'require_manager'} )
|
|
|
|
{
|
|
|
|
$tinfo->{'skip'}= 1;
|
|
|
|
$tinfo->{'comment'}= "Test need the _old_ manager(to be removed)";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( defined $tinfo->{'binlog_format'} and
|
|
|
|
! ( $tinfo->{'binlog_format'} eq $::used_binlog_format ) )
|
|
|
|
{
|
|
|
|
$tinfo->{'skip'}= 1;
|
2007-04-10 17:01:29 +02:00
|
|
|
$tinfo->{'comment'}= "Requiring binlog format '$tinfo->{'binlog_format'}'";
|
2006-10-04 12:47:32 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $tinfo->{'need_debug'} && ! $::debug_compiled_binaries )
|
|
|
|
{
|
|
|
|
$tinfo->{'skip'}= 1;
|
|
|
|
$tinfo->{'comment'}= "Test need debug binaries";
|
|
|
|
return;
|
|
|
|
}
|
2006-10-18 13:24:06 +02:00
|
|
|
|
|
|
|
if ( $tinfo->{'ndb_test'} )
|
|
|
|
{
|
|
|
|
# This is a NDB test
|
|
|
|
if ( ! $::glob_ndbcluster_supported )
|
|
|
|
{
|
|
|
|
# Ndb is not supported, skip it
|
|
|
|
$tinfo->{'skip'}= 1;
|
|
|
|
$tinfo->{'comment'}= "No ndbcluster support";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
elsif ( $::opt_skip_ndbcluster )
|
|
|
|
{
|
|
|
|
# All ndb test's should be skipped
|
|
|
|
$tinfo->{'skip'}= 1;
|
|
|
|
$tinfo->{'comment'}= "No ndbcluster tests(--skip-ndbcluster)";
|
|
|
|
return;
|
|
|
|
}
|
2007-01-16 09:35:14 +01:00
|
|
|
# Ndb tests run with two mysqld masters
|
|
|
|
$tinfo->{'master_num'}= 2;
|
2006-10-18 13:24:06 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
# This is not a ndb test
|
|
|
|
if ( $::opt_with_ndbcluster_only )
|
|
|
|
{
|
|
|
|
# Only the ndb test should be run, all other should be skipped
|
|
|
|
$tinfo->{'skip'}= 1;
|
|
|
|
$tinfo->{'comment'}= "Only ndbcluster tests(--with-ndbcluster-only)";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-25 16:50:06 +02:00
|
|
|
if ( $tinfo->{'innodb_test'} )
|
|
|
|
{
|
2007-01-16 09:35:14 +01:00
|
|
|
# This is a test that need innodb
|
2007-04-18 14:24:09 +02:00
|
|
|
if ( $::mysqld_variables{'innodb'} ne "TRUE" )
|
2006-10-25 16:50:06 +02:00
|
|
|
{
|
|
|
|
# innodb is not supported, skip it
|
|
|
|
$tinfo->{'skip'}= 1;
|
|
|
|
$tinfo->{'comment'}= "No innodb support";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-07 19:18:01 +02:00
|
|
|
if ( $tinfo->{'need_binlog'} )
|
|
|
|
{
|
|
|
|
if (grep(/^--skip-log-bin/, @::opt_extra_mysqld_opt) )
|
|
|
|
{
|
|
|
|
$tinfo->{'skip'}= 1;
|
|
|
|
$tinfo->{'comment'}= "Test need binlog";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-06-08 07:16:36 +02:00
|
|
|
if ( $::mysql_version_id >= 50100 )
|
|
|
|
{
|
|
|
|
# Test does not need binlog, add --skip-binlog to
|
|
|
|
# the options used when starting it
|
|
|
|
push(@{$tinfo->{'master_opt'}}, "--skip-log-bin");
|
|
|
|
}
|
2007-06-07 19:18:01 +02:00
|
|
|
}
|
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
}
|
2005-02-03 21:50:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
# List of tags in the .test files that if found should set
|
|
|
|
# the specified value in "tinfo"
|
|
|
|
our @tags=
|
|
|
|
(
|
|
|
|
["include/have_innodb.inc", "innodb_test", 1],
|
|
|
|
["include/have_binlog_format_row.inc", "binlog_format", "row"],
|
2007-06-07 20:25:22 +02:00
|
|
|
["include/have_log_bin.inc", "need_binlog", 1],
|
2007-04-10 17:01:29 +02:00
|
|
|
["include/have_binlog_format_statement.inc", "binlog_format", "statement"],
|
2006-10-24 23:39:46 +02:00
|
|
|
["include/have_binlog_format_mixed.inc", "binlog_format", "mixed"],
|
2006-10-04 12:47:32 +02:00
|
|
|
["include/big_test.inc", "big_test", 1],
|
|
|
|
["include/have_debug.inc", "need_debug", 1],
|
2006-10-18 13:24:06 +02:00
|
|
|
["include/have_ndb.inc", "ndb_test", 1],
|
2007-06-30 11:42:41 +02:00
|
|
|
["include/have_multi_ndb.inc", "ndb_test", 1],
|
2006-10-04 12:47:32 +02:00
|
|
|
["include/have_ndb_extra.inc", "ndb_extra", 1],
|
|
|
|
["require_manager", "require_manager", 1],
|
|
|
|
);
|
|
|
|
|
|
|
|
sub mtr_options_from_test_file($$) {
|
|
|
|
my $tinfo= shift;
|
|
|
|
my $file= shift;
|
|
|
|
#mtr_verbose("$file");
|
|
|
|
my $F= IO::File->new($file) or mtr_error("can't open file \"$file\": $!");
|
|
|
|
|
|
|
|
while ( my $line= <$F> )
|
|
|
|
{
|
2006-11-17 13:14:07 +01:00
|
|
|
|
|
|
|
# Skip line if it start's with #
|
|
|
|
next if ( $line =~ /^#/ );
|
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
# Match this line against tag in "tags" array
|
|
|
|
foreach my $tag (@tags)
|
|
|
|
{
|
|
|
|
if ( index($line, $tag->[0]) >= 0 )
|
|
|
|
{
|
|
|
|
# Tag matched, assign value to "tinfo"
|
|
|
|
$tinfo->{"$tag->[1]"}= $tag->[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# If test sources another file, open it as well
|
2006-10-13 11:05:46 +02:00
|
|
|
if ( $line =~ /^\-\-([[:space:]]*)source(.*)$/ or
|
|
|
|
$line =~ /^([[:space:]]*)source(.*);$/ )
|
2006-10-04 12:47:32 +02:00
|
|
|
{
|
|
|
|
my $value= $2;
|
|
|
|
$value =~ s/^\s+//; # Remove leading space
|
|
|
|
$value =~ s/[[:space:]]+$//; # Remove ending space
|
|
|
|
|
|
|
|
my $sourced_file= "$::glob_mysql_test_dir/$value";
|
2006-10-13 11:05:46 +02:00
|
|
|
if ( -f $sourced_file )
|
|
|
|
{
|
|
|
|
# Only source the file if it exists, we may get
|
|
|
|
# false positives in the regexes above if someone
|
|
|
|
# writes "source nnnn;" in a test case(such as mysqltest.test)
|
|
|
|
mtr_options_from_test_file($tinfo, $sourced_file);
|
|
|
|
}
|
2006-10-04 12:47:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-03 21:50:56 +01:00
|
|
|
1;
|