~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/test-run.pl

  • Committer: Brian Aker
  • Date: 2009-07-11 19:23:04 UTC
  • mfrom: (1089.1.14 merge)
  • Revision ID: brian@gaz-20090711192304-ootijyl5yf9jq9kd
Merge Brian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/perl
2
2
# -*- cperl -*-
3
3
 
 
4
use utf8;
 
5
 
4
6
#
5
7
##############################################################################
6
8
#
8
10
#
9
11
#  Tool used for executing a suite of .test file
10
12
#
11
 
#  See the "MySQL Test framework manual" for more information
12
 
#  http://dev.mysql.com/doc/drizzletest/en/index.html
 
13
#  For now, see the "MySQL Test framework manual" for more information
 
14
#  http://dev.mysql.com/doc/mysqltest/en/index.html
 
15
#  (as the Drizzle test environment is currently still fairly similar)
13
16
#
14
17
#  Please keep the test framework tools identical in all versions!
15
18
#
62
65
use File::Basename;
63
66
use File::Copy;
64
67
use File::Temp qw /tempdir/;
65
 
use File::Spec::Functions qw /splitdir/;
 
68
use File::Spec::Functions qw /splitdir catpath catdir
 
69
                              updir curdir splitpath rel2abs/;
66
70
use Cwd;
67
71
use Getopt::Long;
68
72
use IO::Socket;
101
105
our $glob_timers=                 undef;
102
106
our @glob_test_mode;
103
107
 
 
108
our $glob_builddir;
 
109
 
104
110
our $glob_basedir;
105
111
 
106
 
our $path_charsetsdir;
107
112
our $path_client_bindir;
108
 
our $path_share;
109
113
our $path_timefile;
110
114
our $path_snapshot;
111
115
our $path_drizzletest_log;
115
119
our $opt_vardir;                 # A path but set directly on cmd line
116
120
our $path_vardir_trace;          # unix formatted opt_vardir for trace files
117
121
our $opt_tmpdir;                 # A path but set directly on cmd line
 
122
our $opt_testdir;
118
123
 
119
124
 
120
125
our $default_vardir;
121
126
 
122
127
our $opt_usage;
123
128
our $opt_suites;
124
 
our $opt_suites_default= "main,binlog,rpl"; # Default suites to run
 
129
our $opt_suites_default= "main"; # Default suites to run
125
130
our $opt_script_debug= 0;  # Script debugging, enable with --script-debug
126
131
our $opt_verbose= 0;  # Verbose output, enable with --verbose
127
132
 
 
133
our $opt_repeat_test= 1;
 
134
 
128
135
our $exe_master_mysqld;
129
136
our $exe_drizzle;
130
 
our $exe_drizzleadmin;
131
 
our $exe_drizzlebinlog;
132
137
our $exe_drizzle_client_test;
133
138
our $exe_bug25714;
134
139
our $exe_drizzled;
135
140
our $exe_drizzlecheck;
136
141
our $exe_drizzledump;
137
 
our $exe_mysqlslap;
 
142
our $exe_drizzleslap;
138
143
our $exe_drizzleimport;
139
144
our $exe_drizzle_fix_system_tables;
140
145
our $exe_drizzletest;
147
152
 
148
153
our $opt_bench= 0;
149
154
our $opt_small_bench= 0;
150
 
our $opt_big_test= 0;
151
155
 
152
156
our @opt_combinations;
153
157
our $opt_skip_combination;
159
163
our $opt_debug;
160
164
our $opt_do_test;
161
165
our @opt_cases;                  # The test cases names in argv
 
166
our $opt_engine;
162
167
 
163
168
our $opt_extern= 0;
164
169
our $opt_socket;
181
186
our $opt_manual_gdb;
182
187
our $opt_manual_ddd;
183
188
our $opt_manual_debug;
184
 
our $opt_mtr_build_thread=0;
 
189
# Magic number -69.4 results in traditional test ports starting from 9306.
 
190
our $opt_mtr_build_thread=-69.4;
185
191
our $opt_debugger;
186
192
our $opt_client_debugger;
187
193
 
201
207
our $opt_check_testcases;
202
208
our $opt_mark_progress;
203
209
 
204
 
our $opt_skip_rpl;
 
210
our $opt_skip_rpl= 1;
205
211
our $max_slave_num= 0;
206
212
our $max_master_num= 1;
207
213
our $use_innodb;
244
250
 
245
251
our $opt_warnings;
246
252
 
247
 
our $opt_skip_master_binlog= 0;
248
 
our $opt_skip_slave_binlog= 0;
249
 
 
250
253
our $path_sql_dir;
251
254
 
252
255
our @data_dir_lst;
253
256
 
254
 
our $used_binlog_format;
255
257
our $used_default_engine;
256
258
our $debug_compiled_binaries;
257
259
 
295
297
sub mysqld_arguments ($$$$);
296
298
sub stop_all_servers ();
297
299
sub run_drizzletest ($);
 
300
sub collapse_path ($);
298
301
sub usage ($);
299
302
 
300
303
 
420
423
 
421
424
  my $opt_comment;
422
425
 
423
 
  # Magic number -69.4 results in traditional test ports starting from 9306.
424
 
  set_mtr_build_thread_ports(-69.4);
425
 
 
426
426
  # If so requested, we try to avail ourselves of a unique build thread number.
427
427
  if ( $ENV{'MTR_BUILD_THREAD'} ) {
428
428
    if ( lc($ENV{'MTR_BUILD_THREAD'}) eq 'auto' ) {
464
464
 
465
465
             # Control what test suites or cases to run
466
466
             'force'                    => \$opt_force,
467
 
             'skip-master-binlog'       => \$opt_skip_master_binlog,
468
 
             'skip-slave-binlog'        => \$opt_skip_slave_binlog,
469
467
             'do-test=s'                => \$opt_do_test,
470
468
             'start-from=s'             => \$opt_start_from,
471
469
             'suite|suites=s'           => \$opt_suites,
472
470
             'skip-rpl'                 => \$opt_skip_rpl,
473
471
             'skip-test=s'              => \$opt_skip_test,
474
 
             'big-test'                 => \$opt_big_test,
475
472
             'combination=s'            => \@opt_combinations,
476
473
             'skip-combination'         => \$opt_skip_combination,
477
474
 
487
484
 
488
485
             # Extra options used when starting mysqld
489
486
             'mysqld=s'                 => \@opt_extra_mysqld_opt,
 
487
             'engine=s'                 => \$opt_engine,
490
488
 
491
489
             # Run test on running server
492
490
             'extern'                   => \$opt_extern,
541
539
             # Directories
542
540
             'tmpdir=s'                 => \$opt_tmpdir,
543
541
             'vardir=s'                 => \$opt_vardir,
 
542
             'testdir=s'                => \$opt_testdir,
544
543
             'benchdir=s'               => \$glob_mysql_bench_dir,
545
544
             'mem'                      => \$opt_mem,
546
545
 
562
561
             'testcase-timeout=i'       => \$opt_testcase_timeout,
563
562
             'suite-timeout=i'          => \$opt_suite_timeout,
564
563
             'warnings|log-warnings'    => \$opt_warnings,
 
564
             'repeat-test=i'            => \$opt_repeat_test,
565
565
 
566
566
             # Options which are no longer used
567
567
             (map { $_ => \&warn_about_removed_option } @removed_options),
582
582
    $opt_mtr_build_thread= $ENV{'MTR_BUILD_THREAD'};
583
583
  }
584
584
 
585
 
  # We require that we are in the "mysql-test" directory
586
 
  # to run drizzle-test-run
587
 
  if (! -f $glob_scriptname)
588
 
  {
589
 
    mtr_error("Can't find the location for the drizzle-test-run script\n" .
590
 
              "Go to to the mysql-test directory and execute the script " .
591
 
              "as follows:\n./$glob_scriptname");
592
 
  }
593
 
 
594
585
  if ( -d "../drizzled" )
595
586
  {
596
587
    $source_dist=  1;
597
588
  }
598
589
 
599
590
  # Find the absolute path to the test directory
600
 
  $glob_mysql_test_dir=  cwd();
 
591
  if ( ! $opt_testdir )
 
592
  {
 
593
    $glob_mysql_test_dir=  cwd();
 
594
  } 
 
595
  else
 
596
  {
 
597
    $glob_mysql_test_dir= $opt_testdir;
 
598
  }
601
599
  $default_vardir= "$glob_mysql_test_dir/var";
602
600
 
603
601
  # In most cases, the base directory we find everything relative to,
615
613
    $glob_basedir= dirname($glob_basedir);
616
614
  }
617
615
 
 
616
  if ( $opt_testdir and -d $opt_testdir and $opt_vardir and -d $opt_vardir
 
617
         and -f "$opt_vardir/../../drizzled/drizzled")
 
618
  {
 
619
    # probably in a VPATH build
 
620
    $glob_builddir= "$opt_vardir/../..";
 
621
  }
 
622
  else
 
623
  {
 
624
    $glob_builddir="..";
 
625
  }
 
626
 
618
627
  # Expect mysql-bench to be located adjacent to the source tree, by default
619
628
  $glob_mysql_bench_dir= "$glob_basedir/../mysql-bench"
620
629
    unless defined $glob_mysql_bench_dir;
632
641
  #
633
642
 
634
643
  # Look for the client binaries directory
635
 
  $path_client_bindir= mtr_path_exists("$glob_basedir/client",
 
644
  $path_client_bindir= mtr_path_exists("$glob_builddir/client",
 
645
                                       "$glob_basedir/client",
636
646
                                       "$glob_basedir/bin");
637
647
 
638
 
  # Look for charsetsdir, use same share
639
 
  $path_share=      mtr_path_exists("$glob_basedir/share/mysql",
640
 
                                    "$glob_basedir/drizzled/share",
641
 
                                    "$glob_basedir/share");
642
 
 
643
 
  $path_charsetsdir=   mtr_path_exists("$path_share/charsets");
644
 
 
645
 
 
646
 
 
647
648
  if (!$opt_extern)
648
649
  {
649
650
    $exe_drizzled=       mtr_exe_exists ("$glob_basedir/drizzled/drizzled",
650
651
                                       "$path_client_bindir/drizzled",
651
652
                                       "$glob_basedir/libexec/drizzled",
652
653
                                       "$glob_basedir/bin/drizzled",
653
 
                                       "$glob_basedir/sbin/drizzled");
 
654
                                       "$glob_basedir/sbin/drizzled",
 
655
                                       "$glob_builddir/drizzled/drizzled");
654
656
 
655
657
    # Use the mysqld found above to find out what features are available
656
658
    collect_mysqld_features();
660
662
    $mysqld_variables{'port'}= 4427;
661
663
  }
662
664
 
 
665
  if (!$opt_engine)
 
666
  {
 
667
    $opt_engine= "innodb";
 
668
  }
 
669
 
663
670
  if ( $opt_comment )
664
671
  {
665
672
    print "\n";
691
698
  }
692
699
 
693
700
  # --------------------------------------------------------------------------
694
 
  # Find out type of logging that are being used
695
 
  # --------------------------------------------------------------------------
696
 
  if (!$opt_extern && $mysql_version_id >= 50100 )
697
 
  {
698
 
    foreach my $arg ( @opt_extra_mysqld_opt )
699
 
    {
700
 
      if ( $arg =~ /binlog[-_]format=(\S+)/ )
701
 
      {
702
 
        $used_binlog_format= $1;
703
 
      }
704
 
    }
705
 
    if (defined $used_binlog_format) 
706
 
    {
707
 
      mtr_report("Using binlog format '$used_binlog_format'");
708
 
    }
709
 
    else
710
 
    {
711
 
      mtr_report("Using dynamic switching of binlog format");
712
 
    }
713
 
  }
714
 
 
715
 
 
716
 
  # --------------------------------------------------------------------------
717
701
  # Find out default storage engine being used(if any)
718
702
  # --------------------------------------------------------------------------
719
703
  foreach my $arg ( @opt_extra_mysqld_opt )
760
744
  {
761
745
    $opt_vardir= $default_vardir;
762
746
  }
763
 
  elsif ( $mysql_version_id < 50000 and
764
 
          $opt_vardir ne $default_vardir)
765
 
  {
766
 
    # Version 4.1 and --vardir was specified
767
 
    # Only supported as a symlink from var/
768
 
    # by setting up $opt_mem that symlink will be created
769
 
    {
770
 
      # Only platforms that have native symlinks can use the vardir trick
771
 
      $opt_mem= $opt_vardir;
772
 
      mtr_report("Using 4.1 vardir trick");
773
 
    }
774
 
 
775
 
    $opt_vardir= $default_vardir;
776
 
  }
777
747
 
778
748
  $path_vardir_trace= $opt_vardir;
779
749
  # Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/...
780
750
  $path_vardir_trace=~ s/^\w://;
781
751
 
782
 
  # We make the path absolute, as the server will do a chdir() before usage
783
 
  unless ( $opt_vardir =~ m,^/,)
784
 
  {
785
 
    # Make absolute path, relative test dir
786
 
    $opt_vardir= "$glob_mysql_test_dir/$opt_vardir";
787
 
  }
 
752
  $opt_vardir= collapse_path($opt_vardir);
788
753
 
789
754
  # --------------------------------------------------------------------------
790
755
  # Set tmpdir
814
779
  }
815
780
 
816
781
  # --------------------------------------------------------------------------
817
 
  # Big test flags
818
 
  # --------------------------------------------------------------------------
819
 
   if ( $opt_big_test )
820
 
   {
821
 
     $ENV{'BIG_TEST'}= 1;
822
 
   }
823
 
 
824
 
  # --------------------------------------------------------------------------
825
782
  # Gcov flag
826
783
  # --------------------------------------------------------------------------
827
784
  if ( $opt_gcov and ! $source_dist )
1069
1026
    print "got ".$mtr_build_thread."\n";
1070
1027
  }
1071
1028
 
 
1029
  $mtr_build_thread= (($mtr_build_thread * 10) % 2000) - 1000;
 
1030
 
1072
1031
  # Up to two masters, up to three slaves
1073
1032
  # A magic value in command_line_setup depends on these equations.
1074
 
  $opt_master_myport=         $mtr_build_thread * 10 + 10000; # and 1
 
1033
  $opt_master_myport=         $mtr_build_thread + 9000; # and 1
1075
1034
  $opt_slave_myport=          $opt_master_myport + 2;  # and 3 4
1076
1035
 
1077
1036
  if ( $opt_master_myport < 5001 or $opt_master_myport + 10 >= 32767 )
1187
1146
  mtr_init_args(\$args);
1188
1147
 
1189
1148
  mtr_add_arg($args, "--no-defaults");
 
1149
  mtr_add_arg($args, "--skip-stack-trace");
1190
1150
  mtr_add_arg($args, "--user=%s", $opt_user);
1191
1151
  mtr_add_arg($args, "--port=%d", $mysqld->{'port'});
1192
1152
  mtr_add_arg($args, "--silent"); # Tab separated output
1234
1194
  $exe_my_print_defaults=
1235
1195
    mtr_exe_exists(
1236
1196
        "$path_client_bindir/my_print_defaults",
1237
 
        "$glob_basedir/extra/my_print_defaults");
 
1197
        "$glob_basedir/extra/my_print_defaults",
 
1198
        "$glob_builddir/extra/my_print_defaults");
1238
1199
 
1239
1200
# Look for perror
1240
1201
  $exe_perror= "perror";
1243
1204
  $exe_drizzlecheck= mtr_exe_exists("$path_client_bindir/drizzlecheck");
1244
1205
  $exe_drizzledump= mtr_exe_exists("$path_client_bindir/drizzledump");
1245
1206
  $exe_drizzleimport= mtr_exe_exists("$path_client_bindir/drizzleimport");
1246
 
  $exe_drizzlebinlog= mtr_exe_exists("$path_client_bindir/drizzlebinlog");
1247
 
  $exe_drizzleadmin= mtr_exe_exists("$path_client_bindir/drizzleadmin");
1248
1207
  $exe_drizzle=          mtr_exe_exists("$path_client_bindir/drizzle");
1249
1208
 
1250
1209
  if (!$opt_extern)
1251
1210
  {
1252
1211
# Look for SQL scripts directory
1253
 
    if ( $mysql_version_id >= 50100 )
1254
 
    {
1255
 
      $exe_mysqlslap= mtr_exe_exists("$path_client_bindir/mysqlslap");
1256
 
    }
 
1212
     if ( $mysql_version_id >= 50100 )
 
1213
     {
 
1214
         $exe_drizzleslap= mtr_exe_exists("$path_client_bindir/drizzleslap");
 
1215
     }
1257
1216
  }
1258
1217
 
1259
1218
# Look for drizzletest executable
1340
1299
  # --------------------------------------------------------------------------
1341
1300
  if ( $source_dist )
1342
1301
  {
1343
 
    push(@ld_library_paths, "$glob_basedir/libmysql/.libs/",
1344
 
                            "$glob_basedir/libmysql_r/.libs/",
1345
 
                            "$glob_basedir/zlib.libs/");
 
1302
    push(@ld_library_paths, "$glob_basedir/libdrizzleclient/.libs/",
 
1303
                            "$glob_basedir/mysys/.libs/",
 
1304
                            "$glob_basedir/mystrings/.libs/",
 
1305
                            "$glob_basedir/drizzled/.libs/",
 
1306
                            "/usr/local/lib");
1346
1307
  }
1347
1308
  else
1348
1309
  {
1369
1330
    push(@ld_library_paths, $debug_libraries_path);
1370
1331
  }
1371
1332
 
1372
 
  $ENV{'LD_LIBRARY_PATH'}= join(":", @ld_library_paths,
 
1333
  $ENV{'LD_LIBRARY_PATH'}= join(":", 
1373
1334
                                $ENV{'LD_LIBRARY_PATH'} ?
1374
 
                                split(':', $ENV{'LD_LIBRARY_PATH'}) : ());
 
1335
                                split(':', $ENV{'LD_LIBRARY_PATH'}) : (),
 
1336
                                @ld_library_paths);
1375
1337
  mtr_debug("LD_LIBRARY_PATH: $ENV{'LD_LIBRARY_PATH'}");
1376
1338
 
1377
1339
  $ENV{'DYLD_LIBRARY_PATH'}= join(":", @ld_library_paths,
1395
1357
  # Also command lines in .opt files may contain env vars
1396
1358
  # --------------------------------------------------------------------------
1397
1359
 
1398
 
  $ENV{'CHARSETSDIR'}=              $path_charsetsdir;
 
1360
  $ENV{'CHARSETSDIR'}=              "";
1399
1361
  $ENV{'UMASK'}=              "0660"; # The octal *string*
1400
1362
  $ENV{'UMASK_DIR'}=          "0770"; # The octal *string*
1401
1363
  
1412
1374
  
1413
1375
  $ENV{'LC_COLLATE'}=         "C";
1414
1376
  $ENV{'USE_RUNNING_SERVER'}= $opt_extern;
1415
 
  $ENV{'DRIZZLE_TEST_DIR'}=     $glob_mysql_test_dir;
 
1377
  $ENV{'DRIZZLE_TEST_DIR'}=     collapse_path($glob_mysql_test_dir);
1416
1378
  $ENV{'MYSQLTEST_VARDIR'}=   $opt_vardir;
1417
1379
  $ENV{'DRIZZLE_TMP_DIR'}=      $opt_tmpdir;
1418
1380
  $ENV{'MASTER_MYSOCK'}=      $master->[0]->{'path_sock'};
1425
1387
  $ENV{'SLAVE_MYPORT2'}=      $slave->[2]->{'port'};
1426
1388
  $ENV{'DRIZZLE_TCP_PORT'}=     $mysqld_variables{'port'};
1427
1389
 
1428
 
  $ENV{MTR_BUILD_THREAD}=      $opt_mtr_build_thread;
 
1390
  $ENV{'MTR_BUILD_THREAD'}=      $opt_mtr_build_thread;
1429
1391
 
1430
1392
  $ENV{'EXE_MYSQL'}=          $exe_drizzle;
1431
1393
 
1460
1422
  $ENV{'DRIZZLE_DUMP'}= $cmdline_mysqldump;
1461
1423
  $ENV{'DRIZZLE_DUMP_SLAVE'}= $cmdline_mysqldumpslave;
1462
1424
 
1463
 
 
1464
1425
  # ----------------------------------------------------
1465
1426
  # Setup env so childs can execute mysqlslap
1466
1427
  # ----------------------------------------------------
1467
 
  if ( $exe_mysqlslap )
 
1428
  if ( $exe_drizzleslap )
1468
1429
  {
1469
 
    my $cmdline_mysqlslap=
1470
 
      mtr_native_path($exe_mysqlslap) .
 
1430
    my $cmdline_drizzleslap=
 
1431
      mtr_native_path($exe_drizzleslap) .
1471
1432
      " -uroot " .
1472
1433
      "--port=$master->[0]->{'port'} ";
1473
1434
 
1474
1435
    if ( $opt_debug )
1475
1436
   {
1476
 
      $cmdline_mysqlslap .=
1477
 
        " --debug=d:t:A,$path_vardir_trace/log/mysqlslap.trace";
 
1437
      $cmdline_drizzleslap .=
 
1438
        " --debug=d:t:A,$path_vardir_trace/log/drizzleslap.trace";
1478
1439
    }
1479
 
    $ENV{'DRIZZLE_SLAP'}= $cmdline_mysqlslap;
 
1440
    $ENV{'DRIZZLE_SLAP'}= $cmdline_drizzleslap;
1480
1441
  }
1481
1442
 
 
1443
 
 
1444
 
1482
1445
  # ----------------------------------------------------
1483
1446
  # Setup env so childs can execute mysqlimport
1484
1447
  # ----------------------------------------------------
1496
1459
 
1497
1460
 
1498
1461
  # ----------------------------------------------------
1499
 
  # Setup env so childs can execute mysqlbinlog
1500
 
  # ----------------------------------------------------
1501
 
  my $cmdline_mysqlbinlog=
1502
 
    mtr_native_path($exe_drizzlebinlog) .
1503
 
      " --no-defaults --disable-force-if-open --debug-check";
1504
 
  if ( !$opt_extern && $mysql_version_id >= 50000 )
1505
 
  {
1506
 
    $cmdline_mysqlbinlog .=" --character-sets-dir=$path_charsetsdir";
1507
 
  }
1508
 
 
1509
 
  if ( $opt_debug )
1510
 
  {
1511
 
    $cmdline_mysqlbinlog .=
1512
 
      " --debug=d:t:A,$path_vardir_trace/log/mysqlbinlog.trace";
1513
 
  }
1514
 
  $ENV{'DRIZZLE_BINLOG'}= $cmdline_mysqlbinlog;
1515
 
 
1516
 
  # ----------------------------------------------------
1517
1462
  # Setup env so childs can execute mysql
1518
1463
  # ----------------------------------------------------
1519
1464
  my $cmdline_mysql=
1520
1465
    mtr_native_path($exe_drizzle) .
1521
1466
    " --no-defaults --debug-check --host=localhost  --user=root --password= " .
1522
 
    "--port=$master->[0]->{'port'} " .
1523
 
    "--character-sets-dir=$path_charsetsdir";
 
1467
    "--port=$master->[0]->{'port'} ";
1524
1468
 
1525
1469
  $ENV{'MYSQL'}= $cmdline_mysql;
1526
1470
 
1556
1500
  $ENV{'DRIZZLE_MY_PRINT_DEFAULTS'}= mtr_native_path($exe_my_print_defaults);
1557
1501
 
1558
1502
  # ----------------------------------------------------
1559
 
  # Setup env so childs can execute mysqladmin
 
1503
  # Setup env so childs can shutdown the server
1560
1504
  # ----------------------------------------------------
1561
 
  $ENV{'MYSQLADMIN'}= mtr_native_path($exe_drizzleadmin);
 
1505
  $ENV{'DRIZZLED_SHUTDOWN'}= mtr_native_path($exe_drizzle);
1562
1506
 
1563
1507
  # ----------------------------------------------------
1564
1508
  # Setup env so childs can execute perror  
1789
1733
  }
1790
1734
 
1791
1735
  # Make a link std_data_ln in var/ that points to std_data
1792
 
  symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
 
1736
  symlink(collapse_path("$glob_mysql_test_dir/std_data"),
 
1737
          "$opt_vardir/std_data_ln");
1793
1738
 
1794
1739
  # Remove old log files
1795
1740
  foreach my $name (glob("r/*.progress r/*.log r/*.warnings"))
1796
1741
  {
1797
1742
    unlink($name);
1798
1743
  }
 
1744
  system("chmod -R ugo+r $opt_vardir");
 
1745
  system("chmod -R ugo+r $opt_vardir/std_data_ln/*");
1799
1746
}
1800
1747
 
1801
1748
 
1886
1833
 
1887
1834
  if ( ! $benchmark )
1888
1835
  {
1889
 
    mtr_add_arg($args, "--log");
1890
1836
    mtr_run("$glob_mysql_bench_dir/run-all-tests", $args, "", "", "", "");
1891
1837
    # FIXME check result code?!
1892
1838
  }
1927
1873
 
1928
1874
  foreach my $tinfo ( @$tests )
1929
1875
  {
1930
 
    if (run_testcase_check_skip_test($tinfo))
 
1876
    foreach(1..$opt_repeat_test)
1931
1877
    {
1932
 
      next;
 
1878
      if (run_testcase_check_skip_test($tinfo))
 
1879
        {
 
1880
          next;
 
1881
        }
 
1882
 
 
1883
      mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout);
 
1884
      run_testcase($tinfo);
 
1885
      mtr_timer_stop($glob_timers,"testcase");
1933
1886
    }
1934
 
 
1935
 
    mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout);
1936
 
    run_testcase($tinfo);
1937
 
    mtr_timer_stop($glob_timers,"testcase");
1938
1887
  }
1939
1888
 
1940
1889
  mtr_print_line();
2092
2041
  unlink("$base_file.log");
2093
2042
  unlink("$base_file.warnings");
2094
2043
 
2095
 
  if (!$opt_extern)
2096
 
  {
2097
 
    if (defined $tinfo->{binlog_format} and  $mysql_version_id > 50100 )
2098
 
    {
2099
 
      # Dynamically switch binlog format of
2100
 
      # master, slave is always restarted
2101
 
      foreach my $server ( @$master )
2102
 
      {
2103
 
        next unless ($server->{'pid'});
2104
 
 
2105
 
        mtr_init_args(\$args);
2106
 
        mtr_add_arg($args, "--no-defaults");
2107
 
        mtr_add_arg($args, "--user=root");
2108
 
        mtr_add_arg($args, "--port=$server->{'port'}");
2109
 
 
2110
 
        my $sql= "include/set_binlog_format_".$tinfo->{binlog_format}.".sql";
2111
 
        mtr_verbose("Setting binlog format:", $tinfo->{binlog_format});
2112
 
        if (mtr_run($exe_drizzle, $args, $sql, "", "", "") != 0)
2113
 
        {
2114
 
          mtr_error("Failed to switch binlog format");
2115
 
        }
2116
 
      }
2117
 
    }
2118
 
  }
2119
2044
}
2120
2045
 
2121
2046
sub do_after_run_drizzletest($)
2488
2413
 
2489
2414
  mtr_add_arg($args, "%s--no-defaults", $prefix);
2490
2415
 
 
2416
  $path_my_basedir= collapse_path($path_my_basedir);
2491
2417
  mtr_add_arg($args, "%s--basedir=%s", $prefix, $path_my_basedir);
2492
 
  mtr_add_arg($args, "%s--character-sets-dir=%s", $prefix, $path_charsetsdir);
 
2418
 
 
2419
  if ($opt_engine)
 
2420
  {
 
2421
    mtr_add_arg($args, "%s--default-storage-engine=%s", $prefix, $opt_engine);
 
2422
  }
2493
2423
 
2494
2424
  if ( $mysql_version_id >= 50036)
2495
2425
  {
2497
2427
    mtr_add_arg($args, "%s--secure-file-priv=%s", $prefix, $opt_vardir);
2498
2428
  }
2499
2429
 
2500
 
  if ( $mysql_version_id >= 50000 )
2501
 
  {
2502
 
    mtr_add_arg($args, "%s--log-bin-trust-function-creators", $prefix);
2503
 
  }
2504
 
 
2505
 
  mtr_add_arg($args, "%s--default-character-set=latin1", $prefix);
2506
2430
  mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
2507
2431
 
2508
2432
  # Increase default connect_timeout to avoid intermittent
2527
2451
  mtr_add_arg($args, "%s--datadir=%s", $prefix,
2528
2452
              $mysqld->{'path_myddir'});
2529
2453
 
2530
 
  my $log_base_path= "$opt_vardir/log/$mysqld->{'type'}$sidx";
2531
 
  mtr_add_arg($args, "%s--log=%s.log", $prefix, $log_base_path);
2532
 
  mtr_add_arg($args,
2533
 
              "%s--log-slow-queries=%s-slow.log", $prefix, $log_base_path);
2534
 
 
2535
2454
  # Check if "extra_opt" contains --skip-log-bin
2536
 
  my $skip_binlog= grep(/^--skip-log-bin/, @$extra_opt, @opt_extra_mysqld_opt);
2537
2455
  if ( $mysqld->{'type'} eq 'master' )
2538
2456
  {
2539
 
    if (! ($opt_skip_master_binlog || $skip_binlog) )
2540
 
    {
2541
 
      mtr_add_arg($args, "%s--log-bin=%s/log/master-bin%s", $prefix,
2542
 
                  $opt_vardir, $sidx);
2543
 
    }
2544
 
 
2545
2457
    mtr_add_arg($args, "%s--server-id=%d", $prefix,
2546
2458
               $idx > 0 ? $idx + 101 : 1);
2547
2459
 
2548
2460
    mtr_add_arg($args, "%s--loose-innodb_data_file_path=ibdata1:10M:autoextend",
2549
2461
                $prefix);
2550
2462
 
2551
 
    mtr_add_arg($args, "%s--local-infile", $prefix);
 
2463
    mtr_add_arg($args, "%s--loose-innodb-lock-wait-timeout=5", $prefix);
2552
2464
 
2553
2465
    if ( $idx > 0 or !$use_innodb)
2554
2466
    {
2560
2472
    mtr_error("unknown mysqld type")
2561
2473
      unless $mysqld->{'type'} eq 'slave';
2562
2474
 
2563
 
    #mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
2564
 
    if (! ( $opt_skip_slave_binlog || $skip_binlog ))
2565
 
    {
2566
 
      mtr_add_arg($args, "%s--log-bin=%s/log/slave%s-bin", $prefix,
2567
 
                  $opt_vardir, $sidx); # FIXME use own dir for binlogs
2568
 
      mtr_add_arg($args, "%s--log-slave-updates", $prefix);
2569
 
    }
2570
 
 
2571
 
    mtr_add_arg($args, "%s--master-retry-count=10", $prefix);
2572
 
 
2573
 
    mtr_add_arg($args, "%s--relay-log=%s/log/slave%s-relay-bin", $prefix,
2574
 
                $opt_vardir, $sidx);
2575
 
    mtr_add_arg($args, "%s--report-host=127.0.0.1", $prefix);
2576
 
    mtr_add_arg($args, "%s--report-port=%d", $prefix,
2577
 
                $mysqld->{'port'});
2578
 
#    mtr_add_arg($args, "%s--report-user=root", $prefix);
2579
 
    mtr_add_arg($args, "%s--loose-skip-innodb", $prefix);
2580
 
    mtr_add_arg($args, "%s--skip-slave-start", $prefix);
2581
 
 
2582
2475
    # Directory where slaves find the dumps generated by "load data"
2583
2476
    # on the server. The path need to have constant length otherwise
2584
2477
    # test results will vary, thus a relative path is used.
2585
2478
    my $slave_load_path= "../tmp";
2586
 
    mtr_add_arg($args, "%s--slave-load-tmpdir=%s", $prefix,
2587
 
                $slave_load_path);
2588
 
    mtr_add_arg($args, "%s--set-variable=slave_net_timeout=120", $prefix);
2589
2479
 
2590
2480
    if ( @$slave_master_info )
2591
2481
    {
2599
2489
      my $slave_server_id=  2 + $idx;
2600
2490
      my $slave_rpl_rank= $slave_server_id;
2601
2491
      mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
2602
 
#      mtr_add_arg($args, "%s--rpl-recovery-rank=%d", $prefix, $slave_rpl_rank);
2603
2492
    }
2604
2493
  } # end slave
2605
2494
 
2632
2521
    {
2633
2522
      $found_skip_core= 1;
2634
2523
    }
2635
 
    elsif ($skip_binlog and mtr_match_prefix($arg, "--binlog-format"))
2636
 
    {
2637
 
      ; # Dont add --binlog-format when running without binlog
2638
 
    }
2639
2524
    else
2640
2525
    {
2641
2526
      mtr_add_arg($args, "%s%s", $prefix, $arg);
2646
2531
    mtr_add_arg($args, "%s%s", $prefix, "--core-file");
2647
2532
  }
2648
2533
 
2649
 
  if ( $opt_bench )
2650
 
  {
2651
 
    #mtr_add_arg($args, "%s--rpl-recovery-rank=1", $prefix);
2652
 
    #mtr_add_arg($args, "%s--init-rpl-role=master", $prefix);
2653
 
  }
2654
 
  elsif ( $mysqld->{'type'} eq 'master' )
2655
 
  {
2656
 
    mtr_add_arg($args, "%s--open-files-limit=1024", $prefix);
2657
 
  }
2658
 
 
2659
2534
  return $args;
2660
2535
}
2661
2536
 
2777
2652
  {
2778
2653
    if ( $mysqld->{'pid'} )
2779
2654
    {
2780
 
      $pid= mtr_mysqladmin_start($mysqld, "shutdown", 70);
 
2655
      $pid= mtr_server_shutdown($mysqld);
2781
2656
      $admin_pids{$pid}= 1;
2782
2657
 
2783
2658
      push(@kill_pids,{
2839
2714
    my $diff_opts= mtr_diff_opts($master->[0]->{'start_opts'},$tinfo->{'master_opt'});
2840
2715
    if (scalar(@$diff_opts) eq 2) 
2841
2716
    {
2842
 
      $do_restart= 1 unless ($diff_opts->[0] =~/^--binlog-format=/ and $diff_opts->[1] =~/^--binlog-format=/);
 
2717
      $do_restart= 1;
2843
2718
    }
2844
2719
    else
2845
2720
    {
2935
2810
    {
2936
2811
      if ( $mysqld->{'pid'} )
2937
2812
      {
2938
 
        $pid= mtr_mysqladmin_start($mysqld, "shutdown", 20);
2939
 
 
2940
 
        $admin_pids{$pid}= 1;
2941
 
 
2942
 
        push(@kill_pids,{
2943
 
                         pid      => $mysqld->{'pid'},
2944
 
                         real_pid => $mysqld->{'real_pid'},
2945
 
                         pidfile  => $mysqld->{'path_pid'},
2946
 
                         sockfile => $mysqld->{'path_sock'},
2947
 
                         port     => $mysqld->{'port'},
2948
 
                         errfile   => $mysqld->{'path_myerr'},
2949
 
                        });
2950
 
 
2951
 
        $mysqld->{'pid'}= 0; # Assume we are done with it
 
2813
        $pid= mtr_server_shutdown($mysqld);
 
2814
 
 
2815
        $admin_pids{$pid}= 1;
 
2816
 
 
2817
        push(@kill_pids,{
 
2818
              pid      => $mysqld->{'pid'},
 
2819
              real_pid => $mysqld->{'real_pid'},
 
2820
              pidfile  => $mysqld->{'path_pid'},
 
2821
              sockfile => $mysqld->{'path_sock'},
 
2822
              port     => $mysqld->{'port'},
 
2823
              errfile   => $mysqld->{'path_myerr'},
 
2824
        });
 
2825
 
 
2826
        $mysqld->{'pid'}= 0; # Assume we are done with it
2952
2827
      }
2953
2828
    }
2954
2829
  }
2963
2838
    {
2964
2839
      if ( $mysqld->{'pid'} )
2965
2840
      {
2966
 
        $pid= mtr_mysqladmin_start($mysqld, "shutdown", 20);
2967
 
 
2968
 
        $admin_pids{$pid}= 1;
2969
 
 
2970
 
        push(@kill_pids,{
2971
 
                         pid      => $mysqld->{'pid'},
2972
 
                         real_pid => $mysqld->{'real_pid'},
2973
 
                         pidfile  => $mysqld->{'path_pid'},
2974
 
                         sockfile => $mysqld->{'path_sock'},
2975
 
                         port     => $mysqld->{'port'},
2976
 
                         errfile   => $mysqld->{'path_myerr'},
2977
 
                        });
2978
 
 
2979
 
 
2980
 
        $mysqld->{'pid'}= 0; # Assume we are done with it
 
2841
        $pid= mtr_server_shutdown($mysqld);
 
2842
 
 
2843
        $admin_pids{$pid}= 1;
 
2844
 
 
2845
        push(@kill_pids,{
 
2846
              pid      => $mysqld->{'pid'},
 
2847
              real_pid => $mysqld->{'real_pid'},
 
2848
              pidfile  => $mysqld->{'path_pid'},
 
2849
              sockfile => $mysqld->{'path_sock'},
 
2850
              port     => $mysqld->{'port'},
 
2851
              errfile  => $mysqld->{'path_myerr'},
 
2852
        });
 
2853
 
 
2854
        $mysqld->{'pid'}= 0; # Assume we are done with it
2981
2855
      }
2982
2856
    }
2983
2857
  }
3087
2961
  mtr_add_arg($args, "--no-defaults");
3088
2962
  mtr_add_arg($args, "--silent");
3089
2963
  mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
3090
 
  mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
3091
2964
 
3092
2965
  mtr_add_arg($args, "--port=%d", $mysqld->{'port'});
3093
2966
  mtr_add_arg($args, "--database=test");
3102
2975
    mtr_add_arg($args, "--record");
3103
2976
  }
3104
2977
 
 
2978
  if ( $opt_testdir )
 
2979
  {
 
2980
    mtr_add_arg($args, "--testdir=%s", $opt_testdir);
 
2981
  }
 
2982
 
3105
2983
  my $res = mtr_run_test($exe_drizzletest,$args,
3106
2984
                "include/check-testcase.test", "", "", "");
3107
2985
 
3166
3044
  mtr_add_arg($args, "--no-defaults");
3167
3045
  mtr_add_arg($args, "--silent");
3168
3046
  mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
3169
 
  mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
3170
3047
  mtr_add_arg($args, "--logdir=%s/log", $opt_vardir);
3171
3048
 
3172
3049
  # Log line number and time  for each line in .test file
3209
3086
                $path_vardir_trace);
3210
3087
  }
3211
3088
 
 
3089
  if ( $opt_testdir )
 
3090
  {
 
3091
    mtr_add_arg($args, "--testdir=%s", $opt_testdir);
 
3092
  }
 
3093
 
 
3094
 
3212
3095
  # ----------------------------------------------------------------------
3213
3096
  # export DRIZZLE_TEST variable containing <path>/drizzletest <args>
3214
3097
  # ----------------------------------------------------------------------
3511
3394
  return 0;
3512
3395
}
3513
3396
 
 
3397
sub collapse_path ($) {
 
3398
 
 
3399
    my $c_path= rel2abs(shift);
 
3400
    my $updir  = updir($c_path);
 
3401
    my $curdir = curdir($c_path);
 
3402
 
 
3403
    my($vol, $dirs, $file) = splitpath($c_path);
 
3404
    my @dirs = splitdir($dirs);
 
3405
 
 
3406
    my @collapsed;
 
3407
    foreach my $dir (@dirs) {
 
3408
        if( $dir eq $updir              and   # if we have an updir
 
3409
            @collapsed                  and   # and something to collapse
 
3410
            length $collapsed[-1]       and   # and its not the rootdir
 
3411
            $collapsed[-1] ne $updir    and   # nor another updir
 
3412
            $collapsed[-1] ne $curdir         # nor the curdir
 
3413
          )
 
3414
        {                                     # then
 
3415
            pop @collapsed;                   # collapse
 
3416
        }
 
3417
        else {                                # else
 
3418
            push @collapsed, $dir;            # just hang onto it
 
3419
        }
 
3420
    }
 
3421
 
 
3422
    return catpath($vol, catdir(@collapsed), $file);
 
3423
}
3514
3424
 
3515
3425
##############################################################################
3516
3426
#
3565
3475
                        list of suite names.
3566
3476
                        The default is: "$opt_suites_default"
3567
3477
  skip-rpl              Skip the replication test cases.
3568
 
  big-test              Set the environment variable BIG_TEST, which can be
3569
 
                        checked from test cases.
3570
3478
  combination="ARG1 .. ARG2" Specify a set of "mysqld" arguments for one
3571
3479
                        combination.
3572
3480
  skip-combination      Skip any combination options and combinations files
 
3481
  repeat-test=n         How many times to repeat each test (default: 1)
3573
3482
 
3574
3483
Options that specify ports
3575
3484