1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

move ctest handling from mtr to a separate suite

This commit is contained in:
Sergei Golubchik
2011-07-16 09:59:15 +02:00
parent 73a46b3eb9
commit 011cbe9088
7 changed files with 116 additions and 209 deletions

View File

@@ -162,7 +162,7 @@ our $opt_vs_config = $ENV{'MTR_VS_CONFIG'};
# If you add a new suite, please check TEST_DIRS in Makefile.am.
#
my $DEFAULT_SUITES= "main,sys_vars,binlog,federated,rpl,innodb,perfschema,maria,parts,percona,vcol,oqgraph,sphinx,pbxt";
my $DEFAULT_SUITES= "main,sys_vars,binlog,federated,rpl,innodb,perfschema,maria,parts,percona,vcol,oqgraph,sphinx,pbxt,unit";
my $opt_suites;
our $opt_verbose= 0; # Verbose output, enable with --verbose
@@ -196,10 +196,6 @@ my $opt_debug_common;
our $opt_debug_server;
our @opt_cases; # The test cases names in argv
our $opt_embedded_server;
# -1 indicates use default, override with env.var.
my $opt_ctest= env_or_val(MTR_UNIT_TESTS => -1);
# Unit test report stored here for delayed printing
my $ctest_report;
# Options used when connecting to an already running server
my %opts_extern;
@@ -542,10 +538,6 @@ sub main {
mtr_report("Only ", int(@$completed), " of $num_tests completed.");
}
mark_time_used('init');
push @$completed, run_ctest() if $opt_ctest;
if ($opt_valgrind) {
# Create minimalistic "test" for the reporting
my $tinfo = My::Test->new
@@ -572,11 +564,6 @@ sub main {
$opt_gcov_msg, $opt_gcov_err);
}
if ($ctest_report) {
print "$ctest_report\n";
mtr_print_line();
}
print_total_times($opt_parallel) if $opt_report_times;
mtr_report_stats($prefix, $fail, $completed, $extra_warnings);
@@ -1237,7 +1224,6 @@ sub command_line_setup {
'default-myisam!' => \&collect_option,
'report-times' => \$opt_report_times,
'result-file' => \$opt_resfile,
'unit-tests!' => \$opt_ctest,
'help|h' => \$opt_usage,
# list-options is internal, not listed in help
@@ -1680,14 +1666,6 @@ sub command_line_setup {
if $opt_suites || @opt_cases;
}
# --------------------------------------------------------------------------
# Don't run ctest if tests or suites named
# --------------------------------------------------------------------------
$opt_ctest= 0 if $opt_ctest == -1 && ($opt_suites || @opt_cases);
# Override: disable if running in the PB test environment
$opt_ctest= 0 if $opt_ctest == -1 && defined $ENV{PB2WORKDIR};
# --------------------------------------------------------------------------
# Check use of wait-all
# --------------------------------------------------------------------------
@@ -3643,16 +3621,6 @@ sub do_before_run_mysqltest($)
unlink("$base_file.log");
unlink("$base_file.warnings");
}
if ( $mysql_version_id < 50000 ) {
# Set environment variable NDB_STATUS_OK to 1
# if script decided to run mysqltest cluster _is_ installed ok
$ENV{'NDB_STATUS_OK'} = "1";
} elsif ( $mysql_version_id < 50100 ) {
# Set environment variable NDB_STATUS_OK to YES
# if script decided to run mysqltest cluster _is_ installed ok
$ENV{'NDB_STATUS_OK'} = "YES";
}
}
@@ -4163,6 +4131,7 @@ sub run_testcase ($$) {
# Write config files:
my %config_files = config_files($tinfo);
while (my ($file, $generate) = each %config_files) {
next unless $generate;
my ($path) = "$opt_vardir/$file";
open (F, '>', $path) or die "Could not open '$path': $!";
print F &$generate($config);
@@ -4262,7 +4231,7 @@ sub run_testcase ($$) {
return 1;
}
my $test= start_mysqltest($tinfo);
my $test= $suites{$tinfo->{suite}}->start_test($tinfo);
# Set only when we have to keep waiting after expectedly died server
my $keep_waiting_proc = 0;
@@ -6181,79 +6150,6 @@ sub valgrind_exit_reports() {
return $found_err;
}
sub run_ctest() {
my $olddir= getcwd();
chdir ($bindir) or die ("Could not chdir to $bindir");
my $tinfo;
my $no_ctest= (IS_WINDOWS) ? 256 : -1;
my $ctest_vs= "";
# Just ignore if not configured/built to run ctest
if (! -f "CTestTestfile.cmake") {
chdir($olddir);
return;
}
# Add vs-config option if needed
$ctest_vs= "-C $opt_vs_config" if $opt_vs_config;
# Also silently ignore if we don't have ctest and didn't insist
# Special override: also ignore in Pushbuild, some platforms may not have it
# Now, run ctest and collect output
my $ctest_out= `ctest $ctest_vs 2>&1`;
if ($? == $no_ctest && $opt_ctest == -1 && ! defined $ENV{PB2WORKDIR}) {
chdir($olddir);
return;
}
# Create minimalistic "test" for the reporting
$tinfo = My::Test->new
(
name => 'unit_tests',
);
# Set dummy worker id to align report with normal tests
$tinfo->{worker} = 0 if $opt_parallel > 1;
my $ctfail= 0; # Did ctest fail?
if ($?) {
$ctfail= 1;
$tinfo->{result}= 'MTR_RES_FAILED';
$tinfo->{comment}= "ctest failed with exit code $?, see result below";
$ctest_out= "" unless $ctest_out;
}
my $ctfile= "$opt_vardir/ctest.log";
my $ctres= 0; # Did ctest produce report summary?
open (CTEST, " > $ctfile") or die ("Could not open output file $ctfile");
# Put ctest output in log file, while analyzing results
for (split ('\n', $ctest_out)) {
print CTEST "$_\n";
if (/tests passed/) {
$ctres= 1;
$ctest_report .= "\nUnit tests: $_\n";
}
if ( /FAILED/ or /\(Failed\)/ ) {
$ctfail= 1;
$ctest_report .= " $_\n";
}
}
close CTEST;
# Set needed 'attributes' for test reporting
$tinfo->{comment}.= "\nctest did not pruduce report summary" if ! $ctres;
$tinfo->{result}= ($ctres && !$ctfail)
? 'MTR_RES_PASSED' : 'MTR_RES_FAILED';
$ctest_report .= "Report from unit tests in $ctfile";
$tinfo->{failures}= ($tinfo->{result} eq 'MTR_RES_FAILED');
mark_time_used('test');
mtr_report_test($tinfo);
chdir($olddir);
return $tinfo;
}
#
# Usage
#
@@ -6500,9 +6396,6 @@ Misc options
engine to InnoDB.
report-times Report how much time has been spent on different
phases of test execution.
nounit-tests Do not run unit tests. Normally run if configured
and if not running named tests/suites
unit-tests Run unit tests even if they would otherwise not be run
Some options that control enabling a feature for normal test runs,
can be turned off by prepending 'no' to the option, e.g. --notimer.