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

« back to all changes in this revision

Viewing changes to mysql-test/mtr

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 08:30:45 UTC
  • mfrom: (1.4.1)
  • Revision ID: package-import@ubuntu.com-20120222083045-2rd53r4bnyx7qus4
Tags: 5.1.61-0ubuntu0.11.04.1
* SECURITY UPDATE: Update to 5.1.61 to fix multiple security issues
  (LP: #937869)
  - http://www.oracle.com/technetwork/topics/security/cpujan2012-366304.html
  - CVE-2011-2262
  - CVE-2012-0075
  - CVE-2012-0112
  - CVE-2012-0113
  - CVE-2012-0114
  - CVE-2012-0115
  - CVE-2012-0116
  - CVE-2012-0117
  - CVE-2012-0118
  - CVE-2012-0119
  - CVE-2012-0120
  - CVE-2012-0484
  - CVE-2012-0485
  - CVE-2012-0486
  - CVE-2012-0487
  - CVE-2012-0488
  - CVE-2012-0489
  - CVE-2012-0490
  - CVE-2012-0491
  - CVE-2012-0492
  - CVE-2012-0493
  - CVE-2012-0494
  - CVE-2012-0495
  - CVE-2012-0496

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/perl
2
2
# -*- cperl -*-
3
3
 
 
4
# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 
5
#
 
6
# This program is free software; you can redistribute it and/or
 
7
# modify it under the terms of the GNU Library General Public
 
8
# License as published by the Free Software Foundation; version 2
 
9
# of the License.
 
10
#
 
11
# This program is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
# Library General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with this program; if not, write to the Free Software
 
18
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 
4
20
#
5
21
##############################################################################
6
22
#
166
182
my $opt_view_protocol;
167
183
 
168
184
our $opt_debug;
 
185
our $opt_debug_server;
169
186
our @opt_cases;                  # The test cases names in argv
170
187
our $opt_embedded_server;
171
188
 
239
256
 
240
257
our $opt_user = "root";
241
258
 
242
 
my $opt_valgrind= 0;
 
259
our $opt_valgrind= 0;
243
260
my $opt_valgrind_mysqld= 0;
244
261
my $opt_valgrind_mysqltest= 0;
245
262
my @default_valgrind_args= ("--show-reachable=yes");
569
586
            if ( !$opt_force ) {
570
587
              # Test has failed, force is off
571
588
              push(@$completed, $result);
572
 
              return $completed;
 
589
              return $completed unless $result->{'dont_kill_server'};
 
590
              # Prevent kill of server, to get valgrind report
 
591
              print $sock "BYE\n";
 
592
              next;
573
593
            }
574
594
            elsif ($opt_max_test_fail > 0 and
575
595
                   $num_failed_test >= $opt_max_test_fail) {
809
829
    elsif ($line eq 'BYE'){
810
830
      mtr_report("Server said BYE");
811
831
      stop_all_servers($opt_shutdown_timeout);
 
832
      my $valgrind_reports= 0;
812
833
      if ($opt_valgrind_mysqld) {
813
 
        valgrind_exit_reports();
 
834
        $valgrind_reports= valgrind_exit_reports();
814
835
      }
815
836
      if ( $opt_gprof ) {
816
837
        gprof_collect (find_mysqld($basedir), keys %gprof_dirs);
817
838
      }
818
 
      exit(0);
 
839
      exit($valgrind_reports);
819
840
    }
820
841
    else {
821
842
      mtr_error("Could not understand server, '$line'");
860
881
  my $opt_list_options;
861
882
 
862
883
  # Read the command line options
863
 
  # Note: Keep list, and the order, in sync with usage at end of this file
 
884
  # Note: Keep list in sync with usage at end of this file
864
885
  Getopt::Long::Configure("pass_through");
865
886
  my %options=(
866
887
             # Control what engine/variation to run
872
893
             'ssl|with-openssl'         => \$opt_ssl,
873
894
             'skip-ssl'                 => \$opt_skip_ssl,
874
895
             'compress'                 => \$opt_compress,
875
 
             'vs-config'                => \$opt_vs_config,
 
896
             'vs-config=s'              => \$opt_vs_config,
876
897
 
877
898
             # Max number of parallel threads to use
878
899
             'parallel=s'               => \$opt_parallel,
896
917
             'combination=s'            => \@opt_combinations,
897
918
             'skip-combinations'        => \&collect_option,
898
919
             'experimental=s'           => \@opt_experimentals,
 
920
             # skip-im is deprecated and silently ignored
899
921
             'skip-im'                  => \&ignore_option,
900
922
 
901
923
             # Specify ports
915
937
 
916
938
             # Debugging
917
939
             'debug'                    => \$opt_debug,
 
940
             'debug-server'             => \$opt_debug_server,
918
941
             'gdb'                      => \$opt_gdb,
919
942
             'client-gdb'               => \$opt_client_gdb,
920
943
             'manual-gdb'               => \$opt_manual_gdb,
988
1011
             'max-connections=i'        => \$opt_max_connections,
989
1012
 
990
1013
             'help|h'                   => \$opt_usage,
 
1014
             # list-options is internal, not listed in help
991
1015
               'list-options'             => \$opt_list_options,
992
1016
              );
993
1017
 
1060
1084
  my $path_share= dirname($path_language);
1061
1085
  $path_charsetsdir=   mtr_path_exists("$path_share/charsets");
1062
1086
 
 
1087
  # --debug implies we run debug server
 
1088
  $opt_debug_server= 1 if $opt_debug;
 
1089
 
1063
1090
  if (using_extern())
1064
1091
  {
1065
1092
    # Connect to the running mysqld and find out what it supports
1096
1123
        chomp;
1097
1124
        # remove comments (# foo) at the beginning of the line, or after a 
1098
1125
        # blank at the end of the line
1099
 
        s/( +|^)#.*$//;
 
1126
        s/(\s+|^)#.*$//;
1100
1127
        # If @ platform specifier given, use this entry only if it contains
1101
1128
        # @<platform> or @!<xxx> where xxx != platform
1102
1129
        if (/\@.*/)
1107
1134
          s/\@.*$//;
1108
1135
        }
1109
1136
        # remove whitespace
1110
 
        s/^ +//;              
1111
 
        s/ +$//;
 
1137
        s/^\s+//;
 
1138
        s/\s+$//;
1112
1139
        # if nothing left, don't need to remember this line
1113
1140
        if ( $_ eq "" ) {
1114
1141
          next;
1690
1717
  my @mysqld_names= ("mysqld", "mysqld-max-nt", "mysqld-max",
1691
1718
                     "mysqld-nt");
1692
1719
 
1693
 
  if ( $opt_debug ){
 
1720
  if ( $opt_debug_server ){
1694
1721
    # Put mysqld-debug first in the list of binaries to look for
1695
1722
    mtr_verbose("Adding mysqld-debug first in list of binaries to look for");
1696
1723
    unshift(@mysqld_names, "mysqld-debug");
1761
1788
sub client_debug_arg($$) {
1762
1789
  my ($args, $client_name)= @_;
1763
1790
 
 
1791
  # Workaround for Bug #50627: drop any debug opt
 
1792
  return if $client_name =~ /^mysqlbinlog/;
 
1793
 
1764
1794
  if ( $opt_debug ) {
1765
1795
    mtr_add_arg($args,
1766
 
                "--debug=d:t:A,%s/log/%s.trace",
 
1796
                "--loose-debug=d:t:A,%s/log/%s.trace",
1767
1797
                $path_vardir_trace, $client_name)
1768
1798
  }
1769
1799
}
1949
1979
    $ENV{'EXAMPLE_PLUGIN_LOAD'}="--plugin_load=EXAMPLE=".$plugin_filename;
1950
1980
  }
1951
1981
 
 
1982
  # --------------------------------------------------------------------------
 
1983
  # Add the path where mysqld will find ha_federated.so
 
1984
  # --------------------------------------------------------------------------
 
1985
  my $fedplug_filename;
 
1986
  if (IS_WINDOWS) {
 
1987
    $fedplug_filename = "ha_federated.dll";
 
1988
  } else {
 
1989
    $fedplug_filename = "ha_federated.so";
 
1990
  }
 
1991
  my $lib_fed_plugin=
 
1992
    mtr_file_exists(vs_config_dirs('storage/federated',$fedplug_filename),
 
1993
                    "$basedir/storage/federated/.libs/".$fedplug_filename,
 
1994
                    "$basedir/lib/mysql/plugin/".$fedplug_filename);
 
1995
 
 
1996
  $ENV{'FEDERATED_PLUGIN'}= $fedplug_filename;
 
1997
  $ENV{'FEDERATED_PLUGIN_DIR'}=
 
1998
    ($lib_fed_plugin ? dirname($lib_fed_plugin) : "");
 
1999
 
1952
2000
  # ----------------------------------------------------
1953
2001
  # Add the path where mysqld will find mypluglib.so
1954
2002
  # ----------------------------------------------------
2025
2073
  $ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'master-port'} || 3306;
2026
2074
  $ENV{'MYSQL_TMP_DIR'}=      $opt_tmpdir;
2027
2075
  $ENV{'MYSQLTEST_VARDIR'}=   $opt_vardir;
 
2076
  
 
2077
  if (IS_WINDOWS)
 
2078
  {
 
2079
    $ENV{'SECURE_LOAD_PATH'}= $glob_mysql_test_dir."\\std_data";
 
2080
  }
 
2081
  else
 
2082
  {
 
2083
    $ENV{'SECURE_LOAD_PATH'}= $glob_mysql_test_dir."/std_data";
 
2084
  }
 
2085
    
2028
2086
 
2029
2087
  # ----------------------------------------------------
2030
2088
  # Setup env for NDB
2072
2130
  $ENV{'MYSQL_FIX_SYSTEM_TABLES'}=  mysql_fix_arguments();
2073
2131
  $ENV{'EXE_MYSQL'}=                $exe_mysql;
2074
2132
 
 
2133
  my $exe_mysqld= find_mysqld($basedir);
 
2134
  $ENV{'MYSQLD'}= $exe_mysqld;
 
2135
  my $extra_opts= join (" ", @opt_extra_mysqld_opt);
 
2136
  $ENV{'MYSQLD_CMD'}= "$exe_mysqld --defaults-group-suffix=.1 ".
 
2137
    "--defaults-file=$path_config_file $extra_opts";
 
2138
 
2075
2139
  # ----------------------------------------------------
2076
2140
  # bug25714 executable may _not_ exist in
2077
2141
  # some versions, test using it should be skipped
2119
2183
  # mysqlhotcopy
2120
2184
  # ----------------------------------------------------
2121
2185
  my $mysqlhotcopy=
2122
 
    mtr_pl_maybe_exists("$basedir/scripts/mysqlhotcopy");
2123
 
  # Since mysqltest interprets the real path as "false" in an if,
2124
 
  # use 1 ("true") to indicate "not exists" so it can be tested for
2125
 
  $ENV{'MYSQLHOTCOPY'}= $mysqlhotcopy || 1;
 
2186
    mtr_pl_maybe_exists("$basedir/scripts/mysqlhotcopy") ||
 
2187
    mtr_pl_maybe_exists("$path_client_bindir/mysqlhotcopy");
 
2188
  if ($mysqlhotcopy)
 
2189
  {
 
2190
    $ENV{'MYSQLHOTCOPY'}= $mysqlhotcopy;
 
2191
  }
2126
2192
 
2127
2193
  # ----------------------------------------------------
2128
2194
  # perror
2375
2441
    #mtr_report(" - binaries are not debug compiled");
2376
2442
    $debug_compiled_binaries= 0;
2377
2443
 
2378
 
    if ( $opt_debug )
 
2444
    if ( $opt_debug_server )
2379
2445
    {
2380
 
      mtr_error("Can't use --debug, binaries does not support it");
 
2446
      mtr_error("Can't use --debug[-server], binary does not support it");
2381
2447
    }
2382
2448
    return;
2383
2449
  }
3354
3420
 
3355
3421
# The test can leave a file in var/tmp/ to signal
3356
3422
# that all servers should be restarted
3357
 
sub restart_forced_by_test
 
3423
sub restart_forced_by_test($)
3358
3424
{
 
3425
  my $file = shift;
3359
3426
  my $restart = 0;
3360
3427
  foreach my $mysqld ( mysqlds() )
3361
3428
  {
3362
3429
    my $datadir = $mysqld->value('datadir');
3363
 
    my $force_restart_file = "$datadir/mtr/force_restart";
 
3430
    my $force_restart_file = "$datadir/mtr/$file";
3364
3431
    if ( -f $force_restart_file )
3365
3432
    {
3366
3433
      mtr_verbose("Restart of servers forced by test");
3600
3667
      if ( $res == 0 )
3601
3668
      {
3602
3669
        my $check_res;
3603
 
        if ( restart_forced_by_test() )
 
3670
        if ( restart_forced_by_test('force_restart') )
3604
3671
        {
3605
3672
          stop_all_servers($opt_shutdown_timeout);
3606
3673
        }
3628
3695
        find_testcase_skipped_reason($tinfo);
3629
3696
        mtr_report_test_skipped($tinfo);
3630
3697
        # 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/);
 
3698
        if ( restart_forced_by_test('force_restart_if_skipped') ||
 
3699
             $tinfo->{'comment'} =~ /^perl not found/ )
 
3700
        {
 
3701
          stop_all_servers($opt_shutdown_timeout);
 
3702
        }
3633
3703
      }
3634
3704
      elsif ( $res == 65 )
3635
3705
      {
3680
3750
    # ----------------------------------------------------
3681
3751
    # Check if it was an expected crash
3682
3752
    # ----------------------------------------------------
3683
 
    SRVDIED:
3684
3753
    my $check_crash = check_expected_crash_and_restart($proc);
3685
3754
    if ($check_crash)
3686
3755
    {
3690
3759
      next;
3691
3760
    }
3692
3761
 
 
3762
  SRVDIED:
3693
3763
    # ----------------------------------------------------
3694
3764
    # Stop the test case timer
3695
3765
    # ----------------------------------------------------
3785
3855
      else
3786
3856
      {
3787
3857
        push(@lines, $line);
 
3858
        if (scalar(@lines) > 1000000) {
 
3859
          $Ferr = undef;
 
3860
          mtr_warning("Too much log from test, bailing out from extracting");
 
3861
          return ();
 
3862
        }
3788
3863
      }
3789
3864
    }
3790
3865
    else
4067
4142
    {
4068
4143
      mtr_verbose("Crash was expected, file '$expect_file' exists");
4069
4144
 
4070
 
      for (my $waits = 0;  $waits < 50;  $waits++)
 
4145
      for (my $waits = 0;  $waits < 50;  mtr_milli_sleep(100), $waits++)
4071
4146
      {
 
4147
        # Race condition seen on Windows: try again until file not empty
 
4148
        next if -z $expect_file;
4072
4149
        # If last line in expect file starts with "wait"
4073
4150
        # sleep a little and try again, thus allowing the
4074
4151
        # test script to control when the server should start
4077
4154
        if ($last_line =~ /^wait/ )
4078
4155
        {
4079
4156
          mtr_verbose("Test says wait before restart") if $waits == 0;
4080
 
          mtr_milli_sleep(100);
4081
4157
          next;
4082
4158
        }
4083
4159
 
 
4160
        # Ignore any partial or unknown command
 
4161
        next unless $last_line =~ /^restart/;
4084
4162
        # If last line begins "restart:", the rest of the line is read as
4085
4163
        # extra command line options to add to the restarted mysqld.
4086
4164
        # Anything other than 'wait' or 'restart:' (with a colon) will
4239
4317
sub report_failure_and_restart ($) {
4240
4318
  my $tinfo= shift;
4241
4319
 
4242
 
  stop_all_servers();
 
4320
  if ($opt_valgrind_mysqld && ($tinfo->{'warnings'} || $tinfo->{'timeout'})) {
 
4321
    # In these cases we may want valgrind report from normal termination
 
4322
    $tinfo->{'dont_kill_server'}= 1;
 
4323
  }
 
4324
  # Shotdown properly if not to be killed (for valgrind)
 
4325
  stop_all_servers($tinfo->{'dont_kill_server'} ? $opt_shutdown_timeout : 0);
4243
4326
 
4244
4327
  $tinfo->{'result'}= 'MTR_RES_FAILED';
4245
4328
 
4440
4523
  my @all_opts= @$extra_opts;
4441
4524
  if (exists $mysqld->{'restart_opts'}) {
4442
4525
    push (@all_opts, @{$mysqld->{'restart_opts'}});
 
4526
    mtr_verbose(My::Options::toStr("mysqld_start restart",
 
4527
                                   @{$mysqld->{'restart_opts'}}));
4443
4528
  }
4444
4529
  mysqld_arguments($args,$mysqld,\@all_opts);
4445
4530
 
4488
4573
  unlink($mysqld->value('pid-file'));
4489
4574
 
4490
4575
  my $output= $mysqld->value('#log-error');
4491
 
  if ( $opt_valgrind and $opt_debug )
4492
 
  {
4493
 
    # When both --valgrind and --debug is selected, send
4494
 
    # all output to the trace file, making it possible to
4495
 
    # see the exact location where valgrind complains
4496
 
    $output= "$opt_vardir/log/".$mysqld->name().".trace";
4497
 
  }
4498
4576
  # Remember this log file for valgrind error report search
4499
4577
  $mysqld_logs{$output}= 1 if $opt_valgrind;
4500
4578
  # Remember data dir for gmon.out files if using gprof
5366
5444
#
5367
5445
 
5368
5446
sub valgrind_exit_reports() {
 
5447
  my $found_err= 0;
 
5448
 
5369
5449
  foreach my $log_file (keys %mysqld_logs)
5370
5450
  {
5371
5451
    my @culprits= ();
5401
5481
        next;
5402
5482
      }
5403
5483
      # This line marks the start of a valgrind report
5404
 
      $found_report= 1 if $line =~ /ERROR SUMMARY:/;
 
5484
      $found_report= 1 if $line =~ /^==\d+== .* SUMMARY:/;
5405
5485
 
5406
5486
      if ($found_report) {
5407
5487
        $line=~ s/^==\d+== //;
5418
5498
      mtr_print ("Valgrind report from $log_file after tests:\n", @culprits);
5419
5499
      mtr_print_line();
5420
5500
      print ("$valgrind_rep\n");
 
5501
      $found_err= 1;
5421
5502
    }
5422
5503
  }
 
5504
 
 
5505
  return $found_err;
5423
5506
}
5424
5507
 
5425
5508
#
5453
5536
 
5454
5537
  defaults-file=<config template> Use fixed config template for all
5455
5538
                        tests
5456
 
  defaults_extra_file=<config template> Extra config template to add to
 
5539
  defaults-extra-file=<config template> Extra config template to add to
5457
5540
                        all generated configs
5458
5541
  combination=<opt>     Use at least twice to run tests with specified 
5459
5542
                        options to mysqld
5536
5619
  client-gdb            Start mysqltest client in gdb
5537
5620
  ddd                   Start mysqld in ddd
5538
5621
  debug                 Dump trace output for all servers and client programs
 
5622
  debug-server          Use debug version of server, but without turning on
 
5623
                        tracing
5539
5624
  debugger=NAME         Start mysqld in the selected debugger
5540
5625
  gdb                   Start the mysqld(s) in gdb
5541
5626
  manual-debug          Let user manually start mysqld in debugger, before
5544
5629
                        test(s)
5545
5630
  manual-ddd            Let user manually start mysqld in ddd, before running
5546
5631
                        test(s)
5547
 
  strace-client=[path]  Create strace output for mysqltest client, optionally
 
5632
  strace-client[=path]  Create strace output for mysqltest client, optionally
5548
5633
                        specifying name and path to the trace program to use.
5549
5634
                        Example: $0 --strace-client=ktrace
5550
5635
  max-save-core         Limit the number of core files saved (to avoid filling
5577
5662
Misc options
5578
5663
  user=USER             User for connecting to mysqld(default: $opt_user)
5579
5664
  comment=STR           Write STR to the output
5580
 
  notimer               Don't show test case execution time
 
5665
  timer                 Show test case execution time.
5581
5666
  verbose               More verbose output(use multiple times for even more)
5582
5667
  verbose-restart       Write when and why servers are restarted
5583
5668
  start                 Only initialize and start the servers, using the
5617
5702
                        actions. Disable facility with NUM=0.
5618
5703
  gcov                  Collect coverage information after the test.
5619
5704
                        The result is a gcov file per source and header file.
 
5705
  gprof                 Collect profiling information using gprof.
5620
5706
  experimental=<file>   Refer to list of tests considered experimental;
5621
5707
                        failures will be marked exp-fail instead of fail.
5622
5708
  report-features       First run a "test" that reports mysql features
5625
5711
                        *previous* test started
5626
5712
  max-connections=N     Max number of open connection to server in mysqltest
5627
5713
 
 
5714
Some options that control enabling a feature for normal test runs,
 
5715
can be turned off by prepending 'no' to the option, e.g. --notimer.
 
5716
This applies to reorder, timer, check-testcases and warnings.
 
5717
 
5628
5718
HERE
5629
5719
  exit(1);
5630
5720