MTR: MTR_COMBINATIONS envvar for tests

MTR_COMBINATIONS contains comma-separated list of currently applied
combinations "x,y,...". MTR_COMBINATION_X, MTR_COMBINATION_Y, ... are
set to 1 for this list of combinations.

Fixed dead check: non-existent element $tinfo->{combination}.

Better use this clause:

use warnings FATAL => 'uninitialized';

But this must be very well tested.
This commit is contained in:
Aleksey Midenkov 2017-12-03 21:25:07 +03:00
parent 36c0bec2c7
commit ce78bafe7a

View file

@ -3758,14 +3758,32 @@ sub run_testcase ($$) {
$ENV{'MTR_TEST_NAME'} = $tinfo->{name}; $ENV{'MTR_TEST_NAME'} = $tinfo->{name};
resfile_report_test($tinfo) if $opt_resfile; resfile_report_test($tinfo) if $opt_resfile;
# Allow only alpanumerics pluss _ - + . in combination names, for my $key (grep { /^MTR_COMBINATION/ } keys %ENV)
# or anything beginning with -- (the latter comes from --combination)
my $combination= $tinfo->{combination};
if ($combination && $combination !~ /^\w[-\w\.\+]*$/
&& $combination !~ /^--/)
{ {
mtr_error("Combination '$combination' contains illegal characters"); delete $ENV{$key};
} }
if (ref $tinfo->{combinations} eq 'ARRAY')
{
for (my $i = 0; $i < @{$tinfo->{combinations}}; ++$i )
{
my $combination = $tinfo->{combinations}->[$i];
# Allow only alphanumerics plus _ - + . in combination names,
# or anything beginning with -- (the latter comes from --combination)
if ($combination && $combination !~ /^\w[-\w\.\+]*$/
&& $combination !~ /^--/)
{
mtr_error("Combination '$combination' contains illegal characters");
}
$ENV{"MTR_COMBINATION_". uc(${combination})} = 1;
}
$ENV{"MTR_COMBINATIONS"} = join(',', @{$tinfo->{combinations}});
}
elsif (exists $tinfo->{combinations})
{
die 'Unexpected type of $tinfo->{combinations}';
}
# ------------------------------------------------------- # -------------------------------------------------------
# Init variables that can change between each test case # Init variables that can change between each test case
# ------------------------------------------------------- # -------------------------------------------------------