diff options
author | Bjorn Munch <bjorn.munch@oracle.com> | 2011-02-21 13:56:43 +0100 |
---|---|---|
committer | Bjorn Munch <bjorn.munch@oracle.com> | 2011-02-21 13:56:43 +0100 |
commit | 2c4f6e5c632f02880490191f5a8ea407f4d35ade (patch) | |
tree | 996faa658cd4d6655682a62a444ee70e355c0838 /mysql-test | |
parent | 6746a5dc0fdd2f9b8bd33ad8bc48cd844eaa50d5 (diff) | |
download | mariadb-git-2c4f6e5c632f02880490191f5a8ea407f4d35ade.tar.gz |
Bug #11766640 (59789) Hook the invocation of unit tests in MTR.
Added code to call 'ctest' if the needed cmake file is present
Will do so unless tests/suited named on mtr command line
Also add option to turn on/off
Will be made to look like a test 'unit-test' which counts towards total
Extracts summary report and any test failures from ctest output
Addendum: added override to turn off in PB, add back in selected invocations
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/collections/default.daily | 2 | ||||
-rw-r--r-- | mysql-test/collections/default.push | 2 | ||||
-rw-r--r-- | mysql-test/collections/test-bt | 2 | ||||
-rw-r--r-- | mysql-test/collections/test-bt-debug | 2 | ||||
-rw-r--r-- | mysql-test/collections/test-bt-fast | 2 | ||||
-rw-r--r-- | mysql-test/lib/mtr_report.pm | 2 | ||||
-rwxr-xr-x | mysql-test/mysql-test-run.pl | 89 |
7 files changed, 95 insertions, 6 deletions
diff --git a/mysql-test/collections/default.daily b/mysql-test/collections/default.daily index 75c03d4d47b..b1f3b97ae20 100644 --- a/mysql-test/collections/default.daily +++ b/mysql-test/collections/default.daily @@ -1,5 +1,5 @@ -perl mysql-test-run.pl --force --timer --debug-server --parallel=auto --experimental=collections/default.experimental --comment=normal --vardir=var-normal --report-features +perl mysql-test-run.pl --force --timer --debug-server --parallel=auto --experimental=collections/default.experimental --comment=normal --vardir=var-normal --report-features --unit-tests perl mysql-test-run.pl --force --timer --debug-server --parallel=auto --experimental=collections/default.experimental --comment=n_mix --vardir=var-n_mix --mysqld=--binlog-format=mixed perl mysql-test-run.pl --force --timer --debug-server --parallel=auto --experimental=collections/default.experimental --comment=row --vardir=var-row --mysqld=--binlog-format=row perl mysql-test-run.pl --force --timer --debug-server --parallel=auto --experimental=collections/default.experimental --comment=ps_row --vardir=var-ps_row --mysqld=--binlog-format=row --ps-protocol diff --git a/mysql-test/collections/default.push b/mysql-test/collections/default.push index a213706498e..c8402aecd75 100644 --- a/mysql-test/collections/default.push +++ b/mysql-test/collections/default.push @@ -1,4 +1,4 @@ -perl mysql-test-run.pl --timer --force --parallel=auto --comment=n_mix --vardir=var-n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list +perl mysql-test-run.pl --timer --force --parallel=auto --comment=n_mix --vardir=var-n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list --unit-tests perl mysql-test-run.pl --timer --force --parallel=auto --comment=ps_row --vardir=var-ps_row --ps-protocol --mysqld=--binlog-format=row --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list perl mysql-test-run.pl --timer --force --parallel=auto --comment=embedded --vardir=var-emebbed --embedded --experimental=collections/default.experimental --skip-ndb perl mysql-test-run.pl --timer --force --parallel=auto --comment=rpl_binlog_row --vardir=var-rpl_binlog_row --suite=rpl,binlog --mysqld=--binlog-format=row --experimental=collections/default.experimental --skip-ndb --skip-test-list=collections/disabled-per-push.list diff --git a/mysql-test/collections/test-bt b/mysql-test/collections/test-bt index 58f0c2c3cde..f35d2213769 100644 --- a/mysql-test/collections/test-bt +++ b/mysql-test/collections/test-bt @@ -1,4 +1,4 @@ -perl mysql-test-run.pl --force --timer --parallel=auto --comment=normal --skip-ndbcluster --report-features --experimental=collections/default.experimental +perl mysql-test-run.pl --force --timer --parallel=auto --comment=normal --skip-ndbcluster --report-features --experimental=collections/default.experimental --unit-tests perl mysql-test-run.pl --force --timer --parallel=auto --comment=ps --skip-ndbcluster --ps-protocol --experimental=collections/default.experimental perl mysql-test-run.pl --force --timer --parallel=auto --comment=funcs1+ps --suite=funcs_1 --ps-protocol --experimental=collections/default.experimental perl mysql-test-run.pl --force --timer --parallel=auto --comment=funcs2 --suite=funcs_2 --experimental=collections/default.experimental diff --git a/mysql-test/collections/test-bt-debug b/mysql-test/collections/test-bt-debug index 5fc1e15e0d2..ffb9f07b69f 100644 --- a/mysql-test/collections/test-bt-debug +++ b/mysql-test/collections/test-bt-debug @@ -1 +1 @@ -perl mysql-test-run.pl --force --timer --parallel=auto --comment=debug --skip-ndbcluster --skip-rpl --report-features --experimental=collections/default.experimental +perl mysql-test-run.pl --force --timer --parallel=auto --comment=debug --skip-ndbcluster --skip-rpl --report-features --experimental=collections/default.experimental --unit-tests diff --git a/mysql-test/collections/test-bt-fast b/mysql-test/collections/test-bt-fast index 7978c8082f0..de1bdc687cb 100644 --- a/mysql-test/collections/test-bt-fast +++ b/mysql-test/collections/test-bt-fast @@ -1,2 +1,2 @@ -perl mysql-test-run.pl --force --timer --parallel=auto --comment=ps --skip-ndbcluster --ps-protocol --report-features --experimental=collections/default.experimental +perl mysql-test-run.pl --force --timer --parallel=auto --comment=ps --skip-ndbcluster --ps-protocol --report-features --experimental=collections/default.experimental --unit-tests perl mysql-test-run.pl --force --timer --parallel=auto --comment=stress --suite=stress --experimental=collections/default.experimental diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm index f86be0d4c68..dcf83260720 100644 --- a/mysql-test/lib/mtr_report.pm +++ b/mysql-test/lib/mtr_report.pm @@ -72,7 +72,7 @@ sub _mtr_report_test_name ($) { print _name(). _timestamp(); printf "%-40s ", $tname; my $worker = $tinfo->{worker}; - printf "w$worker " if $worker; + print "w$worker " if defined $worker; return $tname; } diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index a1e02a56164..05bfd4eae02 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -194,6 +194,10 @@ 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; @@ -493,6 +497,10 @@ sub main { mtr_error("Not all tests completed"); } + mark_time_used('init'); + + push @$completed, run_ctest() if $opt_ctest; + mtr_print_line(); if ( $opt_gcov ) { @@ -500,6 +508,8 @@ sub main { $opt_gcov_msg, $opt_gcov_err); } + print "$ctest_report\n" if $ctest_report; + print_total_times($opt_parallel) if $opt_report_times; mtr_report_stats("Completed", $completed); @@ -1055,6 +1065,7 @@ sub command_line_setup { 'max-connections=i' => \$opt_max_connections, 'default-myisam!' => \&collect_option, 'report-times' => \$opt_report_times, + 'unit-tests!' => \$opt_ctest, 'help|h' => \$opt_usage, # list-options is internal, not listed in help @@ -1485,6 +1496,14 @@ sub command_line_setup { } # -------------------------------------------------------------------------- + # 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 # -------------------------------------------------------------------------- @@ -5653,6 +5672,73 @@ 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; + + # Just ignore if not configured/built to run ctest + if (! -f "CTestTestfile.cmake") { + chdir($olddir); + return; + } + + # Also silently ignore if we don't have ctest and didn't insist + # Now, run ctest and collect output + my $ctest_out= `ctest 2>&1`; + if ($? == $no_ctest && $opt_ctest == -1) { + 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\n"; + $tinfo->{failures}= ($tinfo->{result} eq 'MTR_RES_FAILED'); + + mark_time_used('test'); + mtr_report_test($tinfo); + chdir($olddir); + return $tinfo; +} + # # Usage # @@ -5871,6 +5957,9 @@ 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. |