List:Commits« Previous MessageNext Message »
From:Bjorn Munch Date:February 21 2011 12:59pm
Subject:bzr commit into mysql-5.5-mtr branch (bjorn.munch:3168) Bug#11766640
View as plain text  
#At file:///home/bm136801/my/unit-55/ based on revid:bjorn.munch@stripped

 3168 Bjorn Munch	2011-02-21
      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

    modified:
      mysql-test/collections/default.daily
      mysql-test/collections/default.push
      mysql-test/collections/test-bt
      mysql-test/collections/test-bt-debug
      mysql-test/collections/test-bt-fast
      mysql-test/lib/mtr_report.pm
      mysql-test/mysql-test-run.pl
=== modified file 'mysql-test/collections/default.daily'
--- a/mysql-test/collections/default.daily	2011-02-08 11:55:42 +0000
+++ b/mysql-test/collections/default.daily	2011-02-21 12:56:43 +0000
@@ -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

=== modified file 'mysql-test/collections/default.push'
--- a/mysql-test/collections/default.push	2010-11-29 15:40:26 +0000
+++ b/mysql-test/collections/default.push	2011-02-21 12:56:43 +0000
@@ -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

=== modified file 'mysql-test/collections/test-bt'
--- a/mysql-test/collections/test-bt	2010-12-03 14:43:49 +0000
+++ b/mysql-test/collections/test-bt	2011-02-21 12:56:43 +0000
@@ -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

=== modified file 'mysql-test/collections/test-bt-debug'
--- a/mysql-test/collections/test-bt-debug	2010-12-03 14:43:49 +0000
+++ b/mysql-test/collections/test-bt-debug	2011-02-21 12:56:43 +0000
@@ -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

=== modified file 'mysql-test/collections/test-bt-fast'
--- a/mysql-test/collections/test-bt-fast	2010-12-03 14:43:49 +0000
+++ b/mysql-test/collections/test-bt-fast	2011-02-21 12:56:43 +0000
@@ -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

=== 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-21 12:56:43 +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-02-08 15:47:33 +0000
+++ b/mysql-test/mysql-test-run.pl	2011-02-21 12:56:43 +0000
@@ -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.


Attachment: [text/bzr-bundle] bzr/bjorn.munch@oracle.com-20110221125643-z6lj23i118cg0guq.bundle
Thread
bzr commit into mysql-5.5-mtr branch (bjorn.munch:3168) Bug#11766640Bjorn Munch21 Feb
  • RE: bzr commit into mysql-5.5-mtr branch (bjorn.munch:3168) Bug#11766640Vladislav Vaintroub21 Feb
    • Re: bzr commit into mysql-5.5-mtr branch (bjorn.munch:3168)Bug#11766640Bjorn Munch21 Feb