~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/test-run.pl

Cleanup around SAFEMALLOC

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
 
 
6
4
#
7
5
##############################################################################
8
6
#
65
63
use File::Basename;
66
64
use File::Copy;
67
65
use File::Temp qw /tempdir/;
68
 
use File::Spec::Functions qw /splitdir catpath catdir
69
 
                              updir curdir splitpath rel2abs/;
 
66
use File::Spec::Functions qw /splitdir/;
70
67
use Cwd;
71
68
use Getopt::Long;
72
69
use IO::Socket;
98
95
##############################################################################
99
96
 
100
97
# Misc global variables
101
 
our $drizzle_version_id;
102
 
our $glob_suite_path=             undef;
 
98
our $mysql_version_id;
103
99
our $glob_mysql_test_dir=         undef;
104
100
our $glob_mysql_bench_dir=        undef;
105
101
our $glob_scriptname=             undef;
106
102
our $glob_timers=                 undef;
107
103
our @glob_test_mode;
108
104
 
109
 
our $glob_builddir;
110
 
 
111
105
our $glob_basedir;
112
106
 
113
107
our $path_client_bindir;
120
114
our $opt_vardir;                 # A path but set directly on cmd line
121
115
our $path_vardir_trace;          # unix formatted opt_vardir for trace files
122
116
our $opt_tmpdir;                 # A path but set directly on cmd line
123
 
our $opt_suitepath;
124
 
our $opt_testdir;
125
117
 
126
 
our $opt_subunit;
127
118
 
128
119
our $default_vardir;
129
120
 
130
121
our $opt_usage;
131
122
our $opt_suites;
132
 
our $opt_suites_default= "main,jp"; # Default suites to run
 
123
our $opt_suites_default= "main,binlog,rpl"; # Default suites to run
133
124
our $opt_script_debug= 0;  # Script debugging, enable with --script-debug
134
125
our $opt_verbose= 0;  # Verbose output, enable with --verbose
135
126
 
136
 
our $opt_repeat_test= 1;
137
 
 
138
127
our $exe_master_mysqld;
139
128
our $exe_drizzle;
 
129
our $exe_drizzleadmin;
 
130
our $exe_drizzlebinlog;
140
131
our $exe_drizzle_client_test;
141
132
our $exe_bug25714;
142
133
our $exe_drizzled;
 
134
our $exe_drizzlecheck;
143
135
our $exe_drizzledump;
144
136
our $exe_drizzleslap;
145
137
our $exe_drizzleimport;
151
143
our $lib_udf_example;
152
144
our $lib_example_plugin;
153
145
our $exe_libtool;
154
 
our $exe_schemawriter;
155
146
 
156
147
our $opt_bench= 0;
157
148
our $opt_small_bench= 0;
 
149
our $opt_big_test= 0;
158
150
 
159
151
our @opt_combinations;
160
152
our $opt_skip_combination;
166
158
our $opt_debug;
167
159
our $opt_do_test;
168
160
our @opt_cases;                  # The test cases names in argv
169
 
our $opt_engine;
170
161
 
171
162
our $opt_extern= 0;
172
163
our $opt_socket;
183
174
 
184
175
our $glob_debugger= 0;
185
176
our $opt_gdb;
186
 
our $opt_dbx;
187
177
our $opt_client_gdb;
188
 
our $opt_client_dbx;
189
 
our $opt_dbx_gdb;
190
178
our $opt_ddd;
191
179
our $opt_client_ddd;
192
180
our $opt_manual_gdb;
193
 
our $opt_manual_dbx;
194
181
our $opt_manual_ddd;
195
182
our $opt_manual_debug;
196
 
# Magic number -69.4 results in traditional test ports starting from 9306.
197
 
our $opt_mtr_build_thread=-69.4;
 
183
our $opt_mtr_build_thread=0;
198
184
our $opt_debugger;
199
185
our $opt_client_debugger;
200
186
 
209
195
 
210
196
our $opt_master_myport;
211
197
our $opt_slave_myport;
212
 
our $opt_memc_myport;
213
198
our $opt_record;
214
199
my $opt_report_features;
215
200
our $opt_check_testcases;
216
201
our $opt_mark_progress;
217
202
 
218
 
our $opt_skip_rpl= 1;
 
203
our $opt_skip_rpl;
219
204
our $max_slave_num= 0;
220
205
our $max_master_num= 1;
221
206
our $use_innodb;
245
230
my @valgrind_args;
246
231
my $opt_valgrind_path;
247
232
my $opt_callgrind;
248
 
my $opt_massif;
249
233
 
250
234
our $opt_stress=               "";
251
235
our $opt_stress_suite=     "main";
259
243
 
260
244
our $opt_warnings;
261
245
 
 
246
our $opt_skip_master_binlog= 0;
 
247
our $opt_skip_slave_binlog= 0;
 
248
 
262
249
our $path_sql_dir;
263
250
 
264
251
our @data_dir_lst;
265
252
 
 
253
our $used_binlog_format;
266
254
our $used_default_engine;
267
255
our $debug_compiled_binaries;
268
256
 
272
260
 
273
261
our $opt_max_save_core= 5;
274
262
my $num_saved_cores= 0;  # Number of core files saved in vardir/log/ so far.
275
 
our $secondary_port_offset= 50;
276
263
 
277
264
######################################################################
278
265
#
307
294
sub mysqld_arguments ($$$$);
308
295
sub stop_all_servers ();
309
296
sub run_drizzletest ($);
310
 
sub collapse_path ($);
311
297
sub usage ($);
312
298
 
313
299
 
433
419
 
434
420
  my $opt_comment;
435
421
 
 
422
  # Magic number -69.4 results in traditional test ports starting from 9306.
 
423
  set_mtr_build_thread_ports(-69.4);
 
424
 
436
425
  # If so requested, we try to avail ourselves of a unique build thread number.
437
426
  if ( $ENV{'MTR_BUILD_THREAD'} ) {
438
427
    if ( lc($ENV{'MTR_BUILD_THREAD'}) eq 'auto' ) {
474
463
 
475
464
             # Control what test suites or cases to run
476
465
             'force'                    => \$opt_force,
 
466
             'skip-master-binlog'       => \$opt_skip_master_binlog,
 
467
             'skip-slave-binlog'        => \$opt_skip_slave_binlog,
477
468
             'do-test=s'                => \$opt_do_test,
478
469
             'start-from=s'             => \$opt_start_from,
479
470
             'suite|suites=s'           => \$opt_suites,
480
471
             'skip-rpl'                 => \$opt_skip_rpl,
481
472
             'skip-test=s'              => \$opt_skip_test,
 
473
             'big-test'                 => \$opt_big_test,
482
474
             'combination=s'            => \@opt_combinations,
483
475
             'skip-combination'         => \$opt_skip_combination,
484
476
 
485
477
             # Specify ports
486
478
             'master_port=i'            => \$opt_master_myport,
487
479
             'slave_port=i'             => \$opt_slave_myport,
488
 
             'memc_port=i'              => \$opt_memc_myport,
489
480
             'mtr-build-thread=i'       => \$opt_mtr_build_thread,
490
481
 
491
482
             # Test case authoring
495
486
 
496
487
             # Extra options used when starting mysqld
497
488
             'mysqld=s'                 => \@opt_extra_mysqld_opt,
498
 
             'engine=s'                 => \$opt_engine,
499
489
 
500
490
             # Run test on running server
501
491
             'extern'                   => \$opt_extern,
502
492
 
503
 
             # Output format
504
 
             'subunit'                  => \$opt_subunit,
505
 
 
506
493
             # Debugging
507
494
             'gdb'                      => \$opt_gdb,
508
 
             'dbx'                      => \$opt_dbx,
509
495
             'client-gdb'               => \$opt_client_gdb,
510
 
             'client-dbx'               => \$opt_client_dbx,
511
496
             'manual-gdb'               => \$opt_manual_gdb,
512
 
             'manual-dbx'               => \$opt_manual_dbx,
513
497
             'manual-debug'             => \$opt_manual_debug,
514
498
             'ddd'                      => \$opt_ddd,
515
499
             'client-ddd'               => \$opt_client_ddd,
541
525
             'valgrind-option=s'        => \@valgrind_args,
542
526
             'valgrind-path=s'          => \$opt_valgrind_path,
543
527
             'callgrind'                => \$opt_callgrind,
544
 
             'massif'                   => \$opt_massif,
545
528
 
546
529
             # Stress testing 
547
530
             'stress'                   => \$opt_stress,
557
540
             # Directories
558
541
             'tmpdir=s'                 => \$opt_tmpdir,
559
542
             'vardir=s'                 => \$opt_vardir,
560
 
             'suitepath=s'              => \$opt_suitepath,
561
 
             'testdir=s'                => \$opt_testdir,
562
543
             'benchdir=s'               => \$glob_mysql_bench_dir,
563
544
             'mem'                      => \$opt_mem,
564
545
 
580
561
             'testcase-timeout=i'       => \$opt_testcase_timeout,
581
562
             'suite-timeout=i'          => \$opt_suite_timeout,
582
563
             'warnings|log-warnings'    => \$opt_warnings,
583
 
             'repeat-test=i'            => \$opt_repeat_test,
584
564
 
585
565
             # Options which are no longer used
586
566
             (map { $_ => \&warn_about_removed_option } @removed_options),
590
570
 
591
571
  usage("") if $opt_usage;
592
572
 
593
 
  usage("you cannot specify --gdb and --dbx both!") if 
594
 
        ($opt_gdb && $opt_dbx) ||
595
 
        ($opt_manual_gdb && $opt_manual_dbx);
596
 
 
597
573
  $glob_scriptname=  basename($0);
598
574
 
599
575
  if ($opt_mtr_build_thread != 0)
605
581
    $opt_mtr_build_thread= $ENV{'MTR_BUILD_THREAD'};
606
582
  }
607
583
 
 
584
  # We require that we are in the "mysql-test" directory
 
585
  # to run drizzle-test-run
 
586
  if (! -f $glob_scriptname)
 
587
  {
 
588
    mtr_error("Can't find the location for the drizzle-test-run script\n" .
 
589
              "Go to to the mysql-test directory and execute the script " .
 
590
              "as follows:\n./$glob_scriptname");
 
591
  }
 
592
 
608
593
  if ( -d "../drizzled" )
609
594
  {
610
595
    $source_dist=  1;
611
596
  }
612
597
 
613
598
  # Find the absolute path to the test directory
614
 
  if ( ! $opt_testdir )
615
 
  {
616
 
    $glob_mysql_test_dir=  cwd();
617
 
  } 
618
 
  else
619
 
  {
620
 
    $glob_mysql_test_dir= $opt_testdir;
621
 
  }
 
599
  $glob_mysql_test_dir=  cwd();
622
600
  $default_vardir= "$glob_mysql_test_dir/var";
623
601
 
624
 
  if ( ! $opt_suitepath )
625
 
  {
626
 
    $glob_suite_path= "$glob_mysql_test_dir/../plugin";
627
 
  }
628
 
  else
629
 
  {
630
 
    $glob_suite_path= $opt_suitepath;
631
 
  }
632
602
  # In most cases, the base directory we find everything relative to,
633
603
  # is the parent directory of the "mysql-test" directory. For source
634
604
  # distributions, TAR binary distributions and some other packages.
644
614
    $glob_basedir= dirname($glob_basedir);
645
615
  }
646
616
 
647
 
  if ( $opt_testdir and -d $opt_testdir and $opt_vardir and -d $opt_vardir
648
 
         and -f "$opt_vardir/../../drizzled/drizzled")
649
 
  {
650
 
    # probably in a VPATH build
651
 
    $glob_builddir= "$opt_vardir/../..";
652
 
  }
653
 
  else
654
 
  {
655
 
    $glob_builddir="..";
656
 
  }
657
 
 
658
617
  # Expect mysql-bench to be located adjacent to the source tree, by default
659
618
  $glob_mysql_bench_dir= "$glob_basedir/../mysql-bench"
660
619
    unless defined $glob_mysql_bench_dir;
672
631
  #
673
632
 
674
633
  # Look for the client binaries directory
675
 
  $path_client_bindir= mtr_path_exists("$glob_builddir/client",
676
 
                                       "$glob_basedir/client",
 
634
  $path_client_bindir= mtr_path_exists("$glob_basedir/client",
677
635
                                       "$glob_basedir/bin");
678
636
 
679
637
  if (!$opt_extern)
682
640
                                       "$path_client_bindir/drizzled",
683
641
                                       "$glob_basedir/libexec/drizzled",
684
642
                                       "$glob_basedir/bin/drizzled",
685
 
                                       "$glob_basedir/sbin/drizzled",
686
 
                                       "$glob_builddir/drizzled/drizzled");
 
643
                                       "$glob_basedir/sbin/drizzled");
687
644
 
688
645
    # Use the mysqld found above to find out what features are available
689
646
    collect_mysqld_features();
693
650
    $mysqld_variables{'port'}= 4427;
694
651
  }
695
652
 
696
 
  if (!$opt_engine)
697
 
  {
698
 
    $opt_engine= "innodb";
699
 
  }
700
 
 
701
653
  if ( $opt_comment )
702
654
  {
703
655
    print "\n";
729
681
  }
730
682
 
731
683
  # --------------------------------------------------------------------------
 
684
  # Find out type of logging that are being used
 
685
  # --------------------------------------------------------------------------
 
686
  if (!$opt_extern && $mysql_version_id >= 50100 )
 
687
  {
 
688
    foreach my $arg ( @opt_extra_mysqld_opt )
 
689
    {
 
690
      if ( $arg =~ /binlog[-_]format=(\S+)/ )
 
691
      {
 
692
        $used_binlog_format= $1;
 
693
      }
 
694
    }
 
695
    if (defined $used_binlog_format) 
 
696
    {
 
697
      mtr_report("Using binlog format '$used_binlog_format'");
 
698
    }
 
699
    else
 
700
    {
 
701
      mtr_report("Using dynamic switching of binlog format");
 
702
    }
 
703
  }
 
704
 
 
705
 
 
706
  # --------------------------------------------------------------------------
732
707
  # Find out default storage engine being used(if any)
733
708
  # --------------------------------------------------------------------------
734
709
  foreach my $arg ( @opt_extra_mysqld_opt )
775
750
  {
776
751
    $opt_vardir= $default_vardir;
777
752
  }
 
753
  elsif ( $mysql_version_id < 50000 and
 
754
          $opt_vardir ne $default_vardir)
 
755
  {
 
756
    # Version 4.1 and --vardir was specified
 
757
    # Only supported as a symlink from var/
 
758
    # by setting up $opt_mem that symlink will be created
 
759
    {
 
760
      # Only platforms that have native symlinks can use the vardir trick
 
761
      $opt_mem= $opt_vardir;
 
762
      mtr_report("Using 4.1 vardir trick");
 
763
    }
 
764
 
 
765
    $opt_vardir= $default_vardir;
 
766
  }
778
767
 
779
768
  $path_vardir_trace= $opt_vardir;
780
769
  # Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/...
781
770
  $path_vardir_trace=~ s/^\w://;
782
771
 
783
 
  $opt_vardir= collapse_path($opt_vardir);
 
772
  # We make the path absolute, as the server will do a chdir() before usage
 
773
  unless ( $opt_vardir =~ m,^/,)
 
774
  {
 
775
    # Make absolute path, relative test dir
 
776
    $opt_vardir= "$glob_mysql_test_dir/$opt_vardir";
 
777
  }
784
778
 
785
779
  # --------------------------------------------------------------------------
786
780
  # Set tmpdir
810
804
  }
811
805
 
812
806
  # --------------------------------------------------------------------------
 
807
  # Big test flags
 
808
  # --------------------------------------------------------------------------
 
809
   if ( $opt_big_test )
 
810
   {
 
811
     $ENV{'BIG_TEST'}= 1;
 
812
   }
 
813
 
 
814
  # --------------------------------------------------------------------------
813
815
  # Gcov flag
814
816
  # --------------------------------------------------------------------------
815
817
  if ( $opt_gcov and ! $source_dist )
822
824
  # --------------------------------------------------------------------------
823
825
  if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd ||
824
826
       $opt_manual_gdb || $opt_manual_ddd || $opt_manual_debug ||
825
 
       $opt_debugger || $opt_client_debugger || $opt_gdb || $opt_manual_gdb)
 
827
       $opt_debugger || $opt_client_debugger )
826
828
  {
827
829
    # Indicate that we are using debugger
828
830
    $glob_debugger= 1;
870
872
      unless @valgrind_args;
871
873
  }
872
874
 
873
 
  if ( $opt_massif )
874
 
  {
875
 
    mtr_report("Valgrind with Massif tool for drizzled(s)");
876
 
    $opt_valgrind= 1;
877
 
    $opt_valgrind_mysqld= 1;
878
 
  }
879
 
 
880
875
  if ( $opt_valgrind )
881
876
  {
882
877
    # Set valgrind_options to default unless already defined
924
919
 
925
920
  $master->[0]=
926
921
  {
927
 
   pid            => 0,
928
 
   type           => "master",
929
 
   idx            => 0,
930
 
   path_myddir    => "$opt_vardir/master-data",
931
 
   path_myerr     => "$opt_vardir/log/master.err",
932
 
   path_pid       => "$opt_vardir/run/master.pid",
933
 
   path_sock      => "$sockdir/master.sock",
934
 
   port           =>  $opt_master_myport,
935
 
   secondary_port =>  $opt_master_myport + $secondary_port_offset,
936
 
   start_timeout  =>  400, # enough time create innodb tables
937
 
   cluster        =>  0, # index in clusters list
938
 
   start_opts     => [],
 
922
   pid           => 0,
 
923
   type          => "master",
 
924
   idx           => 0,
 
925
   path_myddir   => "$opt_vardir/master-data",
 
926
   path_myerr    => "$opt_vardir/log/master.err",
 
927
   path_pid      => "$opt_vardir/run/master.pid",
 
928
   path_sock     => "$sockdir/master.sock",
 
929
   port          =>  $opt_master_myport,
 
930
   start_timeout =>  400, # enough time create innodb tables
 
931
   cluster       =>  0, # index in clusters list
 
932
   start_opts    => [],
939
933
  };
940
934
 
941
935
  $master->[1]=
942
936
  {
943
 
   pid            => 0,
944
 
   type           => "master",
945
 
   idx            => 1,
946
 
   path_myddir    => "$opt_vardir/master1-data",
947
 
   path_myerr     => "$opt_vardir/log/master1.err",
948
 
   path_pid       => "$opt_vardir/run/master1.pid",
949
 
   path_sock      => "$sockdir/master1.sock",
950
 
   port           => $opt_master_myport + 1,
951
 
   secondary_port => $opt_master_myport + 1 + $secondary_port_offset,
952
 
   start_timeout  => 400, # enough time create innodb tables
953
 
   cluster        =>  0, # index in clusters list
954
 
   start_opts     => [],
 
937
   pid           => 0,
 
938
   type          => "master",
 
939
   idx           => 1,
 
940
   path_myddir   => "$opt_vardir/master1-data",
 
941
   path_myerr    => "$opt_vardir/log/master1.err",
 
942
   path_pid      => "$opt_vardir/run/master1.pid",
 
943
   path_sock     => "$sockdir/master1.sock",
 
944
   port          => $opt_master_myport + 1,
 
945
   start_timeout => 400, # enough time create innodb tables
 
946
   cluster       =>  0, # index in clusters list
 
947
   start_opts    => [],
955
948
  };
956
949
 
957
950
  $slave->[0]=
958
951
  {
959
 
   pid            => 0,
960
 
   type           => "slave",
961
 
   idx            => 0,
962
 
   path_myddir    => "$opt_vardir/slave-data",
963
 
   path_myerr     => "$opt_vardir/log/slave.err",
964
 
   path_pid       => "$opt_vardir/run/slave.pid",
965
 
   path_sock      => "$sockdir/slave.sock",
966
 
   port           => $opt_slave_myport,
967
 
   secondary_port => $opt_slave_myport + $secondary_port_offset,
968
 
   start_timeout  => 400,
969
 
   cluster        =>  1, # index in clusters list
970
 
   start_opts     => [],
 
952
   pid           => 0,
 
953
   type          => "slave",
 
954
   idx           => 0,
 
955
   path_myddir   => "$opt_vardir/slave-data",
 
956
   path_myerr    => "$opt_vardir/log/slave.err",
 
957
   path_pid    => "$opt_vardir/run/slave.pid",
 
958
   path_sock   => "$sockdir/slave.sock",
 
959
   port   => $opt_slave_myport,
 
960
   start_timeout => 400,
 
961
 
 
962
   cluster       =>  1, # index in clusters list
 
963
   start_opts    => [],
971
964
  };
972
965
 
973
966
  $slave->[1]=
974
967
  {
975
 
   pid            => 0,
976
 
   type           => "slave",
977
 
   idx            => 1,
978
 
   path_myddir    => "$opt_vardir/slave1-data",
979
 
   path_myerr     => "$opt_vardir/log/slave1.err",
980
 
   path_pid       => "$opt_vardir/run/slave1.pid",
981
 
   path_sock      => "$sockdir/slave1.sock",
982
 
   port           => $opt_slave_myport + 1,
983
 
   secondary_port => $opt_slave_myport + 1 + $secondary_port_offset,
984
 
   start_timeout  => 300,
985
 
   cluster        =>  -1, # index in clusters list
986
 
   start_opts     => [],
 
968
   pid           => 0,
 
969
   type          => "slave",
 
970
   idx           => 1,
 
971
   path_myddir   => "$opt_vardir/slave1-data",
 
972
   path_myerr    => "$opt_vardir/log/slave1.err",
 
973
   path_pid    => "$opt_vardir/run/slave1.pid",
 
974
   path_sock   => "$sockdir/slave1.sock",
 
975
   port   => $opt_slave_myport + 1,
 
976
   start_timeout => 300,
 
977
   cluster       =>  -1, # index in clusters list
 
978
   start_opts    => [],
987
979
  };
988
980
 
989
981
  $slave->[2]=
990
982
  {
991
 
   pid            => 0,
992
 
   type           => "slave",
993
 
   idx            => 2,
994
 
   path_myddir    => "$opt_vardir/slave2-data",
995
 
   path_myerr     => "$opt_vardir/log/slave2.err",
996
 
   path_pid       => "$opt_vardir/run/slave2.pid",
997
 
   path_sock      => "$sockdir/slave2.sock",
998
 
   port           => $opt_slave_myport + 2,
999
 
   secondary_port => $opt_slave_myport + 2 + $secondary_port_offset,
1000
 
   start_timeout  => 300,
1001
 
   cluster        =>  -1, # index in clusters list
1002
 
   start_opts     => [],
 
983
   pid           => 0,
 
984
   type          => "slave",
 
985
   idx           => 2,
 
986
   path_myddir   => "$opt_vardir/slave2-data",
 
987
   path_myerr    => "$opt_vardir/log/slave2.err",
 
988
   path_pid    => "$opt_vardir/run/slave2.pid",
 
989
   path_sock   => "$sockdir/slave2.sock",
 
990
   port   => $opt_slave_myport + 2,
 
991
   start_timeout => 300,
 
992
   cluster       =>  -1, # index in clusters list
 
993
   start_opts    => [],
1003
994
  };
1004
995
 
1005
996
 
1043
1034
  }
1044
1035
}
1045
1036
 
1046
 
sub gimme_a_good_port($)
1047
 
{
1048
 
  my $port_to_test= shift;
1049
 
  my $is_port_bad= 1;
1050
 
  while ($is_port_bad) {
1051
 
    my $sock = new IO::Socket::INET( PeerAddr => 'localhost',
1052
 
                                     PeerPort => $port_to_test,
1053
 
                                     Proto => 'tcp' );
1054
 
    if ($sock) {
1055
 
      close($sock);
1056
 
      $port_to_test += 1;
1057
 
      if ($port_to_test >= 32767) {
1058
 
        $port_to_test = 5001;
1059
 
      }
1060
 
 
1061
 
    } else {
1062
 
      $is_port_bad= 0;
1063
 
    }
1064
 
  }
1065
 
  return $port_to_test;
1066
 
 
1067
 
}
1068
1037
#
1069
1038
# To make it easier for different devs to work on the same host,
1070
1039
# an environment variable can be used to control all ports. A small
1090
1059
    print "got ".$mtr_build_thread."\n";
1091
1060
  }
1092
1061
 
1093
 
  $mtr_build_thread= (($mtr_build_thread * 10) % 2000) - 1000;
1094
 
 
1095
1062
  # Up to two masters, up to three slaves
1096
1063
  # A magic value in command_line_setup depends on these equations.
1097
 
  $opt_master_myport=         gimme_a_good_port($mtr_build_thread + 9000); # and 1
1098
 
 
1099
 
 
1100
 
  $opt_slave_myport=          gimme_a_good_port($opt_master_myport + 2);  # and 3 4
1101
 
  $opt_memc_myport= gimme_a_good_port($opt_master_myport + 10);
 
1064
  $opt_master_myport=         $mtr_build_thread * 10 + 10000; # and 1
 
1065
  $opt_slave_myport=          $opt_master_myport + 2;  # and 3 4
1102
1066
 
1103
1067
  if ( $opt_master_myport < 5001 or $opt_master_myport + 10 >= 32767 )
1104
1068
  {
1149
1113
  foreach my $line (split('\n', $list))
1150
1114
  {
1151
1115
    # First look for version
1152
 
    if ( !$drizzle_version_id )
 
1116
    if ( !$mysql_version_id )
1153
1117
    {
1154
1118
      # Look for version
1155
1119
      my $exe_name= basename($exe_drizzled);
1157
1121
      if ( $line =~ /^\S*$exe_name\s\sVer\s([0-9]*)\.([0-9]*)\.([0-9]*)/ )
1158
1122
      {
1159
1123
        #print "Major: $1 Minor: $2 Build: $3\n";
1160
 
        $drizzle_version_id= $1*10000 + $2*100 + $3;
1161
 
        #print "drizzle_version_id: $drizzle_version_id\n";
1162
 
        mtr_report("Drizzle Version $1.$2.$3");
 
1124
        $mysql_version_id= $1*10000 + $2*100 + $3;
 
1125
        #print "mysql_version_id: $mysql_version_id\n";
 
1126
        mtr_report("MySQL Version $1.$2.$3");
1163
1127
      }
1164
1128
    }
1165
1129
    else
1200
1164
    }
1201
1165
  }
1202
1166
  rmtree($tmpdir);
1203
 
  mtr_error("Could not find version of Drizzle") unless $drizzle_version_id;
 
1167
  mtr_error("Could not find version of MySQL") unless $mysql_version_id;
1204
1168
  mtr_error("Could not find variabes list") unless $found_variable_list_start;
1205
1169
 
1206
1170
}
1213
1177
  mtr_init_args(\$args);
1214
1178
 
1215
1179
  mtr_add_arg($args, "--no-defaults");
1216
 
  mtr_add_arg($args, "--skip-stack-trace");
1217
1180
  mtr_add_arg($args, "--user=%s", $opt_user);
1218
1181
  mtr_add_arg($args, "--port=%d", $mysqld->{'port'});
1219
1182
  mtr_add_arg($args, "--silent"); # Tab separated output
1261
1224
  $exe_my_print_defaults=
1262
1225
    mtr_exe_exists(
1263
1226
        "$path_client_bindir/my_print_defaults",
1264
 
        "$glob_basedir/extra/my_print_defaults",
1265
 
        "$glob_builddir/extra/my_print_defaults");
 
1227
        "$glob_basedir/extra/my_print_defaults");
1266
1228
 
1267
1229
# Look for perror
1268
1230
  $exe_perror= "perror";
1269
1231
 
1270
1232
# Look for the client binaries
 
1233
  $exe_drizzlecheck= mtr_exe_exists("$path_client_bindir/drizzlecheck");
1271
1234
  $exe_drizzledump= mtr_exe_exists("$path_client_bindir/drizzledump");
1272
1235
  $exe_drizzleimport= mtr_exe_exists("$path_client_bindir/drizzleimport");
 
1236
  $exe_drizzlebinlog= mtr_exe_exists("$path_client_bindir/drizzlebinlog");
 
1237
  $exe_drizzleadmin= mtr_exe_exists("$path_client_bindir/drizzleadmin");
1273
1238
  $exe_drizzle=          mtr_exe_exists("$path_client_bindir/drizzle");
1274
1239
 
1275
1240
  if (!$opt_extern)
1276
1241
  {
1277
1242
# Look for SQL scripts directory
1278
 
     if ( $drizzle_version_id >= 50100 )
 
1243
     if ( $mysql_version_id >= 50100 )
1279
1244
     {
1280
1245
         $exe_drizzleslap= mtr_exe_exists("$path_client_bindir/drizzleslap");
1281
1246
     }
1282
1247
  }
1283
1248
 
1284
 
# Look for schema_writer
1285
 
  {
1286
 
    $exe_schemawriter= mtr_exe_exists("$glob_basedir/drizzled/message/schema_writer",
1287
 
                                      "$glob_builddir/drizzled/message/schema_writer");
1288
 
  }
1289
 
 
1290
1249
# Look for drizzletest executable
1291
1250
  {
1292
1251
    $exe_drizzletest= mtr_exe_exists("$path_client_bindir/drizzletest");
1314
1273
  my($mysqld) = @_;
1315
1274
  return
1316
1275
    mtr_native_path($exe_drizzledump) .
1317
 
      " --no-defaults -uroot " .
 
1276
      " --no-defaults -uroot --debug-check " .
1318
1277
      "--port=$mysqld->{'port'} ";
1319
1278
}
1320
1279
 
1342
1301
  mtr_add_arg($args, "--user=root");
1343
1302
  mtr_add_arg($args, "--port=$master->[0]->{'port'}");
1344
1303
 
1345
 
  if ( $opt_extern || $drizzle_version_id >= 50000 )
 
1304
  if ( $opt_extern || $mysql_version_id >= 50000 )
1346
1305
  {
1347
1306
    mtr_add_arg($args, "--vardir=$opt_vardir")
1348
1307
  }
1371
1330
  # --------------------------------------------------------------------------
1372
1331
  if ( $source_dist )
1373
1332
  {
1374
 
    push(@ld_library_paths, "$glob_basedir/libdrizzleclient/.libs/",
1375
 
                            "$glob_basedir/mysys/.libs/",
1376
 
                            "$glob_basedir/mystrings/.libs/",
1377
 
                            "$glob_basedir/drizzled/.libs/",
1378
 
                            "/usr/local/lib");
 
1333
    push(@ld_library_paths, "$glob_basedir/libmysql/.libs/",
 
1334
                            "$glob_basedir/libmysql_r/.libs/",
 
1335
                            "$glob_basedir/zlib.libs/");
1379
1336
  }
1380
1337
  else
1381
1338
  {
1402
1359
    push(@ld_library_paths, $debug_libraries_path);
1403
1360
  }
1404
1361
 
1405
 
  $ENV{'LD_LIBRARY_PATH'}= join(":", 
 
1362
  $ENV{'LD_LIBRARY_PATH'}= join(":", @ld_library_paths,
1406
1363
                                $ENV{'LD_LIBRARY_PATH'} ?
1407
 
                                split(':', $ENV{'LD_LIBRARY_PATH'}) : (),
1408
 
                                @ld_library_paths);
 
1364
                                split(':', $ENV{'LD_LIBRARY_PATH'}) : ());
1409
1365
  mtr_debug("LD_LIBRARY_PATH: $ENV{'LD_LIBRARY_PATH'}");
1410
1366
 
1411
1367
  $ENV{'DYLD_LIBRARY_PATH'}= join(":", @ld_library_paths,
1446
1402
  
1447
1403
  $ENV{'LC_COLLATE'}=         "C";
1448
1404
  $ENV{'USE_RUNNING_SERVER'}= $opt_extern;
1449
 
  $ENV{'DRIZZLE_TEST_DIR'}=     collapse_path($glob_mysql_test_dir);
 
1405
  $ENV{'DRIZZLE_TEST_DIR'}=     $glob_mysql_test_dir;
1450
1406
  $ENV{'MYSQLTEST_VARDIR'}=   $opt_vardir;
1451
1407
  $ENV{'DRIZZLE_TMP_DIR'}=      $opt_tmpdir;
1452
1408
  $ENV{'MASTER_MYSOCK'}=      $master->[0]->{'path_sock'};
1457
1413
  $ENV{'SLAVE_MYPORT'}=       $slave->[0]->{'port'};
1458
1414
  $ENV{'SLAVE_MYPORT1'}=      $slave->[1]->{'port'};
1459
1415
  $ENV{'SLAVE_MYPORT2'}=      $slave->[2]->{'port'};
1460
 
  $ENV{'MC_PORT'}=            $opt_memc_myport;
1461
 
  $ENV{'DRIZZLE_TCP_PORT'}=     $mysqld_variables{'drizzle-protocol-port'};
 
1416
  $ENV{'DRIZZLE_TCP_PORT'}=     $mysqld_variables{'port'};
1462
1417
 
1463
 
  $ENV{'MTR_BUILD_THREAD'}=      $opt_mtr_build_thread;
 
1418
  $ENV{MTR_BUILD_THREAD}=      $opt_mtr_build_thread;
1464
1419
 
1465
1420
  $ENV{'EXE_MYSQL'}=          $exe_drizzle;
1466
1421
 
 
1422
  # ----------------------------------------------------
 
1423
  # Setup env so childs can execute mysqlcheck
 
1424
  # ----------------------------------------------------
 
1425
  my $cmdline_mysqlcheck=
 
1426
    mtr_native_path($exe_drizzlecheck) .
 
1427
    " --no-defaults --debug-check -uroot " .
 
1428
    "--port=$master->[0]->{'port'} ";
 
1429
 
 
1430
  if ( $opt_debug )
 
1431
  {
 
1432
    $cmdline_mysqlcheck .=
 
1433
      " --debug=d:t:A,$path_vardir_trace/log/mysqlcheck.trace";
 
1434
  }
 
1435
  $ENV{'DRIZZLE_CHECK'}=              $cmdline_mysqlcheck;
1467
1436
 
1468
1437
  # ----------------------------------------------------
1469
1438
  # Setup env to childs can execute myqldump
1470
1439
  # ----------------------------------------------------
1471
1440
  my $cmdline_mysqldump= generate_cmdline_mysqldump($master->[0]);
1472
1441
  my $cmdline_mysqldumpslave= generate_cmdline_mysqldump($slave->[0]);
1473
 
  my $cmdline_mysqldump_secondary= mtr_native_path($exe_drizzledump) .
1474
 
       " --no-defaults -uroot " .
1475
 
       " --port=$master->[0]->{'secondary_port'} ";
1476
1442
 
1477
1443
  if ( $opt_debug )
1478
1444
  {
1480
1446
      " --debug=d:t:A,$path_vardir_trace/log/mysqldump-master.trace";
1481
1447
    $cmdline_mysqldumpslave .=
1482
1448
      " --debug=d:t:A,$path_vardir_trace/log/mysqldump-slave.trace";
1483
 
    $cmdline_mysqldump_secondary .=
1484
 
      " --debug=d:t:A,$path_vardir_trace/log/mysqldump-mysql.trace";
1485
1449
  }
1486
1450
  $ENV{'DRIZZLE_DUMP'}= $cmdline_mysqldump;
1487
1451
  $ENV{'DRIZZLE_DUMP_SLAVE'}= $cmdline_mysqldumpslave;
1488
 
  $ENV{'DRIZZLE_DUMP_SECONDARY'}= $cmdline_mysqldump_secondary;
1489
1452
 
1490
1453
  # ----------------------------------------------------
1491
1454
  # Setup env so childs can execute mysqlslap
1496
1459
      mtr_native_path($exe_drizzleslap) .
1497
1460
      " -uroot " .
1498
1461
      "--port=$master->[0]->{'port'} ";
1499
 
    my $cmdline_drizzleslap_secondary=
1500
 
      mtr_native_path($exe_drizzleslap) .
1501
 
      " -uroot " .
1502
 
      " --port=$master->[0]->{'secondary_port'} ";
1503
1462
 
1504
1463
    if ( $opt_debug )
1505
1464
   {
1506
1465
      $cmdline_drizzleslap .=
1507
1466
        " --debug=d:t:A,$path_vardir_trace/log/drizzleslap.trace";
1508
 
      $cmdline_drizzleslap_secondary .=
1509
 
        " --debug=d:t:A,$path_vardir_trace/log/drizzleslap.trace";
1510
1467
    }
1511
1468
    $ENV{'DRIZZLE_SLAP'}= $cmdline_drizzleslap;
1512
 
    $ENV{'DRIZZLE_SLAP_SECONDARY'}= $cmdline_drizzleslap_secondary;
1513
1469
  }
1514
1470
 
1515
1471
 
1519
1475
  # ----------------------------------------------------
1520
1476
  my $cmdline_mysqlimport=
1521
1477
    mtr_native_path($exe_drizzleimport) .
1522
 
    " -uroot " .
 
1478
    " -uroot --debug-check " .
1523
1479
    "--port=$master->[0]->{'port'} ";
1524
1480
 
1525
1481
  if ( $opt_debug )
1531
1487
 
1532
1488
 
1533
1489
  # ----------------------------------------------------
 
1490
  # Setup env so childs can execute mysqlbinlog
 
1491
  # ----------------------------------------------------
 
1492
  my $cmdline_mysqlbinlog=
 
1493
    mtr_native_path($exe_drizzlebinlog) .
 
1494
      " --no-defaults --disable-force-if-open --debug-check";
 
1495
 
 
1496
  if ( $opt_debug )
 
1497
  {
 
1498
    $cmdline_mysqlbinlog .=
 
1499
      " --debug=d:t:A,$path_vardir_trace/log/mysqlbinlog.trace";
 
1500
  }
 
1501
  $ENV{'DRIZZLE_BINLOG'}= $cmdline_mysqlbinlog;
 
1502
 
 
1503
  # ----------------------------------------------------
1534
1504
  # Setup env so childs can execute mysql
1535
1505
  # ----------------------------------------------------
1536
1506
  my $cmdline_mysql=
1537
1507
    mtr_native_path($exe_drizzle) .
1538
 
    " --no-defaults --host=localhost  --user=root --password= " .
 
1508
    " --no-defaults --debug-check --host=localhost  --user=root --password= " .
1539
1509
    "--port=$master->[0]->{'port'} ";
1540
 
  my $cmdline_drizzle_secondary=
1541
 
    mtr_native_path($exe_drizzle) .
1542
 
    " --no-defaults --host=localhost  --user=root --password= " .
1543
 
    " --port=$master->[0]->{'secondary_port'} ";
1544
1510
 
1545
1511
  $ENV{'MYSQL'}= $cmdline_mysql;
1546
 
  $ENV{'DRIZZLE_SECONDARY'}= $cmdline_drizzle_secondary;
1547
1512
 
1548
1513
  # ----------------------------------------------------
1549
1514
  # Setup env so childs can execute bug25714
1577
1542
  $ENV{'DRIZZLE_MY_PRINT_DEFAULTS'}= mtr_native_path($exe_my_print_defaults);
1578
1543
 
1579
1544
  # ----------------------------------------------------
1580
 
  # Setup env so childs can shutdown the server
 
1545
  # Setup env so childs can execute mysqladmin
1581
1546
  # ----------------------------------------------------
1582
 
  $ENV{'DRIZZLED_SHUTDOWN'}= mtr_native_path($exe_drizzle);
 
1547
  $ENV{'MYSQLADMIN'}= mtr_native_path($exe_drizzleadmin);
1583
1548
 
1584
1549
  # ----------------------------------------------------
1585
1550
  # Setup env so childs can execute perror  
1617
1582
    print "Using SLAVE_MYPORT          = $ENV{SLAVE_MYPORT}\n";
1618
1583
    print "Using SLAVE_MYPORT1         = $ENV{SLAVE_MYPORT1}\n";
1619
1584
    print "Using SLAVE_MYPORT2         = $ENV{SLAVE_MYPORT2}\n";
1620
 
    print "Using MC_PORT               = $ENV{MC_PORT}\n";
1621
1585
  }
1622
1586
 
1623
1587
  # Create an environment variable to make it possible
1807
1771
  foreach my $data_dir (@data_dir_lst)
1808
1772
  {
1809
1773
    mkpath("$data_dir/mysql");
1810
 
    system("$exe_schemawriter mysql $data_dir/mysql/db.opt");
1811
 
 
1812
1774
    mkpath("$data_dir/test");
1813
 
    system("$exe_schemawriter test $data_dir/test/db.opt");
1814
1775
  }
1815
1776
 
1816
1777
  # Make a link std_data_ln in var/ that points to std_data
1817
 
  symlink(collapse_path("$glob_mysql_test_dir/std_data"),
1818
 
          "$opt_vardir/std_data_ln");
 
1778
  symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
1819
1779
 
1820
1780
  # Remove old log files
1821
1781
  foreach my $name (glob("r/*.progress r/*.log r/*.warnings"))
1822
1782
  {
1823
1783
    unlink($name);
1824
1784
  }
1825
 
  system("chmod -R ugo+r $opt_vardir");
1826
 
  system("chmod -R ugo+r $opt_vardir/std_data_ln/*");
1827
1785
}
1828
1786
 
1829
1787
 
1914
1872
 
1915
1873
  if ( ! $benchmark )
1916
1874
  {
 
1875
    mtr_add_arg($args, "--log");
1917
1876
    mtr_run("$glob_mysql_bench_dir/run-all-tests", $args, "", "", "", "");
1918
1877
    # FIXME check result code?!
1919
1878
  }
1954
1913
 
1955
1914
  foreach my $tinfo ( @$tests )
1956
1915
  {
1957
 
    foreach(1..$opt_repeat_test)
 
1916
    if (run_testcase_check_skip_test($tinfo))
1958
1917
    {
1959
 
      if (run_testcase_check_skip_test($tinfo))
1960
 
        {
1961
 
          next;
1962
 
        }
1963
 
 
1964
 
      mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout);
1965
 
      run_testcase($tinfo);
1966
 
      mtr_timer_stop($glob_timers,"testcase");
 
1918
      next;
1967
1919
    }
 
1920
 
 
1921
    mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout);
 
1922
    run_testcase($tinfo);
 
1923
    mtr_timer_stop($glob_timers,"testcase");
1968
1924
  }
1969
1925
 
1970
1926
  mtr_print_line();
2122
2078
  unlink("$base_file.log");
2123
2079
  unlink("$base_file.warnings");
2124
2080
 
 
2081
  if (!$opt_extern)
 
2082
  {
 
2083
    if (defined $tinfo->{binlog_format} and  $mysql_version_id > 50100 )
 
2084
    {
 
2085
      # Dynamically switch binlog format of
 
2086
      # master, slave is always restarted
 
2087
      foreach my $server ( @$master )
 
2088
      {
 
2089
        next unless ($server->{'pid'});
 
2090
 
 
2091
        mtr_init_args(\$args);
 
2092
        mtr_add_arg($args, "--no-defaults");
 
2093
        mtr_add_arg($args, "--user=root");
 
2094
        mtr_add_arg($args, "--port=$server->{'port'}");
 
2095
 
 
2096
        my $sql= "include/set_binlog_format_".$tinfo->{binlog_format}.".sql";
 
2097
        mtr_verbose("Setting binlog format:", $tinfo->{binlog_format});
 
2098
        if (mtr_run($exe_drizzle, $args, $sql, "", "", "") != 0)
 
2099
        {
 
2100
          mtr_error("Failed to switch binlog format");
 
2101
        }
 
2102
      }
 
2103
    }
 
2104
  }
2125
2105
}
2126
2106
 
2127
2107
sub do_after_run_drizzletest($)
2494
2474
 
2495
2475
  mtr_add_arg($args, "%s--no-defaults", $prefix);
2496
2476
 
2497
 
  $path_my_basedir= collapse_path($path_my_basedir);
2498
2477
  mtr_add_arg($args, "%s--basedir=%s", $prefix, $path_my_basedir);
2499
2478
 
2500
 
  if ($opt_engine)
2501
 
  {
2502
 
    mtr_add_arg($args, "%s--default-storage-engine=%s", $prefix, $opt_engine);
2503
 
  }
2504
 
 
2505
 
  if ( $drizzle_version_id >= 50036)
 
2479
  if ( $mysql_version_id >= 50036)
2506
2480
  {
2507
2481
    # By default, prevent the started mysqld to access files outside of vardir
2508
2482
    mtr_add_arg($args, "%s--secure-file-priv=%s", $prefix, $opt_vardir);
2509
2483
  }
2510
2484
 
 
2485
  if ( $mysql_version_id >= 50000 )
 
2486
  {
 
2487
    mtr_add_arg($args, "%s--log-bin-trust-function-creators", $prefix);
 
2488
  }
 
2489
 
 
2490
  mtr_add_arg($args, "%s--default-character-set=utf8", $prefix);
2511
2491
  mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
2512
2492
 
2513
2493
  # Increase default connect_timeout to avoid intermittent
2514
2494
  # disconnects when test servers are put under load
2515
2495
  # see BUG#28359
2516
 
  mtr_add_arg($args, "%s--mysql-protocol-connect-timeout=60", $prefix);
 
2496
  mtr_add_arg($args, "%s--connect-timeout=60", $prefix);
2517
2497
 
2518
2498
 
2519
2499
  # When mysqld is run by a root user(euid is 0), it will fail
2526
2506
  mtr_add_arg($args, "%s--pid-file=%s", $prefix,
2527
2507
              $mysqld->{'path_pid'});
2528
2508
 
2529
 
  mtr_add_arg($args, "%s--mysql-protocol-port=%d", $prefix,
2530
 
              $mysqld->{'port'});
2531
 
 
2532
 
  mtr_add_arg($args, "%s--drizzle-protocol-port=%d", $prefix,
2533
 
              $mysqld->{'secondary_port'});
 
2509
  mtr_add_arg($args, "%s--port=%d", $prefix,
 
2510
                $mysqld->{'port'});
2534
2511
 
2535
2512
  mtr_add_arg($args, "%s--datadir=%s", $prefix,
2536
2513
              $mysqld->{'path_myddir'});
2537
2514
 
 
2515
  my $log_base_path= "$opt_vardir/log/$mysqld->{'type'}$sidx";
 
2516
  mtr_add_arg($args, "%s--log=%s.log", $prefix, $log_base_path);
 
2517
  mtr_add_arg($args,
 
2518
              "%s--log-slow-queries=%s-slow.log", $prefix, $log_base_path);
 
2519
 
2538
2520
  # Check if "extra_opt" contains --skip-log-bin
 
2521
  my $skip_binlog= grep(/^--skip-log-bin/, @$extra_opt, @opt_extra_mysqld_opt);
2539
2522
  if ( $mysqld->{'type'} eq 'master' )
2540
2523
  {
 
2524
    if (! ($opt_skip_master_binlog || $skip_binlog) )
 
2525
    {
 
2526
      mtr_add_arg($args, "%s--log-bin=%s/log/master-bin%s", $prefix,
 
2527
                  $opt_vardir, $sidx);
 
2528
    }
 
2529
 
2541
2530
    mtr_add_arg($args, "%s--server-id=%d", $prefix,
2542
2531
               $idx > 0 ? $idx + 101 : 1);
2543
2532
 
2544
2533
    mtr_add_arg($args, "%s--loose-innodb_data_file_path=ibdata1:10M:autoextend",
2545
2534
                $prefix);
2546
2535
 
2547
 
    mtr_add_arg($args, "%s--loose-innodb-lock-wait-timeout=5", $prefix);
 
2536
    mtr_add_arg($args, "%s--local-infile", $prefix);
2548
2537
 
 
2538
    if ( $idx > 0 or !$use_innodb)
 
2539
    {
 
2540
      mtr_add_arg($args, "%s--loose-skip-innodb", $prefix);
 
2541
    }
2549
2542
  }
2550
2543
  else
2551
2544
  {
2552
2545
    mtr_error("unknown mysqld type")
2553
2546
      unless $mysqld->{'type'} eq 'slave';
2554
2547
 
 
2548
    #mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
 
2549
    if (! ( $opt_skip_slave_binlog || $skip_binlog ))
 
2550
    {
 
2551
      mtr_add_arg($args, "%s--log-bin=%s/log/slave%s-bin", $prefix,
 
2552
                  $opt_vardir, $sidx); # FIXME use own dir for binlogs
 
2553
      mtr_add_arg($args, "%s--log-slave-updates", $prefix);
 
2554
    }
 
2555
 
 
2556
    mtr_add_arg($args, "%s--master-retry-count=10", $prefix);
 
2557
 
 
2558
    mtr_add_arg($args, "%s--relay-log=%s/log/slave%s-relay-bin", $prefix,
 
2559
                $opt_vardir, $sidx);
 
2560
    mtr_add_arg($args, "%s--report-host=127.0.0.1", $prefix);
 
2561
    mtr_add_arg($args, "%s--report-port=%d", $prefix,
 
2562
                $mysqld->{'port'});
 
2563
#    mtr_add_arg($args, "%s--report-user=root", $prefix);
 
2564
    mtr_add_arg($args, "%s--loose-skip-innodb", $prefix);
 
2565
    mtr_add_arg($args, "%s--skip-slave-start", $prefix);
 
2566
 
2555
2567
    # Directory where slaves find the dumps generated by "load data"
2556
2568
    # on the server. The path need to have constant length otherwise
2557
2569
    # test results will vary, thus a relative path is used.
2558
2570
    my $slave_load_path= "../tmp";
 
2571
    mtr_add_arg($args, "%s--slave-load-tmpdir=%s", $prefix,
 
2572
                $slave_load_path);
 
2573
    mtr_add_arg($args, "%s--set-variable=slave_net_timeout=120", $prefix);
2559
2574
 
2560
2575
    if ( @$slave_master_info )
2561
2576
    {
2569
2584
      my $slave_server_id=  2 + $idx;
2570
2585
      my $slave_rpl_rank= $slave_server_id;
2571
2586
      mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
 
2587
#      mtr_add_arg($args, "%s--rpl-recovery-rank=%d", $prefix, $slave_rpl_rank);
2572
2588
    }
2573
2589
  } # end slave
2574
2590
 
2578
2594
                $prefix, $path_vardir_trace, $mysqld->{'type'}, $sidx);
2579
2595
  }
2580
2596
 
2581
 
  mtr_add_arg($args, "%s--myisam_key_cache_size=1M", $prefix);
 
2597
  mtr_add_arg($args, "%s--key_buffer_size=1M", $prefix);
2582
2598
  mtr_add_arg($args, "%s--sort_buffer=256K", $prefix);
2583
2599
  mtr_add_arg($args, "%s--max_heap_table_size=1M", $prefix);
2584
2600
 
2601
2617
    {
2602
2618
      $found_skip_core= 1;
2603
2619
    }
 
2620
    elsif ($skip_binlog and mtr_match_prefix($arg, "--binlog-format"))
 
2621
    {
 
2622
      ; # Dont add --binlog-format when running without binlog
 
2623
    }
2604
2624
    else
2605
2625
    {
2606
2626
      mtr_add_arg($args, "%s%s", $prefix, $arg);
2611
2631
    mtr_add_arg($args, "%s%s", $prefix, "--core-file");
2612
2632
  }
2613
2633
 
 
2634
  if ( $opt_bench )
 
2635
  {
 
2636
    #mtr_add_arg($args, "%s--rpl-recovery-rank=1", $prefix);
 
2637
    #mtr_add_arg($args, "%s--init-rpl-role=master", $prefix);
 
2638
  }
 
2639
  elsif ( $mysqld->{'type'} eq 'master' )
 
2640
  {
 
2641
    mtr_add_arg($args, "%s--open-files-limit=1024", $prefix);
 
2642
  }
 
2643
 
2614
2644
  return $args;
2615
2645
}
2616
2646
 
2664
2694
  {
2665
2695
    ddd_arguments(\$args, \$exe, "$type"."_$idx");
2666
2696
  }
2667
 
  if ( $opt_dbx || $opt_manual_dbx)
2668
 
  {
2669
 
    dbx_arguments(\$args, \$exe, "$type"."_$idx");
2670
 
  }
2671
2697
  elsif ( $opt_debugger )
2672
2698
  {
2673
2699
    debugger_arguments(\$args, \$exe, "$type"."_$idx");
2736
2762
  {
2737
2763
    if ( $mysqld->{'pid'} )
2738
2764
    {
2739
 
      $pid= mtr_server_shutdown($mysqld);
 
2765
      $pid= mtr_mysqladmin_start($mysqld, "shutdown", 70);
2740
2766
      $admin_pids{$pid}= 1;
2741
2767
 
2742
2768
      push(@kill_pids,{
2798
2824
    my $diff_opts= mtr_diff_opts($master->[0]->{'start_opts'},$tinfo->{'master_opt'});
2799
2825
    if (scalar(@$diff_opts) eq 2) 
2800
2826
    {
2801
 
      $do_restart= 1;
 
2827
      $do_restart= 1 unless ($diff_opts->[0] =~/^--binlog-format=/ and $diff_opts->[1] =~/^--binlog-format=/);
2802
2828
    }
2803
2829
    else
2804
2830
    {
2894
2920
    {
2895
2921
      if ( $mysqld->{'pid'} )
2896
2922
      {
2897
 
        $pid= mtr_server_shutdown($mysqld);
2898
 
 
2899
 
        $admin_pids{$pid}= 1;
2900
 
 
2901
 
        push(@kill_pids,{
2902
 
              pid      => $mysqld->{'pid'},
2903
 
              real_pid => $mysqld->{'real_pid'},
2904
 
              pidfile  => $mysqld->{'path_pid'},
2905
 
              sockfile => $mysqld->{'path_sock'},
2906
 
              port     => $mysqld->{'port'},
2907
 
              errfile   => $mysqld->{'path_myerr'},
2908
 
        });
2909
 
 
2910
 
        $mysqld->{'pid'}= 0; # Assume we are done with it
 
2923
        $pid= mtr_mysqladmin_start($mysqld, "shutdown", 20);
 
2924
 
 
2925
        $admin_pids{$pid}= 1;
 
2926
 
 
2927
        push(@kill_pids,{
 
2928
                         pid      => $mysqld->{'pid'},
 
2929
                         real_pid => $mysqld->{'real_pid'},
 
2930
                         pidfile  => $mysqld->{'path_pid'},
 
2931
                         sockfile => $mysqld->{'path_sock'},
 
2932
                         port     => $mysqld->{'port'},
 
2933
                         errfile   => $mysqld->{'path_myerr'},
 
2934
                        });
 
2935
 
 
2936
        $mysqld->{'pid'}= 0; # Assume we are done with it
2911
2937
      }
2912
2938
    }
2913
2939
  }
2922
2948
    {
2923
2949
      if ( $mysqld->{'pid'} )
2924
2950
      {
2925
 
        $pid= mtr_server_shutdown($mysqld);
2926
 
 
2927
 
        $admin_pids{$pid}= 1;
2928
 
 
2929
 
        push(@kill_pids,{
2930
 
              pid      => $mysqld->{'pid'},
2931
 
              real_pid => $mysqld->{'real_pid'},
2932
 
              pidfile  => $mysqld->{'path_pid'},
2933
 
              sockfile => $mysqld->{'path_sock'},
2934
 
              port     => $mysqld->{'port'},
2935
 
              errfile  => $mysqld->{'path_myerr'},
2936
 
        });
2937
 
 
2938
 
        $mysqld->{'pid'}= 0; # Assume we are done with it
 
2951
        $pid= mtr_mysqladmin_start($mysqld, "shutdown", 20);
 
2952
 
 
2953
        $admin_pids{$pid}= 1;
 
2954
 
 
2955
        push(@kill_pids,{
 
2956
                         pid      => $mysqld->{'pid'},
 
2957
                         real_pid => $mysqld->{'real_pid'},
 
2958
                         pidfile  => $mysqld->{'path_pid'},
 
2959
                         sockfile => $mysqld->{'path_sock'},
 
2960
                         port     => $mysqld->{'port'},
 
2961
                         errfile   => $mysqld->{'path_myerr'},
 
2962
                        });
 
2963
 
 
2964
 
 
2965
        $mysqld->{'pid'}= 0; # Assume we are done with it
2939
2966
      }
2940
2967
    }
2941
2968
  }
3059
3086
    mtr_add_arg($args, "--record");
3060
3087
  }
3061
3088
 
3062
 
  if ( $opt_testdir )
3063
 
  {
3064
 
    mtr_add_arg($args, "--testdir=%s", $opt_testdir);
3065
 
  }
3066
 
 
3067
3089
  my $res = mtr_run_test($exe_drizzletest,$args,
3068
3090
                "include/check-testcase.test", "", "", "");
3069
3091
 
3170
3192
                $path_vardir_trace);
3171
3193
  }
3172
3194
 
3173
 
  if ( $opt_testdir )
3174
 
  {
3175
 
    mtr_add_arg($args, "--testdir=%s", $opt_testdir);
3176
 
  }
3177
 
 
3178
 
 
3179
3195
  # ----------------------------------------------------------------------
3180
3196
  # export DRIZZLE_TEST variable containing <path>/drizzletest <args>
3181
3197
  # ----------------------------------------------------------------------
3256
3272
 
3257
3273
}
3258
3274
 
3259
 
#
3260
 
# Modify the exe and args so that program is run in gdb in xterm
3261
 
#
3262
 
sub dbx_arguments {
3263
 
  my $args= shift;
3264
 
  my $exe=  shift;
3265
 
  my $type= shift;
3266
 
 
3267
 
  # Write $args to gdb init file
3268
 
  my $str= join(" ", @$$args);
3269
 
  my $dbx_init_file= "$opt_tmpdir/dbxinit.$type";
3270
 
 
3271
 
  # Remove the old gdbinit file
3272
 
  unlink($dbx_init_file);
3273
 
  if ( $type eq "client" )
3274
 
  {
3275
 
    # write init file for client
3276
 
    mtr_tofile($dbx_init_file,
3277
 
               "runargs $str\n" .
3278
 
               "run\n");
3279
 
  }
3280
 
  else
3281
 
  {
3282
 
    # write init file for drizzled
3283
 
    mtr_tofile($dbx_init_file,
3284
 
               "stop in __1cIdrizzledLmysql_parse6Fpn0AHSession_pkcI_v_\n" .
3285
 
               "runargs $str\n" .
3286
 
               "run\n" .
3287
 
               "\n");
3288
 
  }
3289
 
 
3290
 
  if ( $opt_manual_dbx )
3291
 
  {
3292
 
     print "\nTo start dbx for $type, type in another window:\n";
3293
 
     print "dbx -c 'source $dbx_init_file' $$exe\n";
3294
 
 
3295
 
     # Indicate the exe should not be started
3296
 
     $$exe= undef;
3297
 
     return;
3298
 
  }
3299
 
 
3300
 
  $$args= [];
3301
 
  mtr_add_arg($$args, "-title");
3302
 
  mtr_add_arg($$args, "$type");
3303
 
  mtr_add_arg($$args, "-e");
3304
 
 
3305
 
  mtr_add_arg($$args, "dbx");
3306
 
  mtr_add_arg($$args, "-c");
3307
 
  mtr_add_arg($$args, "source $dbx_init_file");
3308
 
  mtr_add_arg($$args, "$$exe");
3309
 
 
3310
 
  $$exe= "xterm";
3311
 
}
3312
3275
 
3313
3276
#
3314
3277
# Modify the exe and args so that program is run in gdb in xterm
3337
3300
    # write init file for mysqld
3338
3301
    mtr_tofile($gdb_init_file,
3339
3302
               "set args $str\n" .
3340
 
               "break drizzled::mysql_parse\n" .
 
3303
               "break mysql_parse\n" .
3341
3304
               "commands 1\n" .
3342
3305
               "disable 1\n" .
3343
3306
               "end\n" .
3402
3365
    mtr_tofile($gdb_init_file,
3403
3366
               "file $$exe\n" .
3404
3367
               "set args $str\n" .
3405
 
               "break drizzled::mysql_parse\n" .
 
3368
               "break mysql_parse\n" .
3406
3369
               "commands 1\n" .
3407
3370
               "disable 1\n" .
3408
3371
               "end");
3455
3418
    $$exe= $debugger;
3456
3419
 
3457
3420
  }
3458
 
  #elsif ( $debugger eq "dbx" )
3459
 
  #{
3460
 
  #  # xterm -e dbx -r exe arg1 .. argn
3461
 
#
3462
 
#    unshift(@$$args, $$exe);
3463
 
#    unshift(@$$args, "-r");
3464
 
#    unshift(@$$args, $debugger);
3465
 
#    unshift(@$$args, "-e");
3466
 
#
3467
 
#    $$exe= "xterm";
3468
 
#
3469
 
#  }
 
3421
  elsif ( $debugger eq "dbx" )
 
3422
  {
 
3423
    # xterm -e dbx -r exe arg1 .. argn
 
3424
 
 
3425
    unshift(@$$args, $$exe);
 
3426
    unshift(@$$args, "-r");
 
3427
    unshift(@$$args, $debugger);
 
3428
    unshift(@$$args, "-e");
 
3429
 
 
3430
    $$exe= "xterm";
 
3431
 
 
3432
  }
3470
3433
  else
3471
3434
  {
3472
3435
    mtr_error("Unknown argument \"$debugger\" passed to --debugger");
3486
3449
    mtr_add_arg($args, "--tool=callgrind");
3487
3450
    mtr_add_arg($args, "--base=$opt_vardir/log");
3488
3451
  }
3489
 
  elsif ($opt_massif)
3490
 
  {
3491
 
    mtr_add_arg($args, "--tool=massif");
3492
 
  }
3493
3452
  else
3494
3453
  {
3495
3454
    mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
 
3455
    mtr_add_arg($args, "--alignment=8");
3496
3456
    mtr_add_arg($args, "--leak-check=yes");
3497
3457
    mtr_add_arg($args, "--num-callers=16");
3498
3458
    mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir)
3534
3494
  return 0;
3535
3495
}
3536
3496
 
3537
 
sub collapse_path ($) {
3538
 
 
3539
 
    my $c_path= rel2abs(shift);
3540
 
    my $updir  = updir($c_path);
3541
 
    my $curdir = curdir($c_path);
3542
 
 
3543
 
    my($vol, $dirs, $file) = splitpath($c_path);
3544
 
    my @dirs = splitdir($dirs);
3545
 
 
3546
 
    my @collapsed;
3547
 
    foreach my $dir (@dirs) {
3548
 
        if( $dir eq $updir              and   # if we have an updir
3549
 
            @collapsed                  and   # and something to collapse
3550
 
            length $collapsed[-1]       and   # and its not the rootdir
3551
 
            $collapsed[-1] ne $updir    and   # nor another updir
3552
 
            $collapsed[-1] ne $curdir         # nor the curdir
3553
 
          )
3554
 
        {                                     # then
3555
 
            pop @collapsed;                   # collapse
3556
 
        }
3557
 
        else {                                # else
3558
 
            push @collapsed, $dir;            # just hang onto it
3559
 
        }
3560
 
    }
3561
 
 
3562
 
    return catpath($vol, catdir(@collapsed), $file);
3563
 
}
3564
3497
 
3565
3498
##############################################################################
3566
3499
#
3615
3548
                        list of suite names.
3616
3549
                        The default is: "$opt_suites_default"
3617
3550
  skip-rpl              Skip the replication test cases.
 
3551
  big-test              Set the environment variable BIG_TEST, which can be
 
3552
                        checked from test cases.
3618
3553
  combination="ARG1 .. ARG2" Specify a set of "mysqld" arguments for one
3619
3554
                        combination.
3620
3555
  skip-combination      Skip any combination options and combinations files
3621
 
  repeat-test=n         How many times to repeat each test (default: 1)
3622
3556
 
3623
3557
Options that specify ports
3624
3558
 
3679
3613
                        can be specified more then once
3680
3614
  valgrind-path=[EXE]   Path to the valgrind executable
3681
3615
  callgrind             Instruct valgrind to use callgrind
3682
 
  massif                Instruct valgrind to use massif
3683
3616
 
3684
3617
Misc options
3685
3618