mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Add support for running in parallel
This commit is contained in:
@ -40,7 +40,7 @@ our $default_storage_engine;
|
||||
our $opt_with_ndbcluster_only;
|
||||
our $defaults_file;
|
||||
our $defaults_extra_file;
|
||||
our $reorder;
|
||||
our $reorder= 1;
|
||||
|
||||
sub collect_option {
|
||||
my ($opt, $value)= @_;
|
||||
@ -55,6 +55,7 @@ use File::Basename;
|
||||
use IO::File();
|
||||
use My::Config;
|
||||
use My::Platform;
|
||||
use My::Test;
|
||||
use My::Find;
|
||||
|
||||
require "mtr_misc.pl";
|
||||
@ -135,52 +136,16 @@ sub collect_test_cases ($$) {
|
||||
{
|
||||
my @criteria = ();
|
||||
|
||||
# Look for tests that must be run in a defined order - that is
|
||||
# defined by test having the same name except for the ending digit
|
||||
#
|
||||
# Append the criteria for sorting, in order of importance.
|
||||
#
|
||||
push(@criteria, "ndb=" . ($tinfo->{'ndb_test'} ? "A" : "B"));
|
||||
# Group test with equal options together.
|
||||
# Ending with "~" makes empty sort later than filled
|
||||
my $opts= $tinfo->{'master_opt'} ? $tinfo->{'master_opt'} : [];
|
||||
push(@criteria, join("!", sort @{$opts}) . "~");
|
||||
|
||||
# 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
|
||||
my $opts= $tinfo->{'master_opt'} ? $tinfo->{'master_opt'} : [];
|
||||
push(@criteria, join("!", sort @{$opts}) . "~");
|
||||
|
||||
$sort_criteria{$test_name} = join(" ", @criteria);
|
||||
}
|
||||
$sort_criteria{$tinfo->{name}} = join(" ", @criteria);
|
||||
}
|
||||
|
||||
@$cases = sort {
|
||||
@ -454,7 +419,7 @@ sub collect_one_suite($)
|
||||
}
|
||||
|
||||
# Copy test options
|
||||
my $new_test= {};
|
||||
my $new_test= My::Test->new();
|
||||
while (my ($key, $value) = each(%$test)) {
|
||||
if (ref $value eq "ARRAY") {
|
||||
push(@{$new_test->{$key}}, @$value);
|
||||
@ -682,13 +647,16 @@ sub collect_one_test_case {
|
||||
# ----------------------------------------------------------------------
|
||||
# Set defaults
|
||||
# ----------------------------------------------------------------------
|
||||
my $tinfo= {};
|
||||
$tinfo->{'name'}= $suitename . ".$tname";
|
||||
$tinfo->{'path'}= "$testdir/$filename";
|
||||
my $tinfo= My::Test->new
|
||||
(
|
||||
name => "$suitename.$tname",
|
||||
path => "$testdir/$filename",
|
||||
|
||||
# TODO allow nonexistsing result file
|
||||
# in that case .test must issue "exit" otherwise test should fail by default
|
||||
$tinfo->{'result_file'}= "$resdir/$tname.result";
|
||||
# TODO allow nonexistsing result file
|
||||
# in that case .test must issue "exit" otherwise test
|
||||
# should fail by default
|
||||
result_file => "$resdir/$tname.result",
|
||||
);
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Skip some tests but include in list, just mark them as skipped
|
||||
@ -1034,19 +1002,6 @@ sub unspace {
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub envsubst {
|
||||
my $string= shift;
|
||||
|
||||
if ( ! defined $ENV{$string} )
|
||||
{
|
||||
mtr_error(".opt file references '$string' which is not set");
|
||||
}
|
||||
|
||||
return $ENV{$string};
|
||||
}
|
||||
|
||||
|
||||
sub opts_from_file ($) {
|
||||
my $file= shift;
|
||||
|
||||
@ -1083,10 +1038,6 @@ sub opts_from_file ($) {
|
||||
or $arg =~ s/^([^\'\"]*)\"(.*)\"([^\'\"]*)$/$1$2$3/;
|
||||
$arg =~ s/\\\\/\\/g;
|
||||
|
||||
# Expand environment variables
|
||||
$arg =~ s/\$\{(\w+)\}/envsubst($1)/ge;
|
||||
$arg =~ s/\$(\w+)/envsubst($1)/ge;
|
||||
|
||||
# Do not pass empty string since my_getopt is not capable to handle it.
|
||||
if (length($arg)) {
|
||||
push(@args, $arg);
|
||||
@ -1102,17 +1053,7 @@ sub print_testcases {
|
||||
|
||||
print "=" x 60, "\n";
|
||||
foreach my $test (@cases){
|
||||
print "[", $test->{name}, "]", "\n";
|
||||
while ((my ($key, $value)) = each(%$test)) {
|
||||
print " ", $key, "= ";
|
||||
if (ref $value eq "ARRAY") {
|
||||
print "[", join(", ", @$value), "]";
|
||||
} else {
|
||||
print $value;
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
print "\n";
|
||||
$test->print_test();
|
||||
}
|
||||
print "=" x 60, "\n";
|
||||
}
|
||||
|
Reference in New Issue
Block a user