From: Bjorn Munch Date: February 7 2011 2:46pm Subject: bzr commit into mysql-5.5-mtr branch (bjorn.munch:3163) Bug#59789 List-Archive: http://lists.mysql.com/commits/130587 X-Bug: 59789 Message-Id: <201102071446.p17EksWB006048@khepri15.norway.sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1710500634==" --===============1710500634== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///home/bm136801/my/unit-55/ based on revid:bjorn.munch@stripped 3163 Bjorn Munch 2011-02-07 Bug #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 modified: mysql-test/lib/mtr_report.pm mysql-test/mysql-test-run.pl === modified file 'mysql-test/lib/mtr_report.pm' --- a/mysql-test/lib/mtr_report.pm 2011-01-18 10:21:37 +0000 +++ b/mysql-test/lib/mtr_report.pm 2011-02-07 14:43:32 +0000 @@ -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; } === modified file 'mysql-test/mysql-test-run.pl' --- a/mysql-test/mysql-test-run.pl 2011-01-29 21:53:17 +0000 +++ b/mysql-test/mysql-test-run.pl 2011-02-07 14:43:32 +0000 @@ -193,6 +193,10 @@ my $debug_d= "d"; my $opt_debug_common; 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; @@ -492,6 +496,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 ) { @@ -499,6 +507,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); @@ -1053,6 +1063,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 @@ -1480,6 +1491,12 @@ sub command_line_setup { } # -------------------------------------------------------------------------- + # Don't run ctest if tests or suites named + # -------------------------------------------------------------------------- + + $opt_ctest= 0 if $opt_ctest == -1 && ($opt_suites || @opt_cases); + + # -------------------------------------------------------------------------- # Check use of wait-all # -------------------------------------------------------------------------- @@ -5635,6 +5652,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 # @@ -5851,6 +5935,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. --===============1710500634== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/bjorn.munch@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: bjorn.munch@stripped # target_branch: file:///home/bm136801/my/unit-55/ # testament_sha1: 3c4237421bd5d2f8803d31ed2c40398fbbb501dd # timestamp: 2011-02-07 15:46:54 +0100 # base_revision_id: bjorn.munch@stripped\ # giug7o9nyhwzas7e # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWVeUJTMABCv/gHHwBAB95/// /3fehP////5gCg7vvd55u7Lw4KHvceuzd7u0O7dKcgSht1oaahGQSn+qeTTTQJ6mGmpianqabUAG hoA0NANqCUmkxGIaAhUeyaKfiSHqBp6mTQyAAAAaBojImjU1PTRqaaAANNBoAAAAADQAlMkIIaNT KmxTTaamDT1PVA9ExNNNANGQ0aPUAOGhk00NMjQ0yMgyMjQyAxNGTQBkyMQwkiJoAmp6GoMjJoRp p6QZTR+lGmQGTTQ0D1MSJAEyh0RF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