summaryrefslogtreecommitdiff
path: root/mysql-test/lib/mtr_cases.pm
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/lib/mtr_cases.pm')
-rw-r--r--mysql-test/lib/mtr_cases.pm360
1 files changed, 118 insertions, 242 deletions
diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm
index 1a27f94acb1..fd4832d49a3 100644
--- a/mysql-test/lib/mtr_cases.pm
+++ b/mysql-test/lib/mtr_cases.pm
@@ -39,7 +39,6 @@ our $enable_disabled;
our $default_storage_engine;
our $opt_with_ndbcluster_only;
our $defaults_file;
-our $defaults_extra_file;
our $quick_collect;
sub collect_option {
@@ -55,7 +54,7 @@ sub collect_option {
}
use File::Basename;
-use File::Spec::Functions qw / splitdir /;
+use File::Spec::Functions qw /splitdir/;
use IO::File();
use My::Config;
use My::Platform;
@@ -68,21 +67,10 @@ require "mtr_misc.pl";
my $do_test_reg;
my $skip_test_reg;
-# Related to adding InnoDB plugin combinations
-my $lib_innodb_plugin;
-
# If "Quick collect", set to 1 once a test to run has been found.
my $some_test_found;
-sub find_innodb_plugin {
- $lib_innodb_plugin=
- my_find_file($::basedir,
- ["storage/innodb_plugin", "storage/innodb_plugin/.libs",
- "lib/mysql/plugin", "lib/mariadb/plugin", "lib/plugin"],
- ["ha_innodb_plugin.dll", "ha_innodb_plugin.so",
- "ha_innodb_plugin.sl"],
- NOT_REQUIRED);
-}
+my $default_suite_object = do 'My/Suite.pm';
sub init_pattern {
my ($from, $what)= @_;
@@ -116,8 +104,6 @@ sub collect_test_cases ($$$) {
$do_test_reg= init_pattern($do_test, "--do-test");
$skip_test_reg= init_pattern($skip_test, "--skip-test");
- &find_innodb_plugin;
-
# If not reordering, we also shouldn't group by suites, unless
# no test cases were named.
# This also effects some logic in the loop following this.
@@ -188,17 +174,17 @@ sub collect_test_cases ($$$) {
my $opts= $tinfo->{'master_opt'} ? $tinfo->{'master_opt'} : [];
push(@criteria, join("!", sort @{$opts}) . "~");
- $sort_criteria{$tinfo->{name}} = join(" ", @criteria);
+ $sort_criteria{$tinfo->fullname()} = join(" ", @criteria);
}
@$cases = sort {
- $sort_criteria{$a->{'name'}} . $a->{'name'} cmp
- $sort_criteria{$b->{'name'}} . $b->{'name'}; } @$cases;
+ $sort_criteria{$a->fullname()} . $a->fullname() cmp
+ $sort_criteria{$b->fullname()} . $b->fullname() } @$cases;
# For debugging the sort-order
# foreach my $tinfo (@$cases)
# {
- # print("$sort_criteria{$tinfo->{'name'}} -> \t$tinfo->{'name'}\n");
+ # print $sort_criteria{$tinfo->fullname()}," -> \t",$tinfo->fullname(),"\n";
# }
}
@@ -310,6 +296,17 @@ sub collect_one_suite
mtr_verbose("testdir: $testdir");
mtr_verbose("resdir: $resdir");
+ #
+ # Load the Suite object
+ #
+ unless ($::suites{$suite}) {
+ if (-f "$suitedir/suite.pm") {
+ $::suites{$suite} = do "$suitedir/suite.pm";
+ } else {
+ $::suites{$suite} = $default_suite_object;
+ }
+ }
+
# ----------------------------------------------------------------------
# Build a hash of disabled testcases for this suite
# ----------------------------------------------------------------------
@@ -328,12 +325,8 @@ sub collect_one_suite
}
# Read suite.opt file
- my $suite_opt_file= "$testdir/suite.opt";
- my $suite_opts= [];
- if ( -f $suite_opt_file )
- {
- $suite_opts= opts_from_file($suite_opt_file);
- }
+ my $suite_opts= [ opts_from_file("$testdir/suite.opt") ];
+ $suite_opts = [ opts_from_file("$suitedir/suite.opt") ] unless @$suite_opts;
if ( @$opt_cases )
{
@@ -438,14 +431,16 @@ sub collect_one_suite
{
# Read combinations file in my.cnf format
mtr_verbose("Read combinations file");
+ my %env_filter = map { $_ => 1 } split /:/, $ENV{"\U${suite}_COMBINATIONS"};
my $config= My::Config->new($combination_file);
foreach my $group ($config->groups()) {
my $comb= {};
$comb->{name}= $group->name();
+ next if %env_filter and not $env_filter{$comb->{name}};
foreach my $option ( $group->options() ) {
push(@{$comb->{comb_opt}}, $option->option());
}
- push(@combinations, $comb);
+ push(@combinations, $comb) if $comb->{comb_opt};
}
}
@@ -539,28 +534,7 @@ sub optimize_cases {
# support it
# =======================================================
#print "binlog_format: $binlog_format\n";
- if (defined $binlog_format )
- {
- # =======================================================
- # Fixed --binlog-format=x specified on command line
- # =======================================================
- if ( defined $tinfo->{'binlog_formats'} )
- {
- #print "binlog_formats: ". join(", ", @{$tinfo->{binlog_formats}})."\n";
-
- # The test supports different binlog formats
- # check if the selected one is ok
- my $supported=
- grep { $_ eq $binlog_format } @{$tinfo->{'binlog_formats'}};
- if ( !$supported )
- {
- $tinfo->{'skip'}= 1;
- $tinfo->{'comment'}=
- "Doesn't support --binlog-format='$binlog_format'";
- }
- }
- }
- else
+ if (not defined $binlog_format )
{
# =======================================================
# Use dynamic switching of binlog format
@@ -623,10 +597,6 @@ sub optimize_cases {
$tinfo->{'ndb_test'}= 1
if ( $default_engine =~ /^ndb/i );
- $tinfo->{'innodb_test'}= 1
- if ( $default_engine =~ /^innodb/i );
- $tinfo->{'pbxt_test'}= 1
- if ( $default_engine =~ /^pbxt/i );
}
}
@@ -644,67 +614,81 @@ sub optimize_cases {
# Read options from the given opt file and append them as an array
# to $tinfo->{$opt_name}
#
-sub process_opts_file {
- my ($tinfo, $opt_file, $opt_name)= @_;
+sub process_opts {
+ my ($tinfo, $opt_name)= @_;
+
+ my @opts= @{$tinfo->{$opt_name}};
+ $tinfo->{$opt_name} = [];
+
+ my @plugins;
+ my %seen;
- if ( -f $opt_file )
+ foreach my $opt (@opts)
{
- my $opts= opts_from_file($opt_file);
+ my $value;
- foreach my $opt ( @$opts )
+ # 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
+
+ $value= mtr_match_prefix($opt, "--timezone=");
+ if ( defined $value )
{
- my $value;
+ $tinfo->{'timezone'}= $value;
+ next;
+ }
- # 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
+ $value= mtr_match_prefix($opt, "--plugin-load=");
+ if (defined $value)
+ {
+ push @plugins, $value unless $seen{$value};
+ $seen{$value}=1;
+ next;
+ }
- $value= mtr_match_prefix($opt, "--timezone=");
- if ( defined $value )
- {
- $tinfo->{'timezone'}= $value;
- next;
- }
+ $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;
+ }
- $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;
- }
+ $value= mtr_match_prefix($opt, "--config-file-template=");
+ if ( defined $value)
+ {
+ # Specifies the configuration file to use for this test
+ $tinfo->{'template_path'}= dirname($tinfo->{path})."/$value";
+ next;
+ }
- $value= mtr_match_prefix($opt, "--config-file-template=");
- if ( defined $value)
- {
- # Specifies the configuration file to use for this test
- $tinfo->{'template_path'}= dirname($tinfo->{path})."/$value";
- next;
- }
+ # If we set default time zone, remove the one we have
+ $value= mtr_match_prefix($opt, "--default-time-zone=");
+ if ( defined $value )
+ {
+ # Set timezone for this test case to something different
+ $tinfo->{'timezone'}= "GMT-8";
+ # Fallthrough, add the --default-time-zone option
+ }
- # If we set default time zone, remove the one we have
- $value= mtr_match_prefix($opt, "--default-time-zone=");
- if ( defined $value )
- {
- # Set timezone for this test case to something different
- $tinfo->{'timezone'}= "GMT-8";
- # Fallthrough, add the --default-time-zone option
- }
+ # 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;
+ }
- # 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;
- }
+ # Ok, this was a real option, add it
+ push(@{$tinfo->{$opt_name}}, $opt);
+ }
- # Ok, this was a real option, add it
- push(@{$tinfo->{$opt_name}}, $opt);
- }
+ if (@plugins) {
+ my $sep = (IS_WINDOWS) ? ';' : ':';
+ push @{$tinfo->{$opt_name}}, "--plugin-load=" . join($sep, @plugins);
}
}
@@ -758,7 +742,7 @@ sub collect_one_test_case {
name => "$suitename.$tname",
shortname => $tname,
path => "$testdir/$filename",
-
+ suite => $suitename,
);
my $result_file= "$resdir/$tname.result";
@@ -790,11 +774,13 @@ sub collect_one_test_case {
# Check for disabled tests
# ----------------------------------------------------------------------
my $marked_as_disabled= 0;
- if ( $disabled->{$tname} )
+ if ( $disabled->{$tname} or $disabled->{"$suitename.$tname"} )
{
# Test was marked as disabled in suites disabled.def file
$marked_as_disabled= 1;
- $tinfo->{'comment'}= $disabled->{$tname};
+ # Test name may have been disabled with or without suite name part
+ $tinfo->{'comment'}= $disabled->{$tname} ||
+ $disabled->{"$suitename.$tname"};
}
my $disabled_file= "$testdir/$tname.disabled";
@@ -878,7 +864,7 @@ sub collect_one_test_case {
if ( -f "$testdir/$tname.slave-mi");
- tags_from_test_file($tinfo,"$testdir/${tname}.test");
+ my @source_files = tags_from_test_file($tinfo,"$testdir/${tname}.test");
# Get default storage engine from suite.opt file
@@ -895,12 +881,6 @@ sub collect_one_test_case {
$tinfo->{'ndb_test'}= 1
if ( $local_default_storage_engine =~ /^ndb/i );
- $tinfo->{'innodb_test'}= 1
- if ( $local_default_storage_engine =~ /^innodb/i );
-
- $tinfo->{'pbxt_test'}= 1
- if ( $local_default_storage_engine =~ /^pbxt/i );
-
}
if ( $tinfo->{'big_test'} and ! $::opt_big_test )
@@ -947,78 +927,6 @@ sub collect_one_test_case {
}
}
- if ($tinfo->{'federated_test'})
- {
- # This is a test that needs federated, enable it
- push(@{$tinfo->{'master_opt'}}, "--loose-federated");
- push(@{$tinfo->{'slave_opt'}}, "--loose-federated");
- }
-
- if ( $tinfo->{'innodb_test'} )
- {
- # This is a test that needs innodb
- if ( $::mysqld_variables{'innodb'} eq "OFF" ||
- ! exists $::mysqld_variables{'innodb'} )
- {
- # innodb is not supported, skip it
- $tinfo->{'skip'}= 1;
- $tinfo->{'comment'}= "No innodb support";
- return $tinfo;
- }
- }
- elsif ( $tinfo->{'innodb_plugin_test'} )
- {
- # This is a test that needs the innodb plugin
- if (!&find_innodb_plugin)
- {
- # innodb plugin is not supported, skip it
- $tinfo->{'skip'}= 1;
- $tinfo->{'comment'}= "No innodb plugin support";
- return $tinfo;
- }
-
- my $sep= (IS_WINDOWS) ? ';' : ':';
- my $plugin_filename= basename($lib_innodb_plugin);
- my $plugin_list=
- "innodb=$plugin_filename$sep" .
- "innodb_trx=$plugin_filename$sep" .
- "innodb_locks=$plugin_filename$sep" .
- "innodb_lock_waits=$plugin_filename$sep" .
- "innodb_cmp=$plugin_filename$sep" .
- "innodb_cmp_reset=$plugin_filename$sep" .
- "innodb_cmpmem=$plugin_filename$sep" .
- "innodb_cmpmem_reset=$plugin_filename";
-
- foreach my $k ('master_opt', 'slave_opt')
- {
- push(@{$tinfo->{$k}}, '--ignore-builtin-innodb');
- push(@{$tinfo->{$k}}, '--plugin-dir=' . dirname($lib_innodb_plugin));
- push(@{$tinfo->{$k}}, "--plugin-load=$plugin_list");
- }
- }
- else
- {
- push(@{$tinfo->{'master_opt'}}, "--loose-skip-innodb");
- push(@{$tinfo->{'slave_opt'}}, "--loose-skip-innodb");
- }
-
- if ( $tinfo->{'need_binlog'} )
- {
- if (grep(/^--skip-log-bin/, @::opt_extra_mysqld_opt) )
- {
- $tinfo->{'skip'}= 1;
- $tinfo->{'comment'}= "Test needs binlog";
- return $tinfo;
- }
- }
- else
- {
- # Test does not need binlog, add --skip-binlog to
- # the options used when starting
- push(@{$tinfo->{'master_opt'}}, "--loose-skip-log-bin");
- push(@{$tinfo->{'slave_opt'}}, "--loose-skip-log-bin");
- }
-
if ( $tinfo->{'rpl_test'} )
{
if ( $skip_rpl )
@@ -1089,31 +997,9 @@ sub collect_one_test_case {
$tinfo->{template_path}= $config;
}
- if ( $tinfo->{'pbxt_test'} )
- {
- # This is a test that needs pbxt
- if ( $::mysqld_variables{'pbxt'} eq "OFF" ||
- ! exists $::mysqld_variables{'pbxt'} )
- {
- # Engine is not supported, skip it
- $tinfo->{'skip'}= 1;
- return $tinfo;
- }
- }
- else
- {
- # Only disable engine if it's on by default (to avoid warnings about
- # not existing loose options
- if ( $::mysqld_variables{'pbxt'} eq "ON")
- {
- push(@{$tinfo->{'master_opt'}}, "--loose-skip-pbxt");
- push(@{$tinfo->{'slave_opt'}}, "--loose-skip-pbxt");
- }
- }
-
if ( $tinfo->{'example_plugin_test'} )
{
- if ( !$ENV{'EXAMPLE_PLUGIN'} )
+ if ( !$ENV{'HA_EXAMPLE_SO'} )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "Test requires the 'example' plugin";
@@ -1123,7 +1009,7 @@ sub collect_one_test_case {
if ( $tinfo->{'oqgraph_test'} )
{
- if ( !$ENV{'OQGRAPH_PLUGIN'} )
+ if ( !$ENV{'GRAPH_ENGINE_SO'} )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "Test requires the OQGraph storage engine";
@@ -1131,27 +1017,29 @@ sub collect_one_test_case {
}
}
-
- # Set extra config file to use
- if (defined $defaults_extra_file) {
- $tinfo->{extra_template_path}= $defaults_extra_file;
+ if (not ref $::suites{$tinfo->{suite}})
+ {
+ $tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}= $::suites{$tinfo->{suite}};
+ return $tinfo;
}
# ----------------------------------------------------------------------
- # Append mysqld extra options to both master and slave
+ # Append mysqld extra options to master and slave, as appropriate
# ----------------------------------------------------------------------
+ for (@source_files) {
+ s/\.\w+$//;
+ push @{$tinfo->{master_opt}}, opts_from_file("$_.opt");
+ push @{$tinfo->{slave_opt}}, opts_from_file("$_.opt");
+ push @{$tinfo->{master_opt}}, opts_from_file("$_-master.opt");
+ push @{$tinfo->{slave_opt}}, opts_from_file("$_-slave.opt");
+ }
+
push(@{$tinfo->{'master_opt'}}, @::opt_extra_mysqld_opt);
push(@{$tinfo->{'slave_opt'}}, @::opt_extra_mysqld_opt);
- # ----------------------------------------------------------------------
- # Add master opts, extra options only for master
- # ----------------------------------------------------------------------
- process_opts_file($tinfo, "$testdir/$tname-master.opt", 'master_opt');
-
- # ----------------------------------------------------------------------
- # Add slave opts, list of extra option only for slave
- # ----------------------------------------------------------------------
- process_opts_file($tinfo, "$testdir/$tname-slave.opt", 'slave_opt');
+ process_opts($tinfo, 'master_opt');
+ process_opts($tinfo, 'slave_opt');
return $tinfo;
}
@@ -1161,21 +1049,6 @@ sub collect_one_test_case {
# the specified value in "tinfo"
my @tags=
(
- ["include/have_binlog_format_row.inc", "binlog_formats", ["row"]],
- ["include/have_binlog_format_statement.inc", "binlog_formats", ["statement"]],
- ["include/have_binlog_format_mixed.inc", "binlog_formats", ["mixed"]],
- ["include/have_binlog_format_mixed_or_row.inc",
- "binlog_formats", ["mixed", "row"]],
- ["include/have_binlog_format_mixed_or_statement.inc",
- "binlog_formats", ["mixed", "statement"]],
- ["include/have_binlog_format_row_or_statement.inc",
- "binlog_formats", ["row", "statement"]],
-
- ["include/have_log_bin.inc", "need_binlog", 1],
-
- ["include/have_innodb.inc", "innodb_test", 1],
- ["include/have_pbxt.inc", "pbxt_test", 1],
- ["include/have_innodb_plugin.inc", "innodb_plugin_test", 1],
["include/big_test.inc", "big_test", 1],
["include/have_debug.inc", "need_debug", 1],
["include/have_ndb.inc", "ndb_test", 1],
@@ -1183,7 +1056,6 @@ my @tags=
["include/master-slave.inc", "rpl_test", 1],
["include/ndb_master-slave.inc", "rpl_test", 1],
["include/ndb_master-slave.inc", "ndb_test", 1],
- ["federated.inc", "federated_test", 1],
["include/not_embedded.inc", "not_embedded", 1],
["include/not_valgrind.inc", "not_valgrind", 1],
["include/have_example_plugin.inc", "example_plugin_test", 1],
@@ -1197,6 +1069,7 @@ sub tags_from_test_file {
my $file= shift;
#mtr_verbose("$file");
my $F= IO::File->new($file) or mtr_error("can't open file \"$file\": $!");
+ my @all_files=($file);
while ( my $line= <$F> )
{
@@ -1232,13 +1105,13 @@ sub tags_from_test_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)
- tags_from_test_file($tinfo, $sourced_file);
+ unshift @all_files, tags_from_test_file($tinfo, $sourced_file);
last;
}
}
}
-
}
+ @all_files;
}
sub unspace {
@@ -1251,6 +1124,9 @@ sub unspace {
sub opts_from_file ($) {
my $file= shift;
+ local $_;
+
+ return () unless -f $file;
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
my @args;
@@ -1292,7 +1168,7 @@ sub opts_from_file ($) {
}
}
close FILE;
- return \@args;
+ return @args;
}
sub print_testcases {