~ubuntu-branches/ubuntu/natty/mysql-5.1/natty-security

« back to all changes in this revision

Viewing changes to mysql-test/mtr

Tags: 5.1.54-1ubuntu1
* Synchronize from Debian Experimental:
* Merge from debian unstable:
  + debian/control:
     * Update maintainer according to spec.
     * Move section from "misc" to "database".
     * Added libmysqlclient16-dev an empty transitional package. 
     * Added mysql-client-core-5.1 package.
     * Suggest mailx for mysql-server-5.1
     * Add mysql-testsuite package so you can run the testsuite seperately.
  + debian/additions/my.cnf:
    * Remove language options. Error message files are located in a different directory in Mysql
      5.0. Setting the language option to use /usr/share/mysql/english breaks Mysql 5.0. Both 5.0
      and 5.1 use a different value that works. (LP: #316974)
  + Add apparmor profile:
    + debian/apparmor-profile: apparmor-profile
    + debian/rules, debian/mysql-server-5.1.files: install apparmor profile
    + debian/mysql-server-5.1.dirs: add etc/apparmor.d/fore-complain
    + debian/mysql-server-5.1.postrm: remove symlink in force-complain/ on purge.
    + debian/mysql-server-5.1.README.Debian: add apparmor documentation.
    + debian/additions/my.cnf: Add warning about apparmor. (LP: #201799)
    + debian/mysql-server-5.1.postinst: reload apparmor profiles
  * Convert the package from sysvinit to upstart:
    + debian/mysql-server-5.1.mysql.upstart: Add upstart script.
    + debian/mysql-server-5.1.mysql.init: Dropped, unused now with upstart.
    + debian/additions/mysqld_safe_syslog.cnf: Dropped, unused now with upstart.
    + debian/additons/my.cnf: Remove pid declaration and setup error logging to /var/log/mysql since
      we're not piping anything around logger anymore.
    + debian/rules, debian/mysql-server-5.1.logcheck.ignore.{paranoid,worstation},
      debian/mysql-server-5.1.logcheck.ignore.server: : Remove references to mysqld_safe
    + debian/patches/38_scripts_mysqld_safe.sh_signals.dpatch: Dropped
  * Added -fno-strict-aliasing to CFLAGS to get around mysql testsuite build failures.
  * Add Apport hook (LP: #354188):
    + debian/mysql-server-5.1.py: apport package hook
    + debian/rules: Make it installable
  * debian/mysql-server-5.1.mysql-server.logrotate: Check to see if mysql is running before
    running logrotate. (LP: #513135)
  * Make the testsuite installable. (LP: #530752)
    + debian/mysql-server-5.1.files, debian/rules: install apport package hook
  * debian/mysql-server-5.1.preinst: Set mysql user's home directory
    to /nonexistent to protect against having the /var/lib/mysql
    user-writeable. If an attacker can trick mysqld into creating
    dot files in the home directory, he could do .rhost-like attacks
    on the system. (LP: #293258)
  * debian/control: mysql-client-5.1 should depend on mysql-core-client-5.1.
    (LP: #590952)
  * debian/mysql-server.5.1.postinst: Specify the mysql user when installing 
    the mysql databases. (LP: #591875)
  * Installing mysql_config_pic in /usr/bin so users of libmysqld-pic
    can extract the appropriate compile flags. (LP: #605021) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
110
110
my $opt_tmpdir;                 # Path to use for tmp/ dir
111
111
my $opt_tmpdir_pid;
112
112
 
 
113
my $opt_start;
 
114
my $opt_start_dirty;
 
115
my $opt_start_exit;
 
116
my $start_only;
 
117
 
113
118
END {
114
119
  if ( defined $opt_tmpdir_pid and $opt_tmpdir_pid == $$ )
115
120
  {
116
 
    # Remove the tempdir this process has created
117
 
    mtr_verbose("Removing tmpdir '$opt_tmpdir");
118
 
    rmtree($opt_tmpdir);
 
121
    if (!$opt_start_exit)
 
122
    {
 
123
      # Remove the tempdir this process has created
 
124
      mtr_verbose("Removing tmpdir $opt_tmpdir");
 
125
      rmtree($opt_tmpdir);
 
126
    }
 
127
    else
 
128
    {
 
129
      mtr_warning("tmpdir $opt_tmpdir should be removed after the server has finished");
 
130
    }
119
131
  }
120
132
}
121
133
 
187
199
my $config; # The currently running config
188
200
my $current_config_name; # The currently running config file template
189
201
 
190
 
our $opt_experimental;
191
 
our $experimental_test_cases;
 
202
our @opt_experimentals;
 
203
our $experimental_test_cases= [];
192
204
 
193
205
my $baseport;
194
206
# $opt_build_thread may later be set from $opt_port_base
212
224
my $opt_shutdown_timeout= $ENV{MTR_SHUTDOWN_TIMEOUT} ||  10; # seconds
213
225
my $opt_start_timeout   = $ENV{MTR_START_TIMEOUT}    || 180; # seconds
214
226
 
215
 
sub testcase_timeout { return $opt_testcase_timeout * 60; };
216
227
sub suite_timeout { return $opt_suite_timeout * 60; };
217
228
sub check_timeout { return $opt_testcase_timeout * 6; };
218
229
 
219
 
my $opt_start;
220
 
my $opt_start_dirty;
221
 
my $start_only;
222
230
my $opt_wait_all;
 
231
my $opt_user_args;
223
232
my $opt_repeat= 1;
224
233
my $opt_retry= 3;
225
234
my $opt_retry_failure= env_or_val(MTR_RETRY_FAILURE => 2);
226
235
my $opt_reorder= 1;
 
236
my $opt_force_restart= 0;
227
237
 
228
238
my $opt_strace_client;
229
239
 
239
249
my %mysqld_logs;
240
250
my $opt_debug_sync_timeout= 300; # Default timeout for WAIT_FOR actions.
241
251
 
 
252
sub testcase_timeout ($) {
 
253
  my ($tinfo)= @_;
 
254
  if (exists $tinfo->{'case-timeout'}) {
 
255
    # Return test specific timeout if *longer* that the general timeout
 
256
    my $test_to= $tinfo->{'case-timeout'};
 
257
    $test_to*= 10 if $opt_valgrind;
 
258
    return $test_to * 60 if $test_to > $opt_testcase_timeout;
 
259
  }
 
260
  return $opt_testcase_timeout * 60;
 
261
}
 
262
 
242
263
our $opt_warnings= 1;
243
264
 
244
 
our $opt_skip_ndbcluster= 0;
 
265
our $opt_include_ndbcluster= 0;
 
266
our $opt_skip_ndbcluster= 1;
245
267
 
246
268
my $exe_ndbd;
247
269
my $exe_ndb_mgmd;
345
367
    mtr_report("Using parallel: $opt_parallel");
346
368
  }
347
369
 
 
370
  if ($opt_parallel > 1 && $opt_start_exit) {
 
371
    mtr_warning("Parallel and --start-and-exit cannot be combined\n" .
 
372
               "Setting parallel to 1");
 
373
    $opt_parallel= 1;
 
374
  }
 
375
 
348
376
  # Create server socket on any free port
349
377
  my $server = new IO::Socket::INET
350
378
    (
384
412
 
385
413
  my $completed= run_test_server($server, $tests, $opt_parallel);
386
414
 
 
415
  exit(0) if $opt_start_exit;
 
416
 
387
417
  # Send Ctrl-C to any children still running
388
418
  kill("INT", keys(%children));
389
419
 
557
587
          if ($test_has_failed and $retries <= $opt_retry){
558
588
            # Test should be run one more time unless it has failed
559
589
            # too many times already
 
590
            my $tname= $result->{name};
560
591
            my $failures= $result->{failures};
561
592
            if ($opt_retry > 1 and $failures >= $opt_retry_failure){
562
 
              mtr_report("\nTest has failed $failures times,",
 
593
              mtr_report("\nTest $tname has failed $failures times,",
563
594
                         "no more retries!\n");
564
595
            }
565
596
            else {
566
 
              mtr_report("\nRetrying test, attempt($retries/$opt_retry)...\n");
 
597
              mtr_report("\nRetrying test $tname, ".
 
598
                         "attempt($retries/$opt_retry)...\n");
567
599
              delete($result->{result});
568
600
              $result->{retries}= $retries+1;
569
601
              $result->write_test($sock, 'TESTCASE');
631
663
            next;
632
664
          }
633
665
 
634
 
          # Prefer same configuration, or just use next if --noreorder
635
 
          if (!$opt_reorder or (defined $result and
636
 
              $result->{template_path} eq $t->{template_path}))
637
 
          {
638
 
            #mtr_report("Test uses same config => good match");
639
 
            # Test uses same config => good match
640
 
            $next= splice(@$tests, $i, 1);
641
 
            last;
642
 
          }
643
 
 
644
666
          # Second best choice is the first that does not fulfill
645
667
          # any of the above conditions
646
668
          if (!defined $second_best){
647
669
            #mtr_report("Setting second_best to $i");
648
670
            $second_best= $i;
649
671
          }
 
672
 
 
673
          # Smart allocation of next test within this thread.
 
674
 
 
675
          if ($opt_reorder and $opt_parallel > 1 and defined $result)
 
676
          {
 
677
            my $wid= $result->{worker};
 
678
            # Reserved for other thread, try next
 
679
            next if (defined $t->{reserved} and $t->{reserved} != $wid);
 
680
            if (! defined $t->{reserved})
 
681
            {
 
682
              # Force-restart not relevant when comparing *next* test
 
683
              $t->{criteria} =~ s/force-restart$/no-restart/;
 
684
              my $criteria= $t->{criteria};
 
685
              # Reserve similar tests for this worker, but not too many
 
686
              my $maxres= (@$tests - $i) / $opt_parallel + 1;
 
687
              for (my $j= $i+1; $j <= $i + $maxres; $j++)
 
688
              {
 
689
                my $tt= $tests->[$j];
 
690
                last unless defined $tt;
 
691
                last if $tt->{criteria} ne $criteria;
 
692
                $tt->{reserved}= $wid;
 
693
              }
 
694
            }
 
695
          }
 
696
 
 
697
          # At this point we have found next suitable test
 
698
          $next= splice(@$tests, $i, 1);
 
699
          last;
650
700
        }
651
701
 
652
702
        # Use second best choice if no other test has been found
655
705
          mtr_error("Internal error, second best too large($second_best)")
656
706
            if $second_best >  $#$tests;
657
707
          $next= splice(@$tests, $second_best, 1);
 
708
          delete $next->{reserved};
658
709
        }
659
710
 
660
711
        if ($next) {
661
 
          #$next->print_test();
 
712
          # We don't need this any more
 
713
          delete $next->{criteria};
662
714
          $next->write_test($sock, 'TESTCASE');
663
715
          $running{$next->key()}= $next;
664
716
          $num_ndb_tests++ if ($next->{ndb_test});
741
793
      delete($test->{'comment'});
742
794
      delete($test->{'logfile'});
743
795
 
 
796
      # A sanity check. Should this happen often we need to look at it.
 
797
      if (defined $test->{reserved} && $test->{reserved} != $thread_num) {
 
798
        my $tres= $test->{reserved};
 
799
        mtr_warning("Test reserved for w$tres picked up by w$thread_num");
 
800
      }
744
801
      $test->{worker} = $thread_num if $opt_parallel > 1;
745
802
 
746
803
      run_testcase($test);
828
885
             # Control what test suites or cases to run
829
886
             'force'                    => \$opt_force,
830
887
             'with-ndbcluster-only'     => \&collect_option,
 
888
             'include-ndbcluster'       => \$opt_include_ndbcluster,
831
889
             'skip-ndbcluster|skip-ndb' => \$opt_skip_ndbcluster,
832
890
             'suite|suites=s'           => \$opt_suites,
833
891
             'skip-rpl'                 => \&collect_option,
837
895
             'big-test'                 => \$opt_big_test,
838
896
             'combination=s'            => \@opt_combinations,
839
897
             'skip-combinations'        => \&collect_option,
840
 
             'experimental=s'           => \$opt_experimental,
 
898
             'experimental=s'           => \@opt_experimentals,
841
899
             'skip-im'                  => \&ignore_option,
842
900
 
843
901
             # Specify ports
904
962
             'report-features'          => \$opt_report_features,
905
963
             'comment=s'                => \$opt_comment,
906
964
             'fast'                     => \$opt_fast,
 
965
             'force-restart'            => \$opt_force_restart,
907
966
             'reorder!'                 => \$opt_reorder,
908
967
             'enable-disabled'          => \&collect_option,
909
968
             'verbose+'                 => \$opt_verbose,
910
969
             'verbose-restart'          => \&report_option,
911
970
             'sleep=i'                  => \$opt_sleep,
912
971
             'start-dirty'              => \$opt_start_dirty,
 
972
             'start-and-exit'           => \$opt_start_exit,
913
973
             'start'                    => \$opt_start,
 
974
             'user-args'                => \$opt_user_args,
914
975
             'wait-all'                 => \$opt_wait_all,
915
976
             'print-testcases'          => \&collect_option,
916
977
             'repeat=i'                 => \$opt_repeat,
1018
1079
    mtr_print_thick_line('#');
1019
1080
  }
1020
1081
 
1021
 
  if ( $opt_experimental )
 
1082
  if ( @opt_experimentals )
1022
1083
  {
1023
1084
    # $^O on Windows considered not generic enough
1024
1085
    my $plat= (IS_WINDOWS) ? 'windows' : $^O;
1025
1086
 
1026
 
    # read the list of experimental test cases from the file specified on
 
1087
    # read the list of experimental test cases from the files specified on
1027
1088
    # the command line
1028
 
    open(FILE, "<", $opt_experimental) or mtr_error("Can't read experimental file: $opt_experimental");
1029
 
    mtr_report("Using experimental file: $opt_experimental");
1030
1089
    $experimental_test_cases = [];
1031
 
    while(<FILE>) {
1032
 
      chomp;
1033
 
      # remove comments (# foo) at the beginning of the line, or after a 
1034
 
      # blank at the end of the line
1035
 
      s/( +|^)#.*$//;
1036
 
      # If @ platform specifier given, use this entry only if it contains
1037
 
      # @<platform> or @!<xxx> where xxx != platform
1038
 
      if (/\@.*/)
1039
 
      {
1040
 
        next if (/\@!$plat/);
1041
 
        next unless (/\@$plat/ or /\@!/);
1042
 
        # Then remove @ and everything after it
1043
 
        s/\@.*$//;
1044
 
      }
1045
 
      # remove whitespace
1046
 
      s/^ +//;              
1047
 
      s/ +$//;
1048
 
      # if nothing left, don't need to remember this line
1049
 
      if ( $_ eq "" ) {
1050
 
        next;
1051
 
      }
1052
 
      # remember what is left as the name of another test case that should be
1053
 
      # treated as experimental
1054
 
      print " - $_\n";
1055
 
      push @$experimental_test_cases, $_;
 
1090
    foreach my $exp_file (@opt_experimentals)
 
1091
    {
 
1092
      open(FILE, "<", $exp_file)
 
1093
        or mtr_error("Can't read experimental file: $exp_file");
 
1094
      mtr_report("Using experimental file: $exp_file");
 
1095
      while(<FILE>) {
 
1096
        chomp;
 
1097
        # remove comments (# foo) at the beginning of the line, or after a 
 
1098
        # blank at the end of the line
 
1099
        s/( +|^)#.*$//;
 
1100
        # If @ platform specifier given, use this entry only if it contains
 
1101
        # @<platform> or @!<xxx> where xxx != platform
 
1102
        if (/\@.*/)
 
1103
        {
 
1104
          next if (/\@!$plat/);
 
1105
          next unless (/\@$plat/ or /\@!/);
 
1106
          # Then remove @ and everything after it
 
1107
          s/\@.*$//;
 
1108
        }
 
1109
        # remove whitespace
 
1110
        s/^ +//;              
 
1111
        s/ +$//;
 
1112
        # if nothing left, don't need to remember this line
 
1113
        if ( $_ eq "" ) {
 
1114
          next;
 
1115
        }
 
1116
        # remember what is left as the name of another test case that should be
 
1117
        # treated as experimental
 
1118
        print " - $_\n";
 
1119
        push @$experimental_test_cases, $_;
 
1120
      }
 
1121
      close FILE;
1056
1122
    }
1057
 
    close FILE;
1058
1123
  }
1059
1124
 
1060
1125
  foreach my $arg ( @ARGV )
1316
1381
  # --------------------------------------------------------------------------
1317
1382
  # Modified behavior with --start options
1318
1383
  # --------------------------------------------------------------------------
1319
 
  if ($opt_start or $opt_start_dirty) {
 
1384
  if ($opt_start or $opt_start_dirty or $opt_start_exit) {
1320
1385
    collect_option ('quick-collect', 1);
1321
1386
    $start_only= 1;
1322
1387
  }
1323
1388
 
1324
1389
  # --------------------------------------------------------------------------
 
1390
  # Check use of user-args
 
1391
  # --------------------------------------------------------------------------
 
1392
 
 
1393
  if ($opt_user_args) {
 
1394
    mtr_error("--user-args only valid with --start options")
 
1395
      unless $start_only;
 
1396
    mtr_error("--user-args cannot be combined with named suites or tests")
 
1397
      if $opt_suites || @opt_cases;
 
1398
  }
 
1399
 
 
1400
  # --------------------------------------------------------------------------
1325
1401
  # Check use of wait-all
1326
1402
  # --------------------------------------------------------------------------
1327
1403
 
1328
1404
  if ($opt_wait_all && ! $start_only)
1329
1405
  {
1330
 
    mtr_error("--wait-all can only be used with --start or --start-dirty");
 
1406
    mtr_error("--wait-all can only be used with --start options");
1331
1407
  }
1332
1408
 
1333
1409
  # --------------------------------------------------------------------------
2060
2136
  # to detect that valgrind is being used from test cases
2061
2137
  $ENV{'VALGRIND_TEST'}= $opt_valgrind;
2062
2138
 
 
2139
  # Add dir of this perl to aid mysqltest in finding perl
 
2140
  my $perldir= dirname($^X);
 
2141
  my $pathsep= ":";
 
2142
  $pathsep= ";" if IS_WINDOWS && ! IS_CYGWIN;
 
2143
  $ENV{'PATH'}= "$ENV{'PATH'}".$pathsep.$perldir;
2063
2144
}
2064
2145
 
2065
2146
 
2335
2416
sub check_ndbcluster_support ($) {
2336
2417
  my $mysqld_variables= shift;
2337
2418
 
 
2419
  if ($opt_include_ndbcluster)
 
2420
  {
 
2421
    $opt_skip_ndbcluster= 0;
 
2422
  }
 
2423
 
2338
2424
  if ($opt_skip_ndbcluster)
2339
2425
  {
2340
2426
    mtr_report(" - skipping ndbcluster");
2741
2827
  my $config= My::ConfigFactory->new_config
2742
2828
    ( {
2743
2829
       basedir         => $basedir,
 
2830
       testdir         => $glob_mysql_test_dir,
2744
2831
       template_path   => "include/default_my.cnf",
2745
2832
       vardir          => $opt_vardir,
2746
2833
       tmpdir          => $opt_tmpdir,
2987
3074
  my %started;
2988
3075
  foreach my $mysqld ( mysqlds() )
2989
3076
  {
2990
 
    if ( defined $mysqld->{'proc'} )
 
3077
    # Skip if server has been restarted with additional options
 
3078
    if ( defined $mysqld->{'proc'} && ! exists $mysqld->{'restart_opts'} )
2991
3079
    {
2992
3080
      my $proc= start_check_testcase($tinfo, $mode, $mysqld);
2993
3081
      $started{$proc->pid()}= $proc;
3040
3128
            "\nMTR's internal check of the test case '$tname' failed.
3041
3129
This means that the test case does not preserve the state that existed
3042
3130
before the test case was executed.  Most likely the test case did not
3043
 
do a proper clean-up.
 
3131
do a proper clean-up. It could also be caused by the previous test run
 
3132
by this thread, if the server wasn't restarted.
3044
3133
This is the diff of the states of the servers before and after the
3045
3134
test case was executed:\n";
3046
3135
          $tinfo->{check}.= $report;
3082
3171
    # Kill any check processes still running
3083
3172
    map($_->kill(), values(%started));
3084
3173
 
 
3174
    mtr_warning("Check-testcase failed, this could also be caused by the" .
 
3175
                " previous test run by this worker thread")
 
3176
      if $result > 1 && $mode eq "before";
 
3177
 
3085
3178
    return $result;
3086
3179
  }
3087
3180
 
3349
3442
      $config= My::ConfigFactory->new_config
3350
3443
        ( {
3351
3444
           basedir         => $basedir,
 
3445
           testdir         => $glob_mysql_test_dir,
3352
3446
           template_path   => $tinfo->{template_path},
3353
3447
           extra_template_path => $tinfo->{extra_template_path},
3354
3448
           vardir          => $opt_vardir,
3409
3503
      mtr_print ($mysqld->name() . "  " . $mysqld->value('port') .
3410
3504
              "  " . $mysqld->value('socket'));
3411
3505
    }
 
3506
    if ( $opt_start_exit )
 
3507
    {
 
3508
      mtr_print("Server(s) started, not waiting for them to finish");
 
3509
      if (IS_WINDOWS)
 
3510
      {
 
3511
        POSIX::_exit(0);        # exit hangs here in ActiveState Perl
 
3512
      }
 
3513
      else
 
3514
      {
 
3515
        exit(0);
 
3516
      }
 
3517
    }
3412
3518
    mtr_print("Waiting for server(s) to exit...");
3413
3519
    if ( $opt_wait_all ) {
3414
3520
      My::SafeProcess->wait_all();
3427
3533
    }
3428
3534
  }
3429
3535
 
3430
 
  my $test_timeout= start_timer(testcase_timeout());
 
3536
  my $test_timeout= start_timer(testcase_timeout($tinfo));
3431
3537
 
3432
3538
  do_before_run_mysqltest($tinfo);
3433
3539
 
3521
3627
        # Try to get reason from test log file
3522
3628
        find_testcase_skipped_reason($tinfo);
3523
3629
        mtr_report_test_skipped($tinfo);
 
3630
        # Restart if skipped due to missing perl, it may have had side effects
 
3631
        stop_all_servers($opt_shutdown_timeout)
 
3632
          if ($tinfo->{'comment'} =~ /^perl not found/);
3524
3633
      }
3525
3634
      elsif ( $res == 65 )
3526
3635
      {
3627
3736
    {
3628
3737
      my $log_file_name= $opt_vardir."/log/".$tinfo->{shortname}.".log";
3629
3738
      $tinfo->{comment}=
3630
 
        "Test case timeout after ".testcase_timeout().
 
3739
        "Test case timeout after ".testcase_timeout($tinfo).
3631
3740
          " seconds\n\n";
3632
3741
      # Add 20 last executed commands from test case log file
3633
3742
      if  (-e $log_file_name)
3636
3745
           "== $log_file_name == \n".
3637
3746
             mtr_lastlinesfromfile($log_file_name, 20)."\n";
3638
3747
      }
3639
 
      $tinfo->{'timeout'}= testcase_timeout(); # Mark as timeout
 
3748
      $tinfo->{'timeout'}= testcase_timeout($tinfo); # Mark as timeout
3640
3749
      run_on_all($tinfo, 'analyze-timeout');
3641
3750
 
3642
3751
      report_failure_and_restart($tinfo);
3719
3828
  foreach my $mysqld (mysqlds()) {
3720
3829
    if ($mysqld->{proc} eq $proc) {
3721
3830
      my @srv_lines= extract_server_log($mysqld->value('#log-error'), $name);
3722
 
      $srv_log= "\nServer log from this test:\n" . join ("", @srv_lines);
 
3831
      $srv_log= "\nServer log from this test:\n" .
 
3832
        "----------SERVER LOG START-----------\n". join ("", @srv_lines) .
 
3833
        "----------SERVER LOG END-------------\n";
3723
3834
      last;
3724
3835
    }
3725
3836
  }
3759
3870
    if ($opt_valgrind_mysqld) {
3760
3871
      # Skip valgrind summary from tests where server has been restarted
3761
3872
      # Should this contain memory leaks, the final report will find it
3762
 
      $skip_valgrind= 1 if $line =~ /^==\d+== ERROR SUMMARY:/;
 
3873
      # Use a generic pattern for summaries
 
3874
      $skip_valgrind= 1 if $line =~ /^==\d+== [A-Z ]+ SUMMARY:/;
3763
3875
      $skip_valgrind= 0 unless $line =~ /^==\d+==/;
3764
3876
      next if $skip_valgrind;
3765
3877
    }
3969
4081
          next;
3970
4082
        }
3971
4083
 
 
4084
        # If last line begins "restart:", the rest of the line is read as
 
4085
        # extra command line options to add to the restarted mysqld.
 
4086
        # Anything other than 'wait' or 'restart:' (with a colon) will
 
4087
        # result in a restart with original mysqld options.
 
4088
        if ($last_line =~ /restart:(.+)/) {
 
4089
          my @rest_opt= split(' ', $1);
 
4090
          $mysqld->{'restart_opts'}= \@rest_opt;
 
4091
        } else {
 
4092
          delete $mysqld->{'restart_opts'};
 
4093
        }
3972
4094
        unlink($expect_file);
3973
4095
 
3974
4096
        # Start server with same settings as last time
4239
4361
    }
4240
4362
  }
4241
4363
 
4242
 
  if ( $mysql_version_id >= 50106 )
 
4364
  if ( $mysql_version_id >= 50106 && !$opt_user_args)
4243
4365
  {
4244
4366
    # Turn on logging to file
4245
4367
    mtr_add_arg($args, "--log-output=file");
4277
4399
    }
4278
4400
  }
4279
4401
  $opt_skip_core = $found_skip_core;
4280
 
  if ( !$found_skip_core )
 
4402
  if ( !$found_skip_core && !$opt_user_args )
4281
4403
  {
4282
4404
    mtr_add_arg($args, "%s", "--core-file");
4283
4405
  }
4285
4407
  # Enable the debug sync facility, set default wait timeout.
4286
4408
  # Facility stays disabled if timeout value is zero.
4287
4409
  mtr_add_arg($args, "--loose-debug-sync-timeout=%s",
4288
 
              $opt_debug_sync_timeout);
 
4410
              $opt_debug_sync_timeout) unless $opt_user_args;
4289
4411
 
4290
4412
  return $args;
4291
4413
}
4313
4435
  }
4314
4436
 
4315
4437
  mtr_add_arg($args, "--defaults-group-suffix=%s", $mysqld->after('mysqld'));
4316
 
  mysqld_arguments($args,$mysqld,$extra_opts);
 
4438
 
 
4439
  # Add any additional options from an in-test restart
 
4440
  my @all_opts= @$extra_opts;
 
4441
  if (exists $mysqld->{'restart_opts'}) {
 
4442
    push (@all_opts, @{$mysqld->{'restart_opts'}});
 
4443
  }
 
4444
  mysqld_arguments($args,$mysqld,\@all_opts);
4317
4445
 
4318
4446
  if ( $opt_debug )
4319
4447
  {
4443
4571
    return 1;
4444
4572
  }
4445
4573
 
 
4574
  if ( $opt_force_restart ) {
 
4575
    mtr_verbose_restart($server, "forced restart turned on");
 
4576
    return 1;
 
4577
  }
 
4578
 
4446
4579
  if ( $tinfo->{template_path} ne $current_config_name)
4447
4580
  {
4448
4581
    mtr_verbose_restart($server, "using different config file");
4474
4607
    }
4475
4608
  }
4476
4609
 
4477
 
  # Temporary re-enable the "always restart slave" hack
4478
 
  # this should be removed asap, but will require that each rpl
4479
 
  # testcase cleanup better after itself - ie. stop and reset
4480
 
  # replication
4481
 
  # Use the "#!use-slave-opt" marker to detect that this is a "slave"
4482
 
  # server
4483
 
  if ( $server->option("#!use-slave-opt") ){
4484
 
    mtr_verbose_restart($server, "Always restart slave(s)");
4485
 
    return 1;
4486
 
  }
4487
 
 
4488
4610
  my $is_mysqld= grep ($server eq $_, mysqlds());
4489
4611
  if ($is_mysqld)
4490
4612
  {
4494
4616
    my $extra_opts= get_extra_opts($server, $tinfo);
4495
4617
    my $started_opts= $server->{'started_opts'};
4496
4618
 
4497
 
    if (!My::Options::same($started_opts, $extra_opts) )
 
4619
    # Also, always restart if server had been restarted with additional
 
4620
    # options within test.
 
4621
    if (!My::Options::same($started_opts, $extra_opts) ||
 
4622
        exists $server->{'restart_opts'})
4498
4623
    {
4499
4624
      my $use_dynamic_option_switch= 0;
4500
4625
      if (!$use_dynamic_option_switch)
4583
4708
 
4584
4709
 
4585
4710
sub get_extra_opts {
 
4711
  # No extra options if --user-args
 
4712
  return \@opt_extra_mysqld_opt if $opt_user_args;
 
4713
 
4586
4714
  my ($mysqld, $tinfo)= @_;
4587
4715
 
4588
4716
  my $opts=
4653
4781
sub start_servers($) {
4654
4782
  my ($tinfo)= @_;
4655
4783
 
 
4784
  # Make sure the safe_process also exits from now on
 
4785
  # Could not be done before, as we don't want this for the bootstrap
 
4786
  if ($opt_start_exit) {
 
4787
    My::SafeProcess->start_exit();
 
4788
  }
 
4789
 
4656
4790
  # Start clusters
4657
4791
  foreach my $cluster ( clusters() )
4658
4792
  {
5345
5479
 
5346
5480
  force                 Continue to run the suite after failure
5347
5481
  with-ndbcluster-only  Run only tests that include "ndb" in the filename
5348
 
  skip-ndb[cluster]     Skip all tests that need cluster
 
5482
  skip-ndb[cluster]     Skip all tests that need cluster. Default.
 
5483
  include-ndb[cluster]  Enable all tests that need cluster
5349
5484
  do-test=PREFIX or REGEX
5350
5485
                        Run test cases which name are prefixed with PREFIX
5351
5486
                        or fulfills REGEX
5449
5584
                        startup settings for the first specified test case
5450
5585
                        Example:
5451
5586
                         $0 --start alias &
 
5587
  start-and-exit        Same as --start, but mysql-test-run terminates and
 
5588
                        leaves just the server running
5452
5589
  start-dirty           Only start the servers (without initialization) for
5453
5590
                        the first specified test case
 
5591
  user-args             In combination with start* and no test name, drops
 
5592
                        arguments to mysqld except those speficied with
 
5593
                        --mysqld (if any)
5454
5594
  wait-all              If --start or --start-dirty option is used, wait for all
5455
5595
                        servers to exit before finishing the process
5456
5596
  fast                  Run as fast as possible, dont't wait for servers
5457
5597
                        to shutdown etc.
 
5598
  force-restart         Always restart servers between tests
5458
5599
  parallel=N            Run tests in N parallel threads (default=1)
5459
5600
                        Use parallel=auto for auto-setting of N
5460
5601
  repeat=N              Run each test N number of times