| 1 |
package My::Suite::CTest; |
| 2 |
use Cwd; |
| 3 |
|
| 4 |
@ISA = qw(My::Suite); |
| 5 |
|
| 6 |
sub list_cases { |
| 7 |
my ($self) = @_; |
| 8 |
keys %{$self->{ctests}} |
| 9 |
} |
| 10 |
|
| 11 |
sub start_test { |
| 12 |
my ($self, $tinfo)= @_; |
| 13 |
my $args; |
| 14 |
my $path; |
| 15 |
my $cmd = $self->{ctests}->{$tinfo->{shortname}}; |
| 16 |
|
| 17 |
if ($cmd =~ /[ "'><%!*?]/) { |
| 18 |
($path, $args) = ('/bin/sh', [ '-c', $cmd ]) |
| 19 |
} else { |
| 20 |
($path, $args) = ($cmd, , [ ]) |
| 21 |
} |
| 22 |
|
| 23 |
my $oldpwd=getcwd(); |
| 24 |
chdir $::opt_vardir; |
| 25 |
my $proc=My::SafeProcess->new |
| 26 |
( |
| 27 |
name => $tinfo->{shortname}, |
| 28 |
path => $path, |
| 29 |
args => \$args, |
| 30 |
append => 1, |
| 31 |
output => $::path_current_testlog, |
| 32 |
error => $::path_current_testlog, |
| 33 |
); |
| 34 |
chdir $oldpwd; |
| 35 |
$proc; |
| 36 |
} |
| 37 |
|
| 38 |
{ |
| 39 |
my $bin=$ENV{MTR_BINDIR} || '..'; |
| 40 |
return "Not run for embedded server" if $::opt_embedded_server; |
| 41 |
return "Not configured to run ctest" unless -f "$bin/CTestTestfile.cmake"; |
| 42 |
my ($ctest_vs)= $::multiconfig ? "-C ".substr($::multiconfig,1) : ""; |
| 43 |
my (@ctest_list)= `cd "$bin" && ctest $ctest_vs --show-only --verbose`; |
| 44 |
return "No ctest" if $?; |
| 45 |
|
| 46 |
$ENV{MYSQL_TEST_PLUGINDIR}=$::plugindir; |
| 47 |
|
| 48 |
my ($command, %tests, $prefix); |
| 49 |
for (@ctest_list) { |
| 50 |
chomp; |
| 51 |
if (/^\d+: Test command: +([^ \t]+.*)/) { |
| 52 |
$command= $1; |
| 53 |
$prefix= /libmariadb/ ? 'conc_' : ''; |
| 54 |
} elsif (/^ +Test +#\d+: ([^ \t]+.*)/) { |
| 55 |
if ($command ne "NOT_AVAILABLE" && $command ne "/bin/sh") { |
| 56 |
$tests{$prefix.$1}=$command; |
| 57 |
} |
| 58 |
} |
| 59 |
} |
| 60 |
bless { ctests => { %tests } }; |
| 61 |
} |