2011-07-16 09:59:15 +02:00
|
|
|
package My::Suite::CTest;
|
|
|
|
use Cwd;
|
|
|
|
|
|
|
|
@ISA = qw(My::Suite);
|
|
|
|
|
|
|
|
sub list_cases {
|
|
|
|
my ($self) = @_;
|
|
|
|
keys %{$self->{ctests}}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub start_test {
|
|
|
|
my ($self, $tinfo)= @_;
|
2013-09-26 18:02:17 +04:00
|
|
|
my $args;
|
|
|
|
my $path;
|
|
|
|
my $cmd = $self->{ctests}->{$tinfo->{shortname}};
|
|
|
|
|
|
|
|
if ($cmd =~ /[ "'><%!*?]/) {
|
|
|
|
($path, $args) = ('/bin/sh', [ '-c', $cmd ])
|
|
|
|
} else {
|
|
|
|
($path, $args) = ($cmd, , [ ])
|
|
|
|
}
|
|
|
|
|
2011-07-16 09:59:15 +02:00
|
|
|
|
|
|
|
my $oldpwd=getcwd();
|
|
|
|
chdir $::opt_vardir;
|
|
|
|
my $proc=My::SafeProcess->new
|
|
|
|
(
|
|
|
|
name => $tinfo->{shortname},
|
2013-09-26 18:02:17 +04:00
|
|
|
path => $path,
|
2011-07-16 09:59:15 +02:00
|
|
|
args => \$args,
|
|
|
|
append => 1,
|
|
|
|
output => $::path_current_testlog,
|
|
|
|
error => $::path_current_testlog,
|
|
|
|
);
|
|
|
|
chdir $oldpwd;
|
|
|
|
$proc;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2017-03-29 21:12:09 +02:00
|
|
|
my $bin=$ENV{MTR_BINDIR} || '..';
|
2011-10-19 23:01:15 +02:00
|
|
|
return "Not run for embedded server" if $::opt_embedded_server;
|
2017-03-29 21:12:09 +02:00
|
|
|
return "Not configured to run ctest" unless -f "$bin/CTestTestfile.cmake";
|
2018-06-20 23:30:49 +02:00
|
|
|
my ($ctest_vs)= $::opt_vs_config ? "-C ".substr($::opt_vs_config,1) : "";
|
2018-02-14 23:21:58 +00:00
|
|
|
my (@ctest_list)= `cd "$bin" && ctest $ctest_vs --show-only --verbose`;
|
2011-07-16 09:59:15 +02:00
|
|
|
return "No ctest" if $?;
|
|
|
|
|
2016-09-04 13:42:01 +02:00
|
|
|
my ($command, %tests, $prefix);
|
2011-07-16 09:59:15 +02:00
|
|
|
for (@ctest_list) {
|
|
|
|
chomp;
|
2016-09-04 13:42:01 +02:00
|
|
|
if (/^\d+: Test command: +/) {
|
|
|
|
$command= $';
|
|
|
|
$prefix= /libmariadb/ ? 'conc_' : '';
|
|
|
|
} elsif (/^ +Test +#\d+: +/) {
|
2018-02-14 23:21:58 +00:00
|
|
|
if ($command ne "NOT_AVAILABLE") {
|
|
|
|
$tests{$prefix.$'}=$command;
|
|
|
|
}
|
2016-09-04 13:42:01 +02:00
|
|
|
}
|
2011-07-16 09:59:15 +02:00
|
|
|
}
|
|
|
|
bless { ctests => { %tests } };
|
|
|
|
}
|