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.pm108
1 files changed, 78 insertions, 30 deletions
diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm
index 6ec73715a0c..9aae7c387d1 100644
--- a/mysql-test/lib/mtr_cases.pm
+++ b/mysql-test/lib/mtr_cases.pm
@@ -31,12 +31,13 @@ our $skip_rpl;
our $do_test;
our $skip_test;
our $opt_skip_combination;
-our $binlog_format;;
+our $binlog_format;
our $enable_disabled;
our $default_storage_engine;
our $opt_with_ndbcluster_only;
our $defaults_file;
our $defaults_extra_file;
+our $reorder;
sub collect_option {
my ($opt, $value)= @_;
@@ -83,8 +84,9 @@ sub init_pattern {
#
##############################################################################
-sub collect_test_cases ($) {
+sub collect_test_cases ($$) {
my $suites= shift; # Semicolon separated list of test suites
+ my $opt_cases= shift;
my $cases= []; # Array of hash(one hash for each testcase)
$do_test_reg= init_pattern($do_test, "--do-test");
@@ -92,15 +94,15 @@ sub collect_test_cases ($) {
foreach my $suite (split(",", $suites))
{
- push(@$cases, collect_one_suite($suite));
+ push(@$cases, collect_one_suite($suite, $opt_cases));
}
- if ( @::opt_cases )
+ if ( @$opt_cases )
{
# A list of tests was specified on the command line
# Check that the tests specified was found
# in at least one suite
- foreach my $test_name_spec ( @::opt_cases )
+ foreach my $test_name_spec ( @$opt_cases )
{
my $found= 0;
my ($sname, $tname, $extension)= split_testname($test_name_spec);
@@ -119,7 +121,7 @@ sub collect_test_cases ($) {
}
}
- if ( $::opt_reorder )
+ if ( $reorder )
{
# Reorder the test cases in an order that will make them faster to run
my %sort_criteria;
@@ -172,7 +174,8 @@ sub collect_test_cases ($) {
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'}}) . "~");
+ my $opts= $tinfo->{'master_opt'} ? $tinfo->{'master_opt'} : [];
+ push(@criteria, join("!", sort @{$opts}) . "~");
$sort_criteria{$test_name} = join(" ", @criteria);
}
@@ -236,6 +239,7 @@ sub split_testname {
sub collect_one_suite($)
{
my $suite= shift; # Test suite name
+ my $opt_cases= shift;
my @cases; # Array of hash
mtr_verbose("Collecting: $suite");
@@ -304,10 +308,10 @@ sub collect_one_suite($)
$suite_opts= opts_from_file($suite_opt_file);
}
- if ( @::opt_cases )
+ if ( @$opt_cases )
{
# Collect in specified order
- foreach my $test_name_spec ( @::opt_cases )
+ foreach my $test_name_spec ( @$opt_cases )
{
my ($sname, $tname, $extension)= split_testname($test_name_spec);
@@ -428,9 +432,18 @@ sub collect_one_suite($)
{
foreach my $test (@cases)
{
- #print $test->{name}, " ", $comb, "\n";
- my $new_test= {};
+ next if ( $test->{'skip'} );
+
+ # Skip this combination if the values it provides
+ # already are set in master_opt or slave_opt
+ if (My::Options::is_set($test->{master_opt}, $comb->{comb_opt}) &&
+ My::Options::is_set($test->{slave_opt}, $comb->{comb_opt}) ){
+ next;
+ }
+
+ # Copy test options
+ my $new_test= {};
while (my ($key, $value) = each(%$test)) {
if (ref $value eq "ARRAY") {
push(@{$new_test->{$key}}, @$value);
@@ -450,6 +463,18 @@ sub collect_one_suite($)
push(@new_cases, $new_test);
}
}
+
+ # Add the plain test if it was not already added
+ # as part of a combination
+ my %added;
+ foreach my $new_test (@new_cases){
+ $added{$new_test->{name}}= 1;
+ }
+ foreach my $test (@cases){
+ push(@new_cases, $test) unless $added{$test->{name}};
+ }
+
+
#print_testcases(@new_cases);
@cases= @new_cases;
#print_testcases(@cases);
@@ -481,6 +506,7 @@ sub optimize_cases {
# --mysqld=--binlog-format=x, skip all test that does not
# support it
# =======================================================
+ #print "binlog_format: $binlog_format\n";
if (defined $binlog_format )
{
# =======================================================
@@ -488,6 +514,8 @@ sub optimize_cases {
# =======================================================
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=
@@ -513,23 +541,18 @@ sub optimize_cases {
mtr_match_prefix($opt, "--binlog-format=") || $test_binlog_format;
}
- if (defined $test_binlog_format)
+ if (defined $test_binlog_format and
+ defined $tinfo->{binlog_formats} )
{
- if ( defined $tinfo->{binlog_formats} )
+ my $supported=
+ grep { $_ eq $test_binlog_format } @{$tinfo->{'binlog_formats'}};
+ if ( !$supported )
{
- my $supported=
- grep { $_ eq $test_binlog_format } @{$tinfo->{'binlog_formats'}};
- if ( !$supported )
- {
- $tinfo->{'skip'}= 1;
- $tinfo->{'comment'}=
- "Doesn't support --binlog-format='$test_binlog_format'";
- next;
- }
+ $tinfo->{'skip'}= 1;
+ $tinfo->{'comment'}=
+ "Doesn't support --binlog-format='$test_binlog_format'";
+ next;
}
-
- # Save binlog format for dynamic switching
- $tinfo->{binlog_format_switch}= $test_binlog_format;
}
}
}
@@ -630,18 +653,26 @@ sub collect_one_test_case {
#print " filename: $filename\n";
# ----------------------------------------------------------------------
- # Skip some tests silently
+ # Check --start-from
# ----------------------------------------------------------------------
- if ( $start_from and $tname lt $start_from )
+ if ( $start_from )
{
- return;
+ # start_from can be specified as [suite.].testname_prefix
+ my ($suite, $test, $ext)= split_testname($start_from);
+
+ if ( $suite and $suitename lt $suite){
+ return; # Skip silently
+ }
+ if ( $tname lt $test ){
+ return; # Skip silently
+ }
}
# ----------------------------------------------------------------------
# Set defaults
# ----------------------------------------------------------------------
my $tinfo= {};
- $tinfo->{'name'}= basename($suitename) . ".$tname";
+ $tinfo->{'name'}= $suitename . ".$tname";
$tinfo->{'path'}= "$testdir/$filename";
# TODO allow nonexistsing result file
@@ -871,8 +902,19 @@ sub collect_one_test_case {
my $config= "$suitedir/my.cnf";
if (! -f $config )
{
- # Suite has no config, use default.cnf
+ # assume default.cnf will be used
$config= "include/default_my.cnf";
+
+ # Suite has no config, autodetect which one to use
+ if ( $tinfo->{rpl_test} ){
+ $config= "suite/rpl/my.cnf";
+ if ( $tinfo->{ndb_test} ){
+ $config= "suite/rpl_ndb/my.cnf";
+ }
+ }
+ elsif ( $tinfo->{ndb_test} ){
+ $config= "suite/ndb/my.cnf";
+ }
}
$tinfo->{template_path}= $config;
}
@@ -882,6 +924,12 @@ sub collect_one_test_case {
$tinfo->{extra_template_path}= $defaults_extra_file;
}
+ # ----------------------------------------------------------------------
+ # Append mysqld extra options to both master and slave
+ # ----------------------------------------------------------------------
+ push(@{$tinfo->{'master_opt'}}, @::opt_extra_mysqld_opt);
+ push(@{$tinfo->{'slave_opt'}}, @::opt_extra_mysqld_opt);
+
return $tinfo;
}