summaryrefslogtreecommitdiff
path: root/mysql-test/lib
diff options
context:
space:
mode:
authormsvensson@pilot.(none) <>2007-06-27 14:28:02 +0200
committermsvensson@pilot.(none) <>2007-06-27 14:28:02 +0200
commit8661497e9bde1f42674b9789799d81b0ea2ba0d0 (patch)
tree7685fdafab101eb337d2a982d91411513f0eb399 /mysql-test/lib
parent95cf9738622fda37d4ba6c11c2d61322807bef3f (diff)
downloadmariadb-git-8661497e9bde1f42674b9789799d81b0ea2ba0d0.tar.gz
WL#3933 Split main test suite to rpl, rpl_ndb and ndb
- Update mysql-test-run.pl to collect tests from several suites - Group test into suites - Add suite.opt file
Diffstat (limited to 'mysql-test/lib')
-rw-r--r--mysql-test/lib/mtr_cases.pl241
-rw-r--r--mysql-test/lib/mtr_report.pl27
2 files changed, 156 insertions, 112 deletions
diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl
index 11ff85818a7..13708a5a3af 100644
--- a/mysql-test/lib/mtr_cases.pl
+++ b/mysql-test/lib/mtr_cases.pl
@@ -23,7 +23,8 @@ use IO::File();
use strict;
sub collect_test_cases ($);
-sub collect_one_test_case ($$$$$$$);
+sub collect_one_suite ($$);
+sub collect_one_test_case ($$$$$$$$$);
sub mtr_options_from_test_file($$);
@@ -34,7 +35,120 @@ sub mtr_options_from_test_file($$);
##############################################################################
sub collect_test_cases ($) {
- my $suite= shift; # Test suite name
+ 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
+ foreach my $tname ( @::opt_cases )
+ {
+ my $found= 0;
+ foreach my $test ( @$cases )
+ {
+ if ( mtr_match_extension($test->{'name'}, $tname) )
+ {
+ $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;
+
+}
+
+sub collect_one_suite($$)
+{
+ my $suite= shift; # Test suite name
+ my $cases= shift; # List of test cases
+
+ mtr_verbose("Collecting: $suite");
my $testdir;
my $resdir;
@@ -50,12 +164,8 @@ sub collect_test_cases ($) {
$resdir= "$::glob_mysql_test_dir/suite/$suite/r";
}
- my $cases = []; # Array of hash, will be array of C struct
-
- opendir(TESTDIR, $testdir) or mtr_error("Can't open dir \"$testdir\": $!");
-
# ----------------------------------------------------------------------
- # Disable some tests listed in disabled.def
+ # Build a hash of disabled testcases for this suite
# ----------------------------------------------------------------------
my %disabled;
if ( open(DISABLED, "$testdir/disabled.def" ) )
@@ -71,11 +181,19 @@ sub collect_test_cases ($) {
close DISABLED;
}
+ # 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);
+ }
+
if ( @::opt_cases )
{
+ # Collect in specified order, no sort
foreach my $tname ( @::opt_cases )
{
- # Run in specified order, no sort
my $elem= undef;
my $component_id= undef;
@@ -122,7 +240,8 @@ sub collect_test_cases ($) {
}
elsif ( ! $mysqld_test_exists and ! $im_test_exists )
{
- mtr_error("Test case $tname is not found");
+ # Silently skip, could exist in another suite
+ next;
}
elsif ( $mysqld_test_exists )
{
@@ -136,13 +255,15 @@ sub collect_test_cases ($) {
}
}
- collect_one_test_case($testdir,$resdir,$tname,$elem,$cases,\%disabled,
- $component_id);
+ collect_one_test_case($testdir,$resdir,$suite,$tname,
+ $elem,$cases,\%disabled,$component_id,
+ $suite_opts);
}
- closedir TESTDIR;
}
else
{
+ opendir(TESTDIR, $testdir) or mtr_error("Can't open dir \"$testdir\": $!");
+
foreach my $elem ( sort readdir(TESTDIR) )
{
my $component_id= undef;
@@ -165,87 +286,13 @@ sub collect_test_cases ($) {
next if $::opt_do_test and
! defined mtr_match_prefix($elem,$::opt_do_test);
- collect_one_test_case($testdir,$resdir,$tname,$elem,$cases,\%disabled,
- $component_id);
+ collect_one_test_case($testdir,$resdir,$suite,$tname,
+ $elem,$cases,\%disabled,$component_id,
+ $suite_opts);
}
closedir TESTDIR;
}
- # Reorder the test cases in an order that will make them faster to run
- if ( $::opt_reorder )
- {
-
- 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;
}
@@ -257,14 +304,16 @@ sub collect_test_cases ($) {
##############################################################################
-sub collect_one_test_case($$$$$$$) {
+sub collect_one_test_case($$$$$$$$$) {
my $testdir= shift;
my $resdir= shift;
+ my $suite= shift;
my $tname= shift;
my $elem= shift;
my $cases= shift;
my $disabled=shift;
my $component_id= shift;
+ my $suite_opts= shift;
my $path= "$testdir/$elem";
@@ -279,7 +328,7 @@ sub collect_one_test_case($$$$$$$) {
my $tinfo= {};
- $tinfo->{'name'}= $tname;
+ $tinfo->{'name'}= "$suite.$tname";
$tinfo->{'result_file'}= "$resdir/$tname.result";
$tinfo->{'component_id'} = $component_id;
push(@$cases, $tinfo);
@@ -334,6 +383,15 @@ sub collect_one_test_case($$$$$$$) {
$tinfo->{'slave_opt'}= [];
$tinfo->{'slave_mi'}= [];
+ # Add suite opts
+ foreach my $opt ( @$suite_opts )
+ {
+ mtr_verbose($opt);
+ push(@{$tinfo->{'master_opt'}}, $opt);
+ push(@{$tinfo->{'slave_opt'}}, $opt);
+ }
+
+ # Add master opts
if ( -f $master_opt_file )
{
@@ -394,6 +452,7 @@ sub collect_one_test_case($$$$$$$) {
}
}
+ # Add slave opts
if ( -f $slave_opt_file )
{
my $slave_opt= mtr_get_opts_from_file($slave_opt_file);
diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl
index 096840eb559..d60f8967256 100644
--- a/mysql-test/lib/mtr_report.pl
+++ b/mysql-test/lib/mtr_report.pl
@@ -48,30 +48,15 @@ sub mtr_verbose (@);
# We can't use diff -u or diff -a as these are not portable
sub mtr_show_failed_diff ($) {
- my $result_file_name= shift;
+ my $tinfo= shift;
# The reject and log files have been dumped to
# to filenames based on the result_file's name
- my $tname= basename($result_file_name);
- $tname=~ s/\..*$//;
-
- my $reject_file= "r/$tname.reject";
- my $result_file= "r/$tname.result";
- my $log_file= "$::opt_vardir/log/$tname.log";
- my $eval_file= "r/$tname.eval";
-
- if ( $::opt_suite ne "main" )
- {
- $reject_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$reject_file";
- $result_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$result_file";
- $eval_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$eval_file";
- $log_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$log_file";
- }
-
- if ( -f $eval_file )
- {
- $result_file= $eval_file;
- }
+ my $base_file= mtr_match_extension($tinfo->{'result_file'},
+ "result"); # Trim extension
+ my $reject_file= "$base_file.reject";
+ my $result_file= "$base_file.result";
+ my $log_file= "$base_file.log";
my $diffopts= $::opt_udiff ? "-u" : "-c";