~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/test-run.pl

[patch 112/129] Merge patch for revision 1925 from InnoDB SVN:
revno: 1925
revision-id: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6169
parent: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6163
committer: calvin
timestamp: Thu 2009-11-12 12:40:43 +0000
message:
  branches/zip: add test case for bug#46676
  
  This crash is reproducible with InnoDB plugin 1.0.4 + MySQL 5.1.37.
  But no longer reproducible after MySQL 5.1.38 (with plugin 1.0.5).
  Add test case to catch future regression.
added:
  mysql-test/innodb_bug46676.result 6169@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb_bug46676.result
  mysql-test/innodb_bug46676.test 6169@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb_bug46676.test
diff:
=== added file 'mysql-test/innodb_bug46676.result'

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
use utf8;
5
5
 
6
6
#
7
 
# Copyright (C) 2008
8
 
9
 
# This program is free software; you can redistribute it and/or modify
10
 
# it under the terms of the GNU General Public License as published by
11
 
# the Free Software Foundation; version 2 of the License.
12
 
13
 
# This program is distributed in the hope that it will be useful,
14
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
# GNU General Public License for more details.
17
 
18
 
# You should have received a copy of the GNU General Public License
19
 
# along with this program; if not, write to the Free Software
20
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
21
 
#
22
 
#
23
7
##############################################################################
24
8
#
25
9
#  drizzle-test-run.pl
38
22
#
39
23
#   - To make this Perl script easy to alter even for those that not
40
24
#     code Perl that often, keeep the coding style as close as possible to
41
 
#     the C/C++ drizzle coding standard.
 
25
#     the C/C++ MySQL coding standard.
42
26
#
43
27
#   - All lists of arguments to send to commands are Perl lists/arrays,
44
28
#     not strings we append args to. Within reason, most string
45
29
#     concatenation for arguments should be avoided.
46
30
#
47
31
#   - Functions defined in the main program are not to be prefixed,
48
 
#     functions in "library files" are to be prefixed with "dtr_" (for
49
 
#     Drizzle-Test-Run). There are some exceptions, code that fits best in
 
32
#     functions in "library files" are to be prefixed with "mtr_" (for
 
33
#     Mysql-Test-Run). There are some exceptions, code that fits best in
50
34
#     the main program, but are put into separate files to avoid
51
35
#     clutter, may be without prefix.
52
36
#
68
52
# A nice way to trace the execution of this script while debugging
69
53
# is to use the Devel::Trace package found at
70
54
# "http://www.plover.com/~mjd/perl/Trace/" and run this script like
71
 
# "perl -d:Trace test-run.pl"
 
55
# "perl -d:Trace drizzle-test-run.pl"
72
56
#
73
57
 
74
58
 
93
77
select(STDOUT);
94
78
$| = 1; # Automatically flush STDOUT
95
79
 
96
 
require "dtr_cases.pl";
97
 
require "dtr_process.pl";
98
 
require "dtr_timer.pl";
99
 
require "dtr_io.pl";
100
 
require "dtr_gcov.pl";
101
 
require "dtr_gprof.pl";
102
 
require "dtr_report.pl";
103
 
require "dtr_match.pl";
104
 
require "dtr_misc.pl";
105
 
require "dtr_stress.pl";
106
 
require "dtr_unique.pl";
 
80
require "mtr_cases.pl";
 
81
require "mtr_process.pl";
 
82
require "mtr_timer.pl";
 
83
require "mtr_io.pl";
 
84
require "mtr_gcov.pl";
 
85
require "mtr_gprof.pl";
 
86
require "mtr_report.pl";
 
87
require "mtr_match.pl";
 
88
require "mtr_misc.pl";
 
89
require "mtr_stress.pl";
 
90
require "mtr_unique.pl";
107
91
 
108
92
$Devel::Trace::TRACE= 1;
109
93
 
116
100
# Misc global variables
117
101
our $drizzle_version_id;
118
102
our $glob_suite_path=             undef;
119
 
our $glob_drizzle_test_dir=         undef;
120
 
our $glob_drizzle_bench_dir=        undef;
 
103
our $glob_mysql_test_dir=         undef;
 
104
our $glob_mysql_bench_dir=        undef;
121
105
our $glob_scriptname=             undef;
122
106
our $glob_timers=                 undef;
123
107
our @glob_test_mode;
154
138
 
155
139
our $opt_repeat_test= 1;
156
140
 
157
 
our $exe_master_drizzled;
 
141
our $exe_master_mysqld;
158
142
our $exe_drizzle;
159
 
our $exe_drizzleadmin;
160
143
our $exe_drizzle_client_test;
161
144
our $exe_bug25714;
162
145
our $exe_drizzled;
165
148
our $exe_drizzleimport;
166
149
our $exe_drizzle_fix_system_tables;
167
150
our $exe_drizzletest;
168
 
our $exe_slave_drizzled;
 
151
our $exe_slave_mysqld;
169
152
our $exe_perror;
170
153
our $lib_udf_example;
171
154
our $lib_example_plugin;
178
161
our @opt_combinations;
179
162
our $opt_skip_combination;
180
163
 
181
 
our @opt_extra_drizzled_opt;
 
164
our @opt_extra_mysqld_opt;
182
165
 
183
166
our $opt_compress;
184
167
 
194
177
our $opt_force;
195
178
our $opt_reorder= 0;
196
179
our $opt_enable_disabled;
197
 
our $opt_mem= $ENV{'DTR_MEM'};
 
180
our $opt_mem= $ENV{'MTR_MEM'};
198
181
 
199
182
our $opt_gcov;
200
183
our $opt_gcov_err;
213
196
our $opt_manual_ddd;
214
197
our $opt_manual_debug;
215
198
# Magic number -69.4 results in traditional test ports starting from 9306.
216
 
our $opt_dtr_build_thread=-69.4;
 
199
our $opt_mtr_build_thread=-69.4;
217
200
our $opt_debugger;
218
201
our $opt_client_debugger;
219
202
 
229
212
our $opt_master_myport;
230
213
our $opt_slave_myport;
231
214
our $opt_memc_myport;
232
 
our $opt_pbms_myport;
233
215
our $opt_record;
234
216
my $opt_report_features;
235
217
our $opt_check_testcases;
259
241
our $opt_user;
260
242
 
261
243
my $opt_valgrind= 0;
262
 
my $opt_valgrind_drizzled= 0;
 
244
my $opt_valgrind_mysqld= 0;
263
245
my $opt_valgrind_drizzletest= 0;
264
246
my $opt_valgrind_drizzleslap= 0;
265
247
my @default_valgrind_args= ("--show-reachable=yes --malloc-fill=0xDEADBEEF --free-fill=0xDEADBEEF");
287
269
our $used_default_engine;
288
270
our $debug_compiled_binaries;
289
271
 
290
 
our %drizzled_variables;
 
272
our %mysqld_variables;
291
273
 
292
274
my $source_dist= 0;
293
275
 
304
286
sub main ();
305
287
sub initial_setup ();
306
288
sub command_line_setup ();
307
 
sub set_dtr_build_thread_ports($);
 
289
sub set_mtr_build_thread_ports($);
308
290
sub datadir_list_setup ();
309
291
sub executable_setup ();
310
292
sub environment_setup ();
312
294
sub remove_stale_vardir ();
313
295
sub setup_vardir ();
314
296
sub check_running_as_root();
315
 
sub drizzled_wait_started($);
 
297
sub mysqld_wait_started($);
316
298
sub run_benchmarks ($);
317
299
sub initialize_servers ();
318
 
sub drizzle_install_db ();
 
300
sub mysql_install_db ();
319
301
sub copy_install_db ($$);
320
302
sub run_testcase ($);
321
303
sub run_testcase_stop_servers ($$$);
324
306
sub report_failure_and_restart ($);
325
307
sub do_before_start_master ($);
326
308
sub do_before_start_slave ($);
327
 
sub drizzled_start ($$$);
328
 
sub drizzled_arguments ($$$$);
 
309
sub mysqld_start ($$$);
 
310
sub mysqld_arguments ($$$$);
329
311
sub stop_all_servers ();
330
312
sub run_drizzletest ($);
331
313
sub collapse_path ($);
344
326
 
345
327
  command_line_setup();
346
328
 
347
 
  check_debug_support(\%drizzled_variables);
 
329
  check_debug_support(\%mysqld_variables);
348
330
 
349
331
  executable_setup();
350
332
 
385
367
      {
386
368
        my $extra_suite= $extra_suites{$dir};
387
369
        if (defined $extra_suite){
388
 
          dtr_report("Found extra suite: $extra_suite");
 
370
          mtr_report("Found extra suite: $extra_suite");
389
371
          $opt_suites= "$extra_suite,$opt_suites";
390
372
          last;
391
373
        }
404
386
        # Count max number of slaves used by a test case
405
387
        if ( $test->{slave_num} > $max_slave_num) {
406
388
          $max_slave_num= $test->{slave_num};
407
 
          dtr_error("Too many slaves") if $max_slave_num > 3;
 
389
          mtr_error("Too many slaves") if $max_slave_num > 3;
408
390
        }
409
391
 
410
392
        # Count max number of masters used by a test case
411
393
        if ( $test->{master_num} > $max_master_num) {
412
394
          $max_master_num= $test->{master_num};
413
 
          dtr_error("Too many masters") if $max_master_num > 2;
414
 
          dtr_error("Too few masters") if $max_master_num < 1;
 
395
          mtr_error("Too many masters") if $max_master_num > 2;
 
396
          mtr_error("Too few masters") if $max_master_num < 1;
415
397
        }
416
398
      }
417
399
      $use_innodb||= $test->{'innodb_test'};
426
408
    run_tests($tests);
427
409
  }
428
410
 
429
 
  dtr_exit(0);
 
411
  mtr_exit(0);
430
412
}
431
413
 
432
414
##############################################################################
437
419
 
438
420
#
439
421
# When an option is no longer used by this program, it must be explicitly
440
 
# ignored or else it will be passed through to drizzled.  GetOptions will call
 
422
# ignored or else it will be passed through to mysqld.  GetOptions will call
441
423
# this subroutine once for each such option on the command line.  See
442
424
# Getopt::Long documentation.
443
425
#
455
437
  my $opt_comment;
456
438
 
457
439
  # If so requested, we try to avail ourselves of a unique build thread number.
458
 
  if ( $ENV{'DTR_BUILD_THREAD'} ) {
459
 
    if ( lc($ENV{'DTR_BUILD_THREAD'}) eq 'auto' ) {
 
440
  if ( $ENV{'MTR_BUILD_THREAD'} ) {
 
441
    if ( lc($ENV{'MTR_BUILD_THREAD'}) eq 'auto' ) {
460
442
      print "Requesting build thread... ";
461
 
      $ENV{'DTR_BUILD_THREAD'} = dtr_require_unique_id_and_wait("/tmp/drizzle-test-ports", 200, 299);
462
 
      print "got ".$ENV{'DTR_BUILD_THREAD'}."\n";
 
443
      $ENV{'MTR_BUILD_THREAD'} = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299);
 
444
      print "got ".$ENV{'MTR_BUILD_THREAD'}."\n";
463
445
    }
464
446
  }
465
447
 
466
 
  if ( $ENV{'DTR_BUILD_THREAD'} )
 
448
  if ( $ENV{'MTR_BUILD_THREAD'} )
467
449
  {
468
 
    set_dtr_build_thread_ports($ENV{'DTR_BUILD_THREAD'});
 
450
    set_mtr_build_thread_ports($ENV{'MTR_BUILD_THREAD'});
469
451
  }
470
452
 
471
453
  # This is needed for test log evaluation in "gen-build-status-page"
477
459
  # Note: Keep list, and the order, in sync with usage at end of this file
478
460
 
479
461
  # Options that are no longer used must still be processed, because all
480
 
  # unprocessed options are passed directly to drizzled.  The user will be
 
462
  # unprocessed options are passed directly to mysqld.  The user will be
481
463
  # warned that the option is being ignored.
482
464
  #
483
465
  # Put the complete option string here.  For example, to remove the --suite
507
489
             'master_port=i'            => \$opt_master_myport,
508
490
             'slave_port=i'             => \$opt_slave_myport,
509
491
             'memc_port=i'              => \$opt_memc_myport,
510
 
             'pbms_port=i'              => \$opt_pbms_myport,
511
 
             'dtr-build-thread=i'       => \$opt_dtr_build_thread,
 
492
             'mtr-build-thread=i'       => \$opt_mtr_build_thread,
512
493
 
513
494
             # Test case authoring
514
495
             'record'                   => \$opt_record,
515
496
             'check-testcases'          => \$opt_check_testcases,
516
497
             'mark-progress'            => \$opt_mark_progress,
517
498
 
518
 
             # Extra options used when starting drizzled
519
 
             'drizzled=s'                 => \@opt_extra_drizzled_opt,
 
499
             # Extra options used when starting mysqld
 
500
             'mysqld=s'                 => \@opt_extra_mysqld_opt,
520
501
             'engine=s'                 => \$opt_engine,
521
502
 
522
503
             # Run test on running server
539
520
             'debugger=s'               => \$opt_debugger,
540
521
             'client-debugger=s'        => \$opt_client_debugger,
541
522
             'strace-client'            => \$opt_strace_client,
542
 
             'master-binary=s'          => \$exe_master_drizzled,
543
 
             'slave-binary=s'           => \$exe_slave_drizzled,
 
523
             'master-binary=s'          => \$exe_master_mysqld,
 
524
             'slave-binary=s'           => \$exe_slave_mysqld,
544
525
             'max-save-core=i'          => \$opt_max_save_core,
545
526
 
546
527
             # Coverage, profiling etc
549
530
             'valgrind|valgrind-all'    => \$opt_valgrind,
550
531
             'valgrind-drizzletest'       => \$opt_valgrind_drizzletest,
551
532
             'valgrind-drizzleslap'       => \$opt_valgrind_drizzleslap,
552
 
             'valgrind-drizzled'          => \$opt_valgrind_drizzled,
 
533
             'valgrind-mysqld'          => \$opt_valgrind_mysqld,
553
534
             'valgrind-options=s'       => sub {
554
535
               my ($opt, $value)= @_;
555
536
               # Deprecated option unless it's what we know pushbuild uses
584
565
             'top-srcdir=s'             => \$opt_top_srcdir,
585
566
             'suitepath=s'              => \$opt_suitepath,
586
567
             'testdir=s'                => \$opt_testdir,
587
 
             'benchdir=s'               => \$glob_drizzle_bench_dir,
 
568
             'benchdir=s'               => \$glob_mysql_bench_dir,
588
569
             'mem'                      => \$opt_mem,
589
570
 
590
571
             # Misc
621
602
 
622
603
  $glob_scriptname=  basename($0);
623
604
 
624
 
  if ($opt_dtr_build_thread != 0)
 
605
  if ($opt_mtr_build_thread != 0)
625
606
  {
626
 
    set_dtr_build_thread_ports($opt_dtr_build_thread)
 
607
    set_mtr_build_thread_ports($opt_mtr_build_thread)
627
608
  }
628
 
  elsif ($ENV{'DTR_BUILD_THREAD'})
 
609
  elsif ($ENV{'MTR_BUILD_THREAD'})
629
610
  {
630
 
    $opt_dtr_build_thread= $ENV{'DTR_BUILD_THREAD'};
 
611
    $opt_mtr_build_thread= $ENV{'MTR_BUILD_THREAD'};
631
612
  }
632
613
 
633
614
  if ( -d "../drizzled" )
638
619
  # Find the absolute path to the test directory
639
620
  if ( ! $opt_testdir )
640
621
  {
641
 
    $glob_drizzle_test_dir=  cwd();
 
622
    $glob_mysql_test_dir=  cwd();
642
623
  } 
643
624
  else
644
625
  {
645
 
    $glob_drizzle_test_dir= $opt_testdir;
 
626
    $glob_mysql_test_dir= $opt_testdir;
646
627
  }
647
 
  $default_vardir= "$glob_drizzle_test_dir/var";
648
 
  $default_top_srcdir= "$glob_drizzle_test_dir/..";
649
 
  $default_top_builddir= "$glob_drizzle_test_dir/..";
 
628
  $default_vardir= "$glob_mysql_test_dir/var";
 
629
  $default_top_srcdir= "$glob_mysql_test_dir/..";
 
630
  $default_top_builddir= "$glob_mysql_test_dir/..";
650
631
 
651
632
  if ( ! $opt_suitepath )
652
633
  {
653
 
    $glob_suite_path= "$glob_drizzle_test_dir/../plugin";
 
634
    $glob_suite_path= "$glob_mysql_test_dir/../plugin";
654
635
  }
655
636
  else
656
637
  {
657
638
    $glob_suite_path= $opt_suitepath;
658
639
  }
659
640
  # In most cases, the base directory we find everything relative to,
660
 
  # is the parent directory of the "drizzle-test" directory. For source
 
641
  # is the parent directory of the "mysql-test" directory. For source
661
642
  # distributions, TAR binary distributions and some other packages.
662
 
  $glob_basedir= dirname($glob_drizzle_test_dir);
 
643
  $glob_basedir= dirname($glob_mysql_test_dir);
663
644
 
664
645
  # In the RPM case, binaries and libraries are installed in the
665
646
  # default system locations, instead of having our own private base
666
 
  # directory. And we install "/usr/share/drizzle-test". Moving up one
667
 
  # more directory relative to "drizzle-test" gives us a usable base
 
647
  # directory. And we install "/usr/share/mysql-test". Moving up one
 
648
  # more directory relative to "mysql-test" gives us a usable base
668
649
  # directory for RPM installs.
669
650
  if ( ! $source_dist and ! -d "$glob_basedir/bin" )
670
651
  {
682
663
    $glob_builddir="..";
683
664
  }
684
665
 
685
 
  # Expect drizzle-bench to be located adjacent to the source tree, by default
686
 
  $glob_drizzle_bench_dir= "$glob_basedir/../drizzle-bench"
687
 
    unless defined $glob_drizzle_bench_dir;
688
 
  $glob_drizzle_bench_dir= undef
689
 
    unless -d $glob_drizzle_bench_dir;
 
666
  # Expect mysql-bench to be located adjacent to the source tree, by default
 
667
  $glob_mysql_bench_dir= "$glob_basedir/../mysql-bench"
 
668
    unless defined $glob_mysql_bench_dir;
 
669
  $glob_mysql_bench_dir= undef
 
670
    unless -d $glob_mysql_bench_dir;
690
671
 
691
 
  $glob_timers= dtr_init_timers();
 
672
  $glob_timers= mtr_init_timers();
692
673
 
693
674
  #
694
675
  # Find the drizzled executable to be able to find the drizzled version
696
677
  #
697
678
 
698
679
  # Look for the client binaries directory
699
 
  $path_client_bindir= dtr_path_exists("$glob_builddir/client",
 
680
  $path_client_bindir= mtr_path_exists("$glob_builddir/client",
700
681
                                       "$glob_basedir/client",
701
682
                                       "$glob_basedir/bin");
702
683
 
703
684
  if (!$opt_extern)
704
685
  {
705
 
    $exe_drizzled=       dtr_exe_exists ("$glob_basedir/drizzled/drizzled",
 
686
    $exe_drizzled=       mtr_exe_exists ("$glob_basedir/drizzled/drizzled",
706
687
                                       "$path_client_bindir/drizzled",
707
688
                                       "$glob_basedir/libexec/drizzled",
708
689
                                       "$glob_basedir/bin/drizzled",
710
691
                                       "$glob_builddir/drizzled/drizzled");
711
692
 
712
693
    # Use the drizzled found above to find out what features are available
713
 
    collect_drizzled_features();
 
694
    collect_mysqld_features();
714
695
  }
715
696
  else
716
697
  {
717
 
    $drizzled_variables{'port'}= 4427;
 
698
    $mysqld_variables{'port'}= 4427;
718
699
  }
719
700
 
720
701
  if (!$opt_engine)
734
715
  {
735
716
    if ( $arg =~ /^--skip-/ )
736
717
    {
737
 
      push(@opt_extra_drizzled_opt, $arg);
 
718
      push(@opt_extra_mysqld_opt, $arg);
738
719
    }
739
720
    elsif ( $arg =~ /^--$/ )
740
721
    {
755
736
  # --------------------------------------------------------------------------
756
737
  # Find out default storage engine being used(if any)
757
738
  # --------------------------------------------------------------------------
758
 
  foreach my $arg ( @opt_extra_drizzled_opt )
 
739
  foreach my $arg ( @opt_extra_mysqld_opt )
759
740
  {
760
741
    if ( $arg =~ /default-storage-engine=(\S+)/ )
761
742
    {
762
743
      $used_default_engine= $1;
763
744
    }
764
745
  }
765
 
  dtr_report("Using default engine '$used_default_engine'")
 
746
  mtr_report("Using default engine '$used_default_engine'")
766
747
    if defined $used_default_engine;
767
748
 
768
749
  # --------------------------------------------------------------------------
770
751
  # --------------------------------------------------------------------------
771
752
  if ( defined $opt_mem )
772
753
  {
773
 
    dtr_error("Can't use --mem and --vardir at the same time ")
 
754
    mtr_error("Can't use --mem and --vardir at the same time ")
774
755
      if $opt_vardir;
775
 
    dtr_error("Can't use --mem and --tmpdir at the same time ")
 
756
    mtr_error("Can't use --mem and --tmpdir at the same time ")
776
757
      if $opt_tmpdir;
777
758
 
778
759
    # Search through list of locations that are known
784
765
    {
785
766
      if ( -d $fs )
786
767
      {
787
 
        dtr_report("Using tmpfs in $fs");
 
768
        mtr_report("Using tmpfs in $fs");
788
769
        $opt_mem= "$fs/var";
789
 
        $opt_mem .= $opt_dtr_build_thread if $opt_dtr_build_thread;
 
770
        $opt_mem .= $opt_mtr_build_thread if $opt_mtr_build_thread;
790
771
        last;
791
772
      }
792
773
    }
835
816
# --------------------------------------------------------------------------
836
817
  if ( $opt_record and ! @opt_cases )
837
818
  {
838
 
    dtr_error("Will not run in record mode without a specific test case");
 
819
    mtr_error("Will not run in record mode without a specific test case");
839
820
  }
840
821
 
841
822
  if ( $opt_record )
856
837
  # --------------------------------------------------------------------------
857
838
  if ( $opt_gcov and ! $source_dist )
858
839
  {
859
 
    dtr_error("Coverage test needs the source - please use source dist");
 
840
    mtr_error("Coverage test needs the source - please use source dist");
860
841
  }
861
842
 
862
843
  # --------------------------------------------------------------------------
870
851
    $glob_debugger= 1;
871
852
    if ( $opt_extern )
872
853
    {
873
 
      dtr_error("Can't use --extern when using debugger");
 
854
      mtr_error("Can't use --extern when using debugger");
874
855
    }
875
856
  }
876
857
 
877
858
  # --------------------------------------------------------------------------
878
859
  # Check if special exe was selected for master or slave
879
860
  # --------------------------------------------------------------------------
880
 
  $exe_master_drizzled= $exe_master_drizzled || $exe_drizzled;
881
 
  $exe_slave_drizzled=  $exe_slave_drizzled  || $exe_drizzled;
 
861
  $exe_master_mysqld= $exe_master_mysqld || $exe_drizzled;
 
862
  $exe_slave_mysqld=  $exe_slave_mysqld  || $exe_drizzled;
882
863
 
883
864
  # --------------------------------------------------------------------------
884
865
  # Check valgrind arguments
885
866
  # --------------------------------------------------------------------------
886
867
  if ( $opt_valgrind or $opt_valgrind_path or @valgrind_args)
887
868
  {
888
 
    dtr_report("Turning on valgrind for all executables");
 
869
    mtr_report("Turning on valgrind for all executables");
889
870
    $opt_valgrind= 1;
890
 
    $opt_valgrind_drizzled= 1;
 
871
    $opt_valgrind_mysqld= 1;
891
872
    $opt_valgrind_drizzletest= 1;
892
 
    $ENV{'VALGRIND_RUN'} = '1';
893
873
  }
894
 
  elsif ( $opt_valgrind_drizzled )
 
874
  elsif ( $opt_valgrind_mysqld )
895
875
  {
896
 
    dtr_report("Turning on valgrind for drizzled(s) only");
 
876
    mtr_report("Turning on valgrind for mysqld(s) only");
897
877
    $opt_valgrind= 1;
898
878
  }
899
879
  elsif ( $opt_valgrind_drizzletest )
900
880
  {
901
 
    dtr_report("Turning on valgrind for drizzletest and drizzle_client_test only");
 
881
    mtr_report("Turning on valgrind for drizzletest and drizzle_client_test only");
902
882
    $opt_valgrind= 1;
903
883
  }
904
884
  elsif ( $opt_valgrind_drizzleslap )
905
885
  {
906
 
    dtr_report("Turning on valgrind for drizzleslap only");
 
886
    mtr_report("Turning on valgrind for drizzleslap only");
907
887
    $opt_valgrind= 1;
908
888
  }
909
889
 
910
890
  if ( $opt_callgrind )
911
891
  {
912
 
    dtr_report("Turning on valgrind with callgrind for drizzled(s)");
 
892
    mtr_report("Turning on valgrind with callgrind for mysqld(s)");
913
893
    $opt_valgrind= 1;
914
 
    $opt_valgrind_drizzled= 1;
 
894
    $opt_valgrind_mysqld= 1;
915
895
 
916
896
    # Set special valgrind options unless options passed on command line
917
897
    push(@valgrind_args, "--trace-children=yes")
920
900
 
921
901
  if ( $opt_massif )
922
902
  {
923
 
    dtr_report("Valgrind with Massif tool for drizzled(s)");
 
903
    mtr_report("Valgrind with Massif tool for drizzled(s)");
924
904
    $opt_valgrind= 1;
925
 
    $opt_valgrind_drizzled= 1;
 
905
    $opt_valgrind_mysqld= 1;
926
906
  }
927
907
 
928
908
  if ( $opt_valgrind )
931
911
    push(@valgrind_args, @default_valgrind_args)
932
912
      unless @valgrind_args;
933
913
 
934
 
    dtr_report("Running valgrind with options \"",
 
914
    mtr_report("Running valgrind with options \"",
935
915
               join(" ", @valgrind_args), "\"");
936
916
  }
937
917
 
959
939
    }
960
940
  }
961
941
 
 
942
  # On QNX, /tmp/dir/master.sock and /tmp/dir//master.sock seem to be
 
943
  # considered different, so avoid the extra slash (/) in the socket
 
944
  # paths.
 
945
  my $sockdir = $opt_tmpdir;
 
946
  $sockdir =~ s|/+$||;
 
947
 
 
948
  # On some operating systems, there is a limit to the length of a
 
949
  # UNIX domain socket's path far below PATH_MAX, so try to avoid long
 
950
  # socket path names.
 
951
  $sockdir = tempdir(CLEANUP => 0) if ( length($sockdir) >= 70 );
 
952
 
962
953
  $master->[0]=
963
954
  {
964
955
   pid            => 0,
967
958
   path_myddir    => "$opt_vardir/master-data",
968
959
   path_myerr     => "$opt_vardir/log/master.err",
969
960
   path_pid       => "$opt_vardir/run/master.pid",
970
 
   path_sock      => "$opt_vardir/master.sock",
 
961
   path_sock      => "$sockdir/master.sock",
971
962
   port           =>  $opt_master_myport,
972
963
   secondary_port =>  $opt_master_myport + $secondary_port_offset,
973
964
   start_timeout  =>  400, # enough time create innodb tables
983
974
   path_myddir    => "$opt_vardir/master1-data",
984
975
   path_myerr     => "$opt_vardir/log/master1.err",
985
976
   path_pid       => "$opt_vardir/run/master1.pid",
986
 
   path_sock      => "$opt_vardir/master1.sock",
 
977
   path_sock      => "$sockdir/master1.sock",
987
978
   port           => $opt_master_myport + 1,
988
979
   secondary_port => $opt_master_myport + 1 + $secondary_port_offset,
989
980
   start_timeout  => 400, # enough time create innodb tables
999
990
   path_myddir    => "$opt_vardir/slave-data",
1000
991
   path_myerr     => "$opt_vardir/log/slave.err",
1001
992
   path_pid       => "$opt_vardir/run/slave.pid",
1002
 
   path_sock      => "$opt_vardir/slave.sock",
 
993
   path_sock      => "$sockdir/slave.sock",
1003
994
   port           => $opt_slave_myport,
1004
995
   secondary_port => $opt_slave_myport + $secondary_port_offset,
1005
996
   start_timeout  => 400,
1015
1006
   path_myddir    => "$opt_vardir/slave1-data",
1016
1007
   path_myerr     => "$opt_vardir/log/slave1.err",
1017
1008
   path_pid       => "$opt_vardir/run/slave1.pid",
1018
 
   path_sock      => "$opt_vardir/slave1.sock",
 
1009
   path_sock      => "$sockdir/slave1.sock",
1019
1010
   port           => $opt_slave_myport + 1,
1020
1011
   secondary_port => $opt_slave_myport + 1 + $secondary_port_offset,
1021
1012
   start_timeout  => 300,
1031
1022
   path_myddir    => "$opt_vardir/slave2-data",
1032
1023
   path_myerr     => "$opt_vardir/log/slave2.err",
1033
1024
   path_pid       => "$opt_vardir/run/slave2.pid",
1034
 
   path_sock      => "$opt_vardir/slave2.sock",
 
1025
   path_sock      => "$sockdir/slave2.sock",
1035
1026
   port           => $opt_slave_myport + 2,
1036
1027
   secondary_port => $opt_slave_myport + 2 + $secondary_port_offset,
1037
1028
   start_timeout  => 300,
1050
1041
    warn("Currenty broken --extern");
1051
1042
 
1052
1043
    # Setup master->[0] with the settings for the extern server
1053
 
    $master->[0]->{'path_sock'}=  $opt_socket ? $opt_socket : "/tmp/drizzle.sock";
1054
 
    dtr_report("Using extern server at '$master->[0]->{path_sock}'");
 
1044
    $master->[0]->{'path_sock'}=  $opt_socket ? $opt_socket : "/tmp/mysql.sock";
 
1045
    mtr_report("Using extern server at '$master->[0]->{path_sock}'");
1055
1046
  }
1056
1047
  else
1057
1048
  {
1058
 
    dtr_error("--socket can only be used in combination with --extern")
 
1049
    mtr_error("--socket can only be used in combination with --extern")
1059
1050
      if $opt_socket;
1060
1051
  }
1061
1052
 
1071
1062
    # When both --valgrind and --debug is selected, send
1072
1063
    # all output to the trace file, making it possible to
1073
1064
    # see the exact location where valgrind complains
1074
 
    foreach my $drizzled (@{$master}, @{$slave})
 
1065
    foreach my $mysqld (@{$master}, @{$slave})
1075
1066
    {
1076
 
      my $sidx= $drizzled->{idx} ? "$drizzled->{idx}" : "";
1077
 
      $drizzled->{path_myerr}=
1078
 
        "$opt_vardir/log/" . $drizzled->{type} . "$sidx.trace";
 
1067
      my $sidx= $mysqld->{idx} ? "$mysqld->{idx}" : "";
 
1068
      $mysqld->{path_myerr}=
 
1069
        "$opt_vardir/log/" . $mysqld->{type} . "$sidx.trace";
1079
1070
    }
1080
1071
  }
1081
1072
}
1113
1104
#
1114
1105
# Note the MASTER_MYPORT has to be set the same in all 4.x and 5.x
1115
1106
# versions of this script, else a 4.0 test run might conflict with a
1116
 
# 5.1 test run, even if different DTR_BUILD_THREAD is used. This means
 
1107
# 5.1 test run, even if different MTR_BUILD_THREAD is used. This means
1117
1108
# all port numbers might not be used in this version of the script.
1118
1109
#
1119
1110
# Also note the limitation of ports we are allowed to hand out. This
1122
1113
# But a fairly safe range seems to be 5001 - 32767
1123
1114
#
1124
1115
 
1125
 
sub set_dtr_build_thread_ports($) {
1126
 
  my $dtr_build_thread= shift;
 
1116
sub set_mtr_build_thread_ports($) {
 
1117
  my $mtr_build_thread= shift;
1127
1118
 
1128
 
  if ( lc($dtr_build_thread) eq 'auto' ) {
 
1119
  if ( lc($mtr_build_thread) eq 'auto' ) {
1129
1120
    print "Requesting build thread... ";
1130
 
    $ENV{'DTR_BUILD_THREAD'} = $dtr_build_thread = dtr_require_unique_id_and_wait("/tmp/drizzle-test-ports", 200, 299);
1131
 
    print "got ".$dtr_build_thread."\n";
 
1121
    $ENV{'MTR_BUILD_THREAD'} = $mtr_build_thread = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299);
 
1122
    print "got ".$mtr_build_thread."\n";
1132
1123
  }
1133
1124
 
1134
 
  $dtr_build_thread= (($dtr_build_thread * 10) % 2000) - 1000;
 
1125
  $mtr_build_thread= (($mtr_build_thread * 10) % 2000) - 1000;
1135
1126
 
1136
1127
  # Up to two masters, up to three slaves
1137
1128
  # A magic value in command_line_setup depends on these equations.
1138
 
  $opt_master_myport=         gimme_a_good_port($dtr_build_thread + 9000); # and 1
 
1129
  $opt_master_myport=         gimme_a_good_port($mtr_build_thread + 9000); # and 1
1139
1130
 
1140
1131
 
1141
1132
  $opt_slave_myport=          gimme_a_good_port($opt_master_myport + 2);  # and 3 4
1142
1133
  $opt_memc_myport= gimme_a_good_port($opt_master_myport + 10);
1143
 
  $opt_pbms_myport= gimme_a_good_port($opt_master_myport + 11);
1144
1134
 
1145
1135
  if ( $opt_master_myport < 5001 or $opt_master_myport + 10 >= 32767 )
1146
1136
  {
1147
 
    dtr_error("DTR_BUILD_THREAD number results in a port",
 
1137
    mtr_error("MTR_BUILD_THREAD number results in a port",
1148
1138
              "outside 5001 - 32767",
1149
1139
              "($opt_master_myport - $opt_master_myport + 10)");
1150
1140
  }
1173
1163
##############################################################################
1174
1164
 
1175
1165
 
1176
 
sub collect_drizzled_features () {
 
1166
sub collect_mysqld_features () {
1177
1167
  my $found_variable_list_start= 0;
1178
1168
  my $tmpdir= tempdir(CLEANUP => 0); # Directory removed by this function
1179
1169
 
1193
1183
    {
1194
1184
      # Look for version
1195
1185
      my $exe_name= basename($exe_drizzled);
1196
 
      dtr_verbose("exe_name: $exe_name");
 
1186
      mtr_verbose("exe_name: $exe_name");
1197
1187
      if ( $line =~ /^\S*$exe_name\s\sVer\s([0-9]*)\.([0-9]*)\.([0-9]*)/ )
1198
1188
      {
1199
1189
        #print "Major: $1 Minor: $2 Build: $3\n";
1200
1190
        $drizzle_version_id= $1*10000 + $2*100 + $3;
1201
1191
        #print "drizzle_version_id: $drizzle_version_id\n";
1202
 
        dtr_report("Drizzle Version $1.$2.$3");
 
1192
        mtr_report("Drizzle Version $1.$2.$3");
1203
1193
      }
1204
1194
    }
1205
1195
  }
1206
1196
  rmtree($tmpdir);
1207
 
  dtr_error("Could not find version of Drizzle") unless $drizzle_version_id;
 
1197
  mtr_error("Could not find version of Drizzle") unless $drizzle_version_id;
1208
1198
 
1209
1199
}
1210
1200
 
1211
1201
 
1212
1202
sub run_query($$) {
1213
 
  my ($drizzled, $query)= @_;
 
1203
  my ($mysqld, $query)= @_;
1214
1204
 
1215
1205
  my $args;
1216
 
  dtr_init_args(\$args);
 
1206
  mtr_init_args(\$args);
1217
1207
 
1218
 
  dtr_add_arg($args, "--no-defaults");
1219
 
  dtr_add_arg($args, "--skip-stack-trace");
1220
 
  dtr_add_arg($args, "--user=%s", $opt_user);
1221
 
  dtr_add_arg($args, "--port=%d", $drizzled->{'port'});
1222
 
  dtr_add_arg($args, "--silent"); # Tab separated output
1223
 
  dtr_add_arg($args, "-e '%s'", $query);
 
1208
  mtr_add_arg($args, "--no-defaults");
 
1209
  mtr_add_arg($args, "--skip-stack-trace");
 
1210
  mtr_add_arg($args, "--user=%s", $opt_user);
 
1211
  mtr_add_arg($args, "--port=%d", $mysqld->{'port'});
 
1212
  mtr_add_arg($args, "--silent"); # Tab separated output
 
1213
  mtr_add_arg($args, "-e '%s'", $query);
1224
1214
 
1225
1215
  my $cmd= "$exe_drizzle " . join(' ', @$args);
1226
 
  dtr_verbose("cmd: $cmd");
 
1216
  mtr_verbose("cmd: $cmd");
1227
1217
  return `$cmd`;
1228
1218
}
1229
1219
 
1230
1220
 
1231
 
sub collect_drizzled_features_from_running_server ()
 
1221
sub collect_mysqld_features_from_running_server ()
1232
1222
{
1233
 
  my $list= run_query($master->[0], "use drizzle; SHOW VARIABLES");
 
1223
  my $list= run_query($master->[0], "use mysql; SHOW VARIABLES");
1234
1224
 
1235
1225
  foreach my $line (split('\n', $list))
1236
1226
  {
1238
1228
    if ( $line =~ /^([\S]+)[ \t]+(.*?)\r?$/ )
1239
1229
    {
1240
1230
      print "$1=\"$2\"\n";
1241
 
      $drizzled_variables{$1}= $2;
 
1231
      $mysqld_variables{$1}= $2;
1242
1232
    }
1243
1233
  }
1244
1234
}
1256
1246
    $exe_libtool= "../libtool";
1257
1247
    if ($opt_valgrind or $glob_debugger)
1258
1248
    {
1259
 
      dtr_report("Using \"$exe_libtool\" when running valgrind or debugger");
 
1249
      mtr_report("Using \"$exe_libtool\" when running valgrind or debugger");
1260
1250
    }
1261
1251
  }
1262
1252
 
1264
1254
  $exe_perror= "perror";
1265
1255
 
1266
1256
# Look for the client binaries
1267
 
  $exe_drizzledump= dtr_exe_exists("$path_client_bindir/drizzledump");
1268
 
  $exe_drizzleimport= dtr_exe_exists("$path_client_bindir/drizzleimport");
1269
 
  $exe_drizzle=          dtr_exe_exists("$path_client_bindir/drizzle");
1270
 
  $exe_drizzleadmin= dtr_exe_exists("$path_client_bindir/drizzleadmin");
 
1257
  $exe_drizzledump= mtr_exe_exists("$path_client_bindir/drizzledump");
 
1258
  $exe_drizzleimport= mtr_exe_exists("$path_client_bindir/drizzleimport");
 
1259
  $exe_drizzle=          mtr_exe_exists("$path_client_bindir/drizzle");
1271
1260
 
1272
1261
  if (!$opt_extern)
1273
1262
  {
1274
1263
# Look for SQL scripts directory
1275
1264
     if ( $drizzle_version_id >= 50100 )
1276
1265
     {
1277
 
         $exe_drizzleslap= dtr_exe_exists("$path_client_bindir/drizzleslap");
 
1266
         $exe_drizzleslap= mtr_exe_exists("$path_client_bindir/drizzleslap");
1278
1267
     }
1279
1268
  }
1280
1269
 
1281
1270
# Look for schema_writer
1282
1271
  {
1283
 
    $exe_schemawriter= dtr_exe_exists("$glob_basedir/drizzled/message/schema_writer",
 
1272
    $exe_schemawriter= mtr_exe_exists("$glob_basedir/drizzled/message/schema_writer",
1284
1273
                                      "$glob_builddir/drizzled/message/schema_writer");
1285
1274
  }
1286
1275
 
1287
1276
# Look for drizzletest executable
1288
1277
  {
1289
 
    $exe_drizzletest= dtr_exe_exists("$path_client_bindir/drizzletest");
 
1278
    $exe_drizzletest= mtr_exe_exists("$path_client_bindir/drizzletest");
1290
1279
  }
1291
1280
 
1292
1281
# Look for drizzle_client_test executable which may _not_ exist in
1293
1282
# some versions, test using it should be skipped
1294
1283
  {
1295
1284
    $exe_drizzle_client_test=
1296
 
      dtr_exe_maybe_exists(
 
1285
      mtr_exe_maybe_exists(
1297
1286
          "$glob_basedir/tests/drizzle_client_test",
1298
1287
          "$glob_basedir/bin/drizzle_client_test");
1299
1288
  }
1301
1290
# Look for bug25714 executable which may _not_ exist in
1302
1291
# some versions, test using it should be skipped
1303
1292
  $exe_bug25714=
1304
 
    dtr_exe_maybe_exists(
 
1293
    mtr_exe_maybe_exists(
1305
1294
        "$glob_basedir/tests/bug25714");
1306
1295
}
1307
1296
 
1308
1297
 
1309
1298
 
1310
 
sub generate_cmdline_drizzledump ($) {
1311
 
  my($drizzled) = @_;
 
1299
sub generate_cmdline_mysqldump ($) {
 
1300
  my($mysqld) = @_;
1312
1301
  return
1313
 
    dtr_native_path($exe_drizzledump) .
 
1302
    mtr_native_path($exe_drizzledump) .
1314
1303
      " --no-defaults -uroot " .
1315
 
      "--port=$drizzled->{'port'} ";
 
1304
      "--port=$mysqld->{'port'} ";
1316
1305
}
1317
1306
 
1318
1307
sub generate_cmdline_drizzle ($) {
1319
 
  my($drizzled) = @_;
 
1308
  my($mysqld) = @_;
1320
1309
  return
1321
 
    dtr_native_path($exe_drizzle) .
1322
 
    " -uroot --port=$drizzled->{'port'} ";
 
1310
    mtr_native_path($exe_drizzle) .
 
1311
    " -uroot --port=$mysqld->{'port'} ";
1323
1312
}
1324
1313
 
1325
 
sub generate_cmdline_drizzleadmin ($) {
1326
 
  my($drizzled) = @_;
1327
 
  return
1328
 
    dtr_native_path($exe_drizzleadmin) .
1329
 
    " -uroot --port=$drizzled->{'port'} ";
1330
 
}
1331
1314
 
1332
1315
##############################################################################
1333
1316
#
1341
1324
  my $exe= $exe_drizzle_client_test;
1342
1325
 
1343
1326
  my $args;
1344
 
  dtr_init_args(\$args);
 
1327
  mtr_init_args(\$args);
1345
1328
  if ( $opt_valgrind_drizzletest )
1346
1329
  {
1347
1330
    valgrind_arguments($args, \$exe);
1348
1331
  }
1349
1332
 
1350
 
  dtr_add_arg($args, "--no-defaults");
1351
 
  dtr_add_arg($args, "--testcase");
1352
 
  dtr_add_arg($args, "--user=root");
1353
 
  dtr_add_arg($args, "--port=$master->[0]->{'port'}");
 
1333
  mtr_add_arg($args, "--no-defaults");
 
1334
  mtr_add_arg($args, "--testcase");
 
1335
  mtr_add_arg($args, "--user=root");
 
1336
  mtr_add_arg($args, "--port=$master->[0]->{'port'}");
1354
1337
 
1355
1338
  if ( $opt_extern || $drizzle_version_id >= 50000 )
1356
1339
  {
1357
 
    dtr_add_arg($args, "--vardir=$opt_vardir")
 
1340
    mtr_add_arg($args, "--vardir=$opt_vardir")
1358
1341
  }
1359
1342
 
1360
1343
  if ( $opt_debug )
1361
1344
  {
1362
 
    dtr_add_arg($args,
 
1345
    mtr_add_arg($args,
1363
1346
      "--debug=d:t:A,$path_vardir_trace/log/drizzle_client_test.trace");
1364
1347
  }
1365
1348
 
1367
1350
}
1368
1351
 
1369
1352
 
1370
 
# Note that some env is setup in spawn/run, in "dtr_process.pl"
 
1353
# Note that some env is setup in spawn/run, in "mtr_process.pl"
1371
1354
 
1372
1355
sub environment_setup () {
1373
1356
 
1406
1389
  my $deb_version;
1407
1390
  if (  $opt_valgrind and -d $debug_libraries_path and
1408
1391
        (! -e '/etc/debian_version' or
1409
 
         ($deb_version= dtr_grab_file('/etc/debian_version')) !~ /^[0-9]+\.[0-9]$/ or
 
1392
         ($deb_version= mtr_grab_file('/etc/debian_version')) !~ /^[0-9]+\.[0-9]$/ or
1410
1393
         $deb_version > 3.1 ) )
1411
1394
  {
1412
1395
    push(@ld_library_paths, $debug_libraries_path);
1416
1399
                                $ENV{'LD_LIBRARY_PATH'} ?
1417
1400
                                split(':', $ENV{'LD_LIBRARY_PATH'}) : (),
1418
1401
                                @ld_library_paths);
1419
 
  dtr_debug("LD_LIBRARY_PATH: $ENV{'LD_LIBRARY_PATH'}");
 
1402
  mtr_debug("LD_LIBRARY_PATH: $ENV{'LD_LIBRARY_PATH'}");
1420
1403
 
1421
1404
  $ENV{'DYLD_LIBRARY_PATH'}= join(":", @ld_library_paths,
1422
1405
                                  $ENV{'DYLD_LIBRARY_PATH'} ?
1423
1406
                                  split(':', $ENV{'DYLD_LIBRARY_PATH'}) : ());
1424
 
  dtr_debug("DYLD_LIBRARY_PATH: $ENV{'DYLD_LIBRARY_PATH'}");
 
1407
  mtr_debug("DYLD_LIBRARY_PATH: $ENV{'DYLD_LIBRARY_PATH'}");
1425
1408
 
1426
1409
  # The environment variable used for shared libs on AIX
1427
1410
  $ENV{'SHLIB_PATH'}= join(":", @ld_library_paths,
1428
1411
                           $ENV{'SHLIB_PATH'} ?
1429
1412
                           split(':', $ENV{'SHLIB_PATH'}) : ());
1430
 
  dtr_debug("SHLIB_PATH: $ENV{'SHLIB_PATH'}");
 
1413
  mtr_debug("SHLIB_PATH: $ENV{'SHLIB_PATH'}");
1431
1414
 
1432
1415
  # The environment variable used for shared libs on hp-ux
1433
1416
  $ENV{'LIBPATH'}= join(":", @ld_library_paths,
1434
1417
                        $ENV{'LIBPATH'} ?
1435
1418
                        split(':', $ENV{'LIBPATH'}) : ());
1436
 
  dtr_debug("LIBPATH: $ENV{'LIBPATH'}");
 
1419
  mtr_debug("LIBPATH: $ENV{'LIBPATH'}");
1437
1420
 
1438
1421
  # --------------------------------------------------------------------------
1439
1422
  # Also command lines in .opt files may contain env vars
1444
1427
  $ENV{'UMASK_DIR'}=          "0770"; # The octal *string*
1445
1428
  
1446
1429
  #
1447
 
  # drizzle tests can produce output in various character sets
 
1430
  # MySQL tests can produce output in various character sets
1448
1431
  # (especially, ctype_xxx.test). To avoid confusing Perl
1449
1432
  # with output which is incompatible with the current locale
1450
1433
  # settings, we reset the current values of LC_ALL and LC_CTYPE to "C".
1456
1439
  
1457
1440
  $ENV{'LC_COLLATE'}=         "C";
1458
1441
  $ENV{'USE_RUNNING_SERVER'}= $opt_extern;
1459
 
  $ENV{'DRIZZLE_TEST_DIR'}=     collapse_path($glob_drizzle_test_dir);
1460
 
  $ENV{'DRIZZLETEST_VARDIR'}=   $opt_vardir;
 
1442
  $ENV{'DRIZZLE_TEST_DIR'}=     collapse_path($glob_mysql_test_dir);
 
1443
  $ENV{'MYSQLTEST_VARDIR'}=   $opt_vardir;
1461
1444
  $ENV{'TOP_SRCDIR'}= $opt_top_srcdir;
1462
1445
  $ENV{'TOP_BUILDDIR'}= $opt_top_builddir;
1463
1446
  $ENV{'DRIZZLE_TMP_DIR'}=      $opt_tmpdir;
1470
1453
  $ENV{'SLAVE_MYPORT1'}=      $slave->[1]->{'port'};
1471
1454
  $ENV{'SLAVE_MYPORT2'}=      $slave->[2]->{'port'};
1472
1455
  $ENV{'MC_PORT'}=            $opt_memc_myport;
1473
 
  $ENV{'PBMS_PORT'}=            $opt_pbms_myport;
1474
 
  $ENV{'DRIZZLE_TCP_PORT'}=     $drizzled_variables{'drizzle-protocol.port'};
1475
 
 
1476
 
  $ENV{'DTR_BUILD_THREAD'}=      $opt_dtr_build_thread;
1477
 
 
1478
 
  $ENV{'EXE_DRIZZLE'}=          $exe_drizzle;
 
1456
  $ENV{'DRIZZLE_TCP_PORT'}=     $mysqld_variables{'drizzle-protocol.port'};
 
1457
 
 
1458
  $ENV{'MTR_BUILD_THREAD'}=      $opt_mtr_build_thread;
 
1459
 
 
1460
  $ENV{'EXE_MYSQL'}=          $exe_drizzle;
1479
1461
 
1480
1462
 
1481
1463
  # ----------------------------------------------------
1482
1464
  # Setup env to childs can execute myqldump
1483
1465
  # ----------------------------------------------------
1484
 
  my $cmdline_drizzleadmin= generate_cmdline_drizzleadmin($master->[0]);
1485
 
  my $cmdline_drizzledump= generate_cmdline_drizzledump($master->[0]);
1486
 
  my $cmdline_drizzledumpslave= generate_cmdline_drizzledump($slave->[0]);
1487
 
  my $cmdline_drizzledump_secondary= dtr_native_path($exe_drizzledump) .
 
1466
  my $cmdline_mysqldump= generate_cmdline_mysqldump($master->[0]);
 
1467
  my $cmdline_mysqldumpslave= generate_cmdline_mysqldump($slave->[0]);
 
1468
  my $cmdline_mysqldump_secondary= mtr_native_path($exe_drizzledump) .
1488
1469
       " --no-defaults -uroot " .
1489
1470
       " --port=$master->[0]->{'secondary_port'} ";
1490
1471
 
1491
1472
  if ( $opt_debug )
1492
1473
  {
1493
 
    $cmdline_drizzledump .=
1494
 
      " --debug=d:t:A,$path_vardir_trace/log/drizzledump-master.trace";
1495
 
    $cmdline_drizzledumpslave .=
1496
 
      " --debug=d:t:A,$path_vardir_trace/log/drizzledump-slave.trace";
1497
 
    $cmdline_drizzledump_secondary .=
1498
 
      " --debug=d:t:A,$path_vardir_trace/log/drizzledump-drizzle.trace";
 
1474
    $cmdline_mysqldump .=
 
1475
      " --debug=d:t:A,$path_vardir_trace/log/mysqldump-master.trace";
 
1476
    $cmdline_mysqldumpslave .=
 
1477
      " --debug=d:t:A,$path_vardir_trace/log/mysqldump-slave.trace";
 
1478
    $cmdline_mysqldump_secondary .=
 
1479
      " --debug=d:t:A,$path_vardir_trace/log/mysqldump-mysql.trace";
1499
1480
  }
1500
 
  $ENV{'DRIZZLE_ADMIN'}= $cmdline_drizzleadmin;
1501
 
  $ENV{'DRIZZLE_DUMP'}= $cmdline_drizzledump;
1502
 
  $ENV{'DRIZZLE_DUMP_SLAVE'}= $cmdline_drizzledumpslave;
1503
 
  $ENV{'DRIZZLE_DUMP_SECONDARY'}= $cmdline_drizzledump_secondary;
 
1481
  $ENV{'DRIZZLE_DUMP'}= $cmdline_mysqldump;
 
1482
  $ENV{'DRIZZLE_DUMP_SLAVE'}= $cmdline_mysqldumpslave;
 
1483
  $ENV{'DRIZZLE_DUMP_SECONDARY'}= $cmdline_mysqldump_secondary;
1504
1484
 
1505
1485
  # ----------------------------------------------------
1506
1486
  # Setup env so we can execute drizzle client
1507
1487
  # ----------------------------------------------------
1508
 
  #my $cmdline_drizzle = generate_cmdline_drizzle($master->[0]);
1509
 
  #$ENV{'DRIZZLE'}= $cmdline_drizzle;
 
1488
  my $cmdline_drizzle = generate_cmdline_drizzle($master->[0]);
 
1489
  $ENV{'DRIZZLE'}= $cmdline_drizzle;
1510
1490
 
1511
1491
  # ----------------------------------------------------
1512
 
  # Setup env so childs can execute drizzleslap
 
1492
  # Setup env so childs can execute mysqlslap
1513
1493
  # ----------------------------------------------------
1514
1494
  if ( $exe_drizzleslap )
1515
1495
  {
1520
1500
      $cmdline_drizzleslap= "$glob_basedir/libtool --mode=execute valgrind --log-file=$opt_vardir/log/drizzleslap-valgrind.log ";
1521
1501
    }
1522
1502
    $cmdline_drizzleslap .=
1523
 
      dtr_native_path($exe_drizzleslap) .
 
1503
      mtr_native_path($exe_drizzleslap) .
1524
1504
      " -uroot " .
1525
1505
      "--port=$master->[0]->{'port'} ";
1526
1506
    my $cmdline_drizzleslap_secondary=
1527
 
      dtr_native_path($exe_drizzleslap) .
 
1507
      mtr_native_path($exe_drizzleslap) .
1528
1508
      " -uroot " .
1529
1509
      " --port=$master->[0]->{'secondary_port'} ";
1530
1510
 
1542
1522
 
1543
1523
 
1544
1524
  # ----------------------------------------------------
1545
 
  # Setup env so childs can execute drizzleimport
 
1525
  # Setup env so childs can execute mysqlimport
1546
1526
  # ----------------------------------------------------
1547
 
  my $cmdline_drizzleimport=
1548
 
    dtr_native_path($exe_drizzleimport) .
 
1527
  my $cmdline_mysqlimport=
 
1528
    mtr_native_path($exe_drizzleimport) .
1549
1529
    " -uroot " .
1550
1530
    "--port=$master->[0]->{'port'} ";
1551
1531
 
1552
1532
  if ( $opt_debug )
1553
1533
  {
1554
 
    $cmdline_drizzleimport .=
1555
 
      " --debug=d:t:A,$path_vardir_trace/log/drizzleimport.trace";
 
1534
    $cmdline_mysqlimport .=
 
1535
      " --debug=d:t:A,$path_vardir_trace/log/mysqlimport.trace";
1556
1536
  }
1557
 
  $ENV{'DRIZZLE_IMPORT'}= $cmdline_drizzleimport;
1558
 
 
1559
 
 
1560
 
  # ----------------------------------------------------
1561
 
  # Setup env so childs can execute drizzle
1562
 
  # ----------------------------------------------------
1563
 
  my $cmdline_drizzle=
1564
 
    dtr_native_path($exe_drizzle) .
 
1537
  $ENV{'DRIZZLE_IMPORT'}= $cmdline_mysqlimport;
 
1538
 
 
1539
 
 
1540
  # ----------------------------------------------------
 
1541
  # Setup env so childs can execute mysql
 
1542
  # ----------------------------------------------------
 
1543
  my $cmdline_mysql=
 
1544
    mtr_native_path($exe_drizzle) .
1565
1545
    " --no-defaults --host=localhost  --user=root --password= " .
1566
1546
    "--port=$master->[0]->{'port'} ";
1567
1547
  my $cmdline_drizzle_secondary=
1568
 
    dtr_native_path($exe_drizzle) .
 
1548
    mtr_native_path($exe_drizzle) .
1569
1549
    " --no-defaults --host=localhost  --user=root --password= " .
1570
1550
    " --port=$master->[0]->{'secondary_port'} ";
1571
1551
 
1572
 
  $ENV{'DRIZZLE'}= $cmdline_drizzle;
 
1552
  $ENV{'MYSQL'}= $cmdline_mysql;
1573
1553
  $ENV{'DRIZZLE_SECONDARY'}= $cmdline_drizzle_secondary;
1574
1554
 
1575
1555
  # ----------------------------------------------------
1584
1564
 
1585
1565
 
1586
1566
  # ----------------------------------------------------
1587
 
  # Setup env so childs can execute drizzle_fix_system_tables
 
1567
  # Setup env so childs can execute mysql_fix_system_tables
1588
1568
  # ----------------------------------------------------
1589
1569
  #if ( !$opt_extern)
1590
1570
  if ( 0 )
1591
1571
  {
1592
 
    my $cmdline_drizzle_fix_system_tables=
 
1572
    my $cmdline_mysql_fix_system_tables=
1593
1573
      "$exe_drizzle_fix_system_tables --no-defaults --host=localhost " .
1594
1574
      "--user=root --password= " .
1595
1575
      "--basedir=$glob_basedir --bindir=$path_client_bindir --verbose " .
1596
1576
      "--port=$master->[0]->{'port'} ";
1597
 
    $ENV{'DRIZZLE_FIX_SYSTEM_TABLES'}=  $cmdline_drizzle_fix_system_tables;
 
1577
    $ENV{'DRIZZLE_FIX_SYSTEM_TABLES'}=  $cmdline_mysql_fix_system_tables;
1598
1578
 
1599
1579
  }
1600
1580
 
1601
1581
  # ----------------------------------------------------
1602
1582
  # Setup env so childs can shutdown the server
1603
1583
  # ----------------------------------------------------
1604
 
  $ENV{'DRIZZLED_SHUTDOWN'}= dtr_native_path($exe_drizzle);
 
1584
  $ENV{'DRIZZLED_SHUTDOWN'}= mtr_native_path($exe_drizzle);
1605
1585
 
1606
1586
  # ----------------------------------------------------
1607
1587
  # Setup env so childs can execute perror  
1608
1588
  # ----------------------------------------------------
1609
 
  $ENV{'MY_PERROR'}= dtr_native_path($exe_perror);
 
1589
  $ENV{'MY_PERROR'}= mtr_native_path($exe_perror);
1610
1590
 
1611
1591
  # ----------------------------------------------------
1612
 
  # Add the path where drizzled will find ha_example.so
 
1592
  # Add the path where mysqld will find ha_example.so
1613
1593
  # ----------------------------------------------------
1614
1594
  $ENV{'EXAMPLE_PLUGIN'}=
1615
1595
    ($lib_example_plugin ? basename($lib_example_plugin) : "");
1621
1601
  # ----------------------------------------------------
1622
1602
  if (!$opt_extern)
1623
1603
  {
1624
 
    print "Using DTR_BUILD_THREAD      = $ENV{DTR_BUILD_THREAD}\n";
 
1604
    print "Using MTR_BUILD_THREAD      = $ENV{MTR_BUILD_THREAD}\n";
1625
1605
    print "Using MASTER_MYPORT         = $ENV{MASTER_MYPORT}\n";
1626
1606
    print "Using MASTER_MYPORT1        = $ENV{MASTER_MYPORT1}\n";
1627
1607
    print "Using SLAVE_MYPORT          = $ENV{SLAVE_MYPORT}\n";
1628
1608
    print "Using SLAVE_MYPORT1         = $ENV{SLAVE_MYPORT1}\n";
1629
1609
    print "Using SLAVE_MYPORT2         = $ENV{SLAVE_MYPORT2}\n";
1630
1610
    print "Using MC_PORT               = $ENV{MC_PORT}\n";
1631
 
    print "Using PBMS_PORT             = $ENV{PBMS_PORT}\n";
1632
1611
  }
1633
1612
 
1634
1613
  # Create an environment variable to make it possible
1652
1631
 
1653
1632
sub handle_int_signal () {
1654
1633
  $SIG{INT}= 'DEFAULT';         # If we get a ^C again, we die...
1655
 
  dtr_warning("got INT signal, cleaning up.....");
 
1634
  mtr_warning("got INT signal, cleaning up.....");
1656
1635
  stop_all_servers();
1657
 
  dtr_error("We die from ^C signal from user");
 
1636
  mtr_error("We die from ^C signal from user");
1658
1637
}
1659
1638
 
1660
1639
 
1666
1645
 
1667
1646
sub kill_running_servers () {
1668
1647
  {
1669
 
    # Ensure that no old drizzled test servers are running
 
1648
    # Ensure that no old mysqld test servers are running
1670
1649
    # This is different from terminating processes we have
1671
1650
    # started from this run of the script, this is terminating
1672
1651
    # leftovers from previous runs.
1673
 
    dtr_kill_leftovers();
 
1652
    mtr_kill_leftovers();
1674
1653
   }
1675
1654
}
1676
1655
 
1680
1659
#
1681
1660
sub remove_stale_vardir () {
1682
1661
 
1683
 
  dtr_report("Removing Stale Files");
 
1662
  mtr_report("Removing Stale Files");
1684
1663
 
1685
1664
  # Safety!
1686
 
  dtr_error("No, don't remove the vardir when running with --extern")
 
1665
  mtr_error("No, don't remove the vardir when running with --extern")
1687
1666
    if $opt_extern;
1688
1667
 
1689
 
  dtr_verbose("opt_vardir: $opt_vardir");
 
1668
  mtr_verbose("opt_vardir: $opt_vardir");
1690
1669
  if ( $opt_vardir eq $default_vardir )
1691
1670
  {
1692
1671
    #
1693
 
    # Running with "var" in drizzle-test dir
 
1672
    # Running with "var" in mysql-test dir
1694
1673
    #
1695
1674
    if ( -l $opt_vardir)
1696
1675
    {
1699
1678
      if ( $opt_mem and readlink($opt_vardir) eq $opt_mem )
1700
1679
      {
1701
1680
        # Remove the directory which the link points at
1702
 
        dtr_verbose("Removing " . readlink($opt_vardir));
1703
 
        dtr_rmtree(readlink($opt_vardir));
 
1681
        mtr_verbose("Removing " . readlink($opt_vardir));
 
1682
        mtr_rmtree(readlink($opt_vardir));
1704
1683
 
1705
1684
        # Remove the "var" symlink
1706
 
        dtr_verbose("unlink($opt_vardir)");
 
1685
        mtr_verbose("unlink($opt_vardir)");
1707
1686
        unlink($opt_vardir);
1708
1687
      }
1709
1688
      elsif ( $opt_mem )
1710
1689
      {
1711
1690
        # Just remove the "var" symlink
1712
 
        dtr_report("WARNING: Removing '$opt_vardir' symlink it's wrong");
 
1691
        mtr_report("WARNING: Removing '$opt_vardir' symlink it's wrong");
1713
1692
 
1714
 
        dtr_verbose("unlink($opt_vardir)");
 
1693
        mtr_verbose("unlink($opt_vardir)");
1715
1694
        unlink($opt_vardir);
1716
1695
      }
1717
1696
      else
1718
1697
      {
1719
 
        # Some users creates a soft link in drizzle-test/var to another area
 
1698
        # Some users creates a soft link in mysql-test/var to another area
1720
1699
        # - allow it, but remove all files in it
1721
1700
 
1722
 
        dtr_report("WARNING: Using the 'drizzle-test/var' symlink");
 
1701
        mtr_report("WARNING: Using the 'mysql-test/var' symlink");
1723
1702
 
1724
1703
        # Make sure the directory where it points exist
1725
 
        dtr_error("The destination for symlink $opt_vardir does not exist")
 
1704
        mtr_error("The destination for symlink $opt_vardir does not exist")
1726
1705
          if ! -d readlink($opt_vardir);
1727
1706
 
1728
1707
        foreach my $bin ( glob("$opt_vardir/*") )
1729
1708
        {
1730
 
          dtr_verbose("Removing bin $bin");
1731
 
          dtr_rmtree($bin);
 
1709
          mtr_verbose("Removing bin $bin");
 
1710
          mtr_rmtree($bin);
1732
1711
        }
1733
1712
      }
1734
1713
    }
1735
1714
    else
1736
1715
    {
1737
1716
      # Remove the entire "var" dir
1738
 
      dtr_verbose("Removing $opt_vardir/");
1739
 
      dtr_rmtree("$opt_vardir/");
 
1717
      mtr_verbose("Removing $opt_vardir/");
 
1718
      mtr_rmtree("$opt_vardir/");
1740
1719
    }
1741
1720
 
1742
1721
    if ( $opt_mem )
1744
1723
      # A symlink from var/ to $opt_mem will be set up
1745
1724
      # remove the $opt_mem dir to assure the symlink
1746
1725
      # won't point at an old directory
1747
 
      dtr_verbose("Removing $opt_mem");
1748
 
      dtr_rmtree($opt_mem);
 
1726
      mtr_verbose("Removing $opt_mem");
 
1727
      mtr_rmtree($opt_mem);
1749
1728
    }
1750
1729
 
1751
1730
  }
1755
1734
    # Running with "var" in some other place
1756
1735
    #
1757
1736
 
1758
 
    # Remove the var/ dir in drizzle-test dir if any
 
1737
    # Remove the var/ dir in mysql-test dir if any
1759
1738
    # this could be an old symlink that shouldn't be there
1760
 
    dtr_verbose("Removing $default_vardir");
1761
 
    dtr_rmtree($default_vardir);
 
1739
    mtr_verbose("Removing $default_vardir");
 
1740
    mtr_rmtree($default_vardir);
1762
1741
 
1763
1742
    # Remove the "var" dir
1764
 
    dtr_verbose("Removing $opt_vardir/");
1765
 
    dtr_rmtree("$opt_vardir/");
 
1743
    mtr_verbose("Removing $opt_vardir/");
 
1744
    mtr_rmtree("$opt_vardir/");
1766
1745
  }
1767
1746
}
1768
1747
 
1770
1749
# Create var and the directories needed in var
1771
1750
#
1772
1751
sub setup_vardir() {
1773
 
  dtr_report("Creating Directories");
 
1752
  mtr_report("Creating Directories");
1774
1753
 
1775
1754
  if ( $opt_vardir eq $default_vardir )
1776
1755
  {
1777
1756
    #
1778
 
    # Running with "var" in drizzle-test dir
 
1757
    # Running with "var" in mysql-test dir
1779
1758
    #
1780
1759
    if ( -l $opt_vardir )
1781
1760
    {
1782
1761
      #  it's a symlink
1783
1762
 
1784
1763
      # Make sure the directory where it points exist
1785
 
      dtr_error("The destination for symlink $opt_vardir does not exist")
 
1764
      mtr_error("The destination for symlink $opt_vardir does not exist")
1786
1765
        if ! -d readlink($opt_vardir);
1787
1766
    }
1788
1767
    elsif ( $opt_mem )
1789
1768
    {
1790
1769
      # Runinng with "var" as a link to some "memory" location, normally tmpfs
1791
 
      dtr_verbose("Creating $opt_mem");
 
1770
      mtr_verbose("Creating $opt_mem");
1792
1771
      mkpath($opt_mem);
1793
1772
 
1794
 
      dtr_report("Symlinking 'var' to '$opt_mem'");
 
1773
      mtr_report("Symlinking 'var' to '$opt_mem'");
1795
1774
      symlink($opt_mem, $opt_vardir);
1796
1775
    }
1797
1776
  }
1798
1777
 
1799
1778
  if ( ! -d $opt_vardir )
1800
1779
  {
1801
 
    dtr_verbose("Creating $opt_vardir");
 
1780
    mtr_verbose("Creating $opt_vardir");
1802
1781
    mkpath($opt_vardir);
1803
1782
  }
1804
1783
 
1805
1784
  # Ensure a proper error message if vardir couldn't be created
1806
1785
  unless ( -d $opt_vardir and -w $opt_vardir )
1807
1786
  {
1808
 
    dtr_error("Writable 'var' directory is needed, use the " .
 
1787
    mtr_error("Writable 'var' directory is needed, use the " .
1809
1788
              "'--vardir=<path>' option");
1810
1789
  }
1811
1790
 
1825
1804
  }
1826
1805
 
1827
1806
  # Make a link std_data_ln in var/ that points to std_data
1828
 
  symlink(collapse_path("$glob_drizzle_test_dir/std_data"),
 
1807
  symlink(collapse_path("$glob_mysql_test_dir/std_data"),
1829
1808
          "$opt_vardir/std_data_ln");
1830
1809
 
1831
1810
  symlink(collapse_path("$glob_suite_path/filesystem_engine/tests/t"),
1847
1826
  # Check if running as root
1848
1827
  # i.e a file can be read regardless what mode we set it to
1849
1828
  my $test_file= "$opt_vardir/test_running_as_root.txt";
1850
 
  dtr_tofile($test_file, "Drizzle");
 
1829
  mtr_tofile($test_file, "MySQL");
1851
1830
  chmod(oct("0000"), $test_file);
1852
1831
 
1853
1832
  my $result="";
1863
1842
  my $file_mode= (stat($test_file))[2] & 07777;
1864
1843
 
1865
1844
  $ENV{'DRIZZLE_TEST_ROOT'}= "NO";
1866
 
  dtr_verbose("result: $result, file_mode: $file_mode");
1867
 
  if ($result eq "Drizzle" && $file_mode == 0)
 
1845
  mtr_verbose("result: $result, file_mode: $file_mode");
 
1846
  if ($result eq "MySQL" && $file_mode == 0)
1868
1847
  {
1869
 
    dtr_warning("running this script as _root_ will cause some " .
 
1848
    mtr_warning("running this script as _root_ will cause some " .
1870
1849
                "tests to be skipped");
1871
1850
    $ENV{'DRIZZLE_TEST_ROOT'}= "YES";
1872
1851
  }
1878
1857
 
1879
1858
 
1880
1859
sub check_debug_support ($) {
1881
 
  my $drizzled_variables= shift;
 
1860
  my $mysqld_variables= shift;
1882
1861
 
1883
 
  if ( ! $drizzled_variables->{'debug'} )
 
1862
  if ( ! $mysqld_variables->{'debug'} )
1884
1863
  {
1885
 
    #dtr_report("Binaries are not debug compiled");
 
1864
    #mtr_report("Binaries are not debug compiled");
1886
1865
    $debug_compiled_binaries= 0;
1887
1866
 
1888
1867
    if ( $opt_debug )
1889
1868
    {
1890
 
      dtr_error("Can't use --debug, binaries does not support it");
 
1869
      mtr_error("Can't use --debug, binaries does not support it");
1891
1870
    }
1892
1871
    return;
1893
1872
  }
1894
 
  dtr_report("Binaries are debug compiled");
 
1873
  mtr_report("Binaries are debug compiled");
1895
1874
  $debug_compiled_binaries= 1;
1896
1875
}
1897
1876
 
1908
1887
  my $args;
1909
1888
 
1910
1889
  {
1911
 
    drizzled_start($master->[0],[],[]);
 
1890
    mysqld_start($master->[0],[],[]);
1912
1891
    if ( ! $master->[0]->{'pid'} )
1913
1892
    {
1914
 
      dtr_error("Can't start the drizzled server");
 
1893
      mtr_error("Can't start the mysqld server");
1915
1894
    }
1916
1895
  }
1917
1896
 
1918
 
  dtr_init_args(\$args);
 
1897
  mtr_init_args(\$args);
1919
1898
 
1920
 
  dtr_add_arg($args, "--user=%s", $opt_user);
 
1899
  mtr_add_arg($args, "--user=%s", $opt_user);
1921
1900
 
1922
1901
  if ( $opt_small_bench )
1923
1902
  {
1924
 
    dtr_add_arg($args, "--small-test");
1925
 
    dtr_add_arg($args, "--small-tables");
 
1903
    mtr_add_arg($args, "--small-test");
 
1904
    mtr_add_arg($args, "--small-tables");
1926
1905
  }
1927
1906
 
1928
 
  chdir($glob_drizzle_bench_dir)
1929
 
    or dtr_error("Couldn't chdir to '$glob_drizzle_bench_dir': $!");
 
1907
  chdir($glob_mysql_bench_dir)
 
1908
    or mtr_error("Couldn't chdir to '$glob_mysql_bench_dir': $!");
1930
1909
 
1931
1910
  if ( ! $benchmark )
1932
1911
  {
1933
 
    dtr_run("$glob_drizzle_bench_dir/run-all-tests", $args, "", "", "", "");
 
1912
    mtr_run("$glob_mysql_bench_dir/run-all-tests", $args, "", "", "", "");
1934
1913
    # FIXME check result code?!
1935
1914
  }
1936
1915
  elsif ( -x $benchmark )
1937
1916
  {
1938
 
    dtr_run("$glob_drizzle_bench_dir/$benchmark", $args, "", "", "", "");
 
1917
    mtr_run("$glob_mysql_bench_dir/$benchmark", $args, "", "", "", "");
1939
1918
    # FIXME check result code?!
1940
1919
  }
1941
1920
  else
1942
1921
  {
1943
 
    dtr_error("Benchmark $benchmark not found");
 
1922
    mtr_error("Benchmark $benchmark not found");
1944
1923
  }
1945
1924
 
1946
 
  chdir($glob_drizzle_test_dir);          # Go back
 
1925
  chdir($glob_mysql_test_dir);          # Go back
1947
1926
 
1948
1927
  {
1949
1928
    stop_masters();
1960
1939
sub run_tests () {
1961
1940
  my ($tests)= @_;
1962
1941
 
1963
 
  dtr_print_thick_line();
1964
 
 
1965
 
  dtr_timer_start($glob_timers,"suite", 60 * $opt_suite_timeout);
1966
 
 
1967
 
  dtr_report_tests_not_skipped_though_disabled($tests);
1968
 
 
1969
 
  dtr_print_header();
 
1942
  mtr_print_thick_line();
 
1943
 
 
1944
  mtr_timer_start($glob_timers,"suite", 60 * $opt_suite_timeout);
 
1945
 
 
1946
  mtr_report_tests_not_skipped_though_disabled($tests);
 
1947
 
 
1948
  mtr_print_header();
1970
1949
 
1971
1950
  foreach my $tinfo ( @$tests )
1972
1951
  {
1977
1956
          next;
1978
1957
        }
1979
1958
 
1980
 
      dtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout);
 
1959
      mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout);
1981
1960
      run_testcase($tinfo);
1982
 
      dtr_timer_stop($glob_timers,"testcase");
 
1961
      mtr_timer_stop($glob_timers,"testcase");
1983
1962
    }
1984
1963
  }
1985
1964
 
1986
 
  dtr_print_line();
 
1965
  mtr_print_line();
1987
1966
 
1988
1967
  if ( ! $glob_debugger and
1989
1968
       ! $opt_extern )
2000
1979
    gprof_collect(); # collect coverage information
2001
1980
  }
2002
1981
 
2003
 
  dtr_report_stats($tests);
 
1982
  mtr_report_stats($tests);
2004
1983
 
2005
 
  dtr_timer_stop($glob_timers,"suite");
 
1984
  mtr_timer_stop($glob_timers,"suite");
2006
1985
}
2007
1986
 
2008
1987
 
2022
2001
    # vardir does not already exist it should be created
2023
2002
    if ( ! -d $opt_vardir )
2024
2003
    {
2025
 
      dtr_report("Creating '$opt_vardir'");
 
2004
      mtr_report("Creating '$opt_vardir'");
2026
2005
      setup_vardir();
2027
2006
    }
2028
2007
    else
2029
2008
    {
2030
 
      dtr_verbose("No need to create '$opt_vardir' it already exists");
 
2009
      mtr_verbose("No need to create '$opt_vardir' it already exists");
2031
2010
    }
2032
2011
  }
2033
2012
  else
2039
2018
      remove_stale_vardir();
2040
2019
      setup_vardir();
2041
2020
 
2042
 
      drizzle_install_db();
 
2021
      mysql_install_db();
2043
2022
      if ( $opt_force )
2044
2023
      {
2045
2024
        # Save a snapshot of the freshly installed db
2050
2029
  }
2051
2030
  check_running_as_root();
2052
2031
 
2053
 
  dtr_log_init("$opt_vardir/log/drizzle-test-run.log");
 
2032
  mtr_log_init("$opt_vardir/log/drizzle-test-run.log");
2054
2033
 
2055
2034
}
2056
2035
 
2057
 
sub drizzle_install_db () {
 
2036
sub mysql_install_db () {
2058
2037
 
2059
2038
  if ($max_master_num > 1)
2060
2039
  {
2075
2054
  my $type=      shift;
2076
2055
  my $data_dir=  shift;
2077
2056
 
2078
 
  dtr_report("Installing \u$type Database");
 
2057
  mtr_report("Installing \u$type Database");
2079
2058
 
2080
2059
  # Just copy the installed db from first master
2081
 
  dtr_copy_dir($master->[0]->{'path_myddir'}, $data_dir);
 
2060
  mtr_copy_dir($master->[0]->{'path_myddir'}, $data_dir);
2082
2061
 
2083
2062
}
2084
2063
 
2096
2075
    {
2097
2076
      my $data_dir= $slave->[$idx]->{'path_myddir'};
2098
2077
      my $name= basename($data_dir);
2099
 
      dtr_rmtree($data_dir);
2100
 
      dtr_copy_dir("$path_snapshot/$name", $data_dir);
 
2078
      mtr_rmtree($data_dir);
 
2079
      mtr_copy_dir("$path_snapshot/$name", $data_dir);
2101
2080
    }
2102
2081
  }
2103
2082
}
2116
2095
 
2117
2096
  if ( $tinfo->{'skip'} )
2118
2097
  {
2119
 
    dtr_report_test_name($tinfo);
2120
 
    dtr_report_test_skipped($tinfo);
 
2098
    mtr_report_test_name($tinfo);
 
2099
    mtr_report_test_skipped($tinfo);
2121
2100
    return 1;
2122
2101
  }
2123
2102
 
2131
2110
  my $args;
2132
2111
 
2133
2112
  # Remove old files produced by drizzletest
2134
 
  my $base_file= dtr_match_extension($tinfo->{'result_file'},
 
2113
  my $base_file= mtr_match_extension($tinfo->{'result_file'},
2135
2114
                                    "result"); # Trim extension
2136
2115
  unlink("$base_file.reject");
2137
2116
  unlink("$base_file.progress");
2145
2124
  my $tinfo= shift;
2146
2125
 
2147
2126
  # Save info from this testcase run to drizzletest.log
2148
 
  dtr_appendfile_to_file($path_current_test_log, $path_drizzletest_log)
 
2127
  mtr_appendfile_to_file($path_current_test_log, $path_drizzletest_log)
2149
2128
    if -f $path_current_test_log;
2150
 
  dtr_appendfile_to_file($path_timefile, $path_drizzletest_log)
 
2129
  mtr_appendfile_to_file($path_timefile, $path_drizzletest_log)
2151
2130
    if -f $path_timefile;
2152
2131
}
2153
2132
 
2159
2138
  # Write a marker to all log files
2160
2139
 
2161
2140
  # The file indicating current test name
2162
 
  dtr_tonewfile($path_current_test_log, $log_msg);
 
2141
  mtr_tonewfile($path_current_test_log, $log_msg);
2163
2142
 
2164
 
  # each drizzled's .err file
2165
 
  foreach my $drizzled (@{$master}, @{$slave})
 
2143
  # each mysqld's .err file
 
2144
  foreach my $mysqld (@{$master}, @{$slave})
2166
2145
  {
2167
 
    dtr_tofile($drizzled->{path_myerr}, $log_msg);
 
2146
    mtr_tofile($mysqld->{path_myerr}, $log_msg);
2168
2147
  }
2169
2148
 
2170
2149
}
2192
2171
 
2193
2172
  if ( ! $reason )
2194
2173
  {
2195
 
    dtr_warning("Could not find reason for skipping test in $path_timefile");
 
2174
    mtr_warning("Could not find reason for skipping test in $path_timefile");
2196
2175
    $reason= "Detected by testcase(reason unknown) ";
2197
2176
  }
2198
2177
  $tinfo->{'comment'}= $reason;
2212
2191
 
2213
2192
# We don't start and kill the servers for each testcase. But some
2214
2193
# testcases needs a restart, because they specify options to start
2215
 
# drizzled with. After that testcase, we need to restart again, to set
 
2194
# mysqld with. After that testcase, we need to restart again, to set
2216
2195
# back the normal options.
2217
2196
 
2218
2197
sub run_testcase ($) {
2223
2202
  # -------------------------------------------------------
2224
2203
 
2225
2204
  $ENV{'TZ'}= $tinfo->{'timezone'};
2226
 
  dtr_verbose("Setting timezone: $tinfo->{'timezone'}");
 
2205
  mtr_verbose("Setting timezone: $tinfo->{'timezone'}");
2227
2206
 
2228
2207
  my $master_restart= run_testcase_need_master_restart($tinfo);
2229
2208
  my $slave_restart= run_testcase_need_slave_restart($tinfo);
2233
2212
    # Can't restart a running server that may be in use
2234
2213
    if ( $opt_extern )
2235
2214
    {
2236
 
      dtr_report_test_name($tinfo);
 
2215
      mtr_report_test_name($tinfo);
2237
2216
      $tinfo->{comment}= "Can't restart a running server";
2238
 
      dtr_report_test_skipped($tinfo);
 
2217
      mtr_report_test_skipped($tinfo);
2239
2218
      return;
2240
2219
    }
2241
2220
 
2245
2224
  # Write to all log files to indicate start of testcase
2246
2225
  run_testcase_mark_logs($tinfo, "CURRENT_TEST: $tinfo->{name}\n");
2247
2226
 
2248
 
  my $died= dtr_record_dead_children();
 
2227
  my $died= mtr_record_dead_children();
2249
2228
  if ($died or $master_restart or $slave_restart)
2250
2229
  {
2251
2230
    if (run_testcase_start_servers($tinfo))
2252
2231
    {
2253
 
      dtr_report_test_name($tinfo);
 
2232
      mtr_report_test_name($tinfo);
2254
2233
      report_failure_and_restart($tinfo);
2255
2234
      return 1;
2256
2235
    }
2261
2240
  # ----------------------------------------------------------------------
2262
2241
  if ( $opt_start_and_exit or $opt_start_dirty )
2263
2242
  {
2264
 
    dtr_timer_stop_all($glob_timers);
2265
 
    dtr_report("\nServers started, exiting");
 
2243
    mtr_timer_stop_all($glob_timers);
 
2244
    mtr_report("\nServers started, exiting");
2266
2245
    exit(0);
2267
2246
  }
2268
2247
 
2270
2249
    do_before_run_drizzletest($tinfo);
2271
2250
 
2272
2251
    my $res= run_drizzletest($tinfo);
2273
 
    dtr_report_test_name($tinfo);
 
2252
    mtr_report_test_name($tinfo);
2274
2253
 
2275
2254
    do_after_run_drizzletest($tinfo);
2276
2255
 
2277
2256
    if ( $res == 0 )
2278
2257
    {
2279
 
      dtr_report_test_passed($tinfo);
 
2258
      mtr_report_test_passed($tinfo);
2280
2259
    }
2281
2260
    elsif ( $res == 62 )
2282
2261
    {
2284
2263
 
2285
2264
      # Try to get reason from drizzletest.log
2286
2265
      find_testcase_skipped_reason($tinfo);
2287
 
      dtr_report_test_skipped($tinfo);
 
2266
      mtr_report_test_skipped($tinfo);
2288
2267
    }
2289
2268
    elsif ( $res == 63 )
2290
2269
    {
2320
2299
#
2321
2300
sub save_installed_db () {
2322
2301
 
2323
 
  dtr_report("Saving snapshot of installed databases");
2324
 
  dtr_rmtree($path_snapshot);
 
2302
  mtr_report("Saving snapshot of installed databases");
 
2303
  mtr_rmtree($path_snapshot);
2325
2304
 
2326
2305
  foreach my $data_dir (@data_dir_lst)
2327
2306
  {
2328
2307
    my $name= basename($data_dir);
2329
 
    dtr_copy_dir("$data_dir", "$path_snapshot/$name");
 
2308
    mtr_copy_dir("$data_dir", "$path_snapshot/$name");
2330
2309
  }
2331
2310
}
2332
2311
 
2345
2324
  {
2346
2325
    last if $opt_max_save_core > 0 && $num_saved_cores >= $opt_max_save_core;
2347
2326
    my $core_name= basename($core_file);
2348
 
    dtr_report("Saving $core_name");
 
2327
    mtr_report("Saving $core_name");
2349
2328
    mkdir($save_name) if ! -d $save_name;
2350
2329
    rename("$core_file", "$save_name/$core_name");
2351
2330
    ++$num_saved_cores;
2362
2341
 
2363
2342
  if ( -d $path_snapshot)
2364
2343
  {
2365
 
    dtr_report("Restoring snapshot of databases");
 
2344
    mtr_report("Restoring snapshot of databases");
2366
2345
 
2367
2346
    foreach my $data_dir (@data_dir_lst)
2368
2347
    {
2369
2348
      my $name= basename($data_dir);
2370
2349
      save_files_before_restore($test_name, $data_dir);
2371
 
      dtr_rmtree("$data_dir");
2372
 
      dtr_copy_dir("$path_snapshot/$name", "$data_dir");
 
2350
      mtr_rmtree("$data_dir");
 
2351
      mtr_copy_dir("$path_snapshot/$name", "$data_dir");
2373
2352
    }
2374
2353
  }
2375
2354
  else
2376
2355
  {
2377
2356
    # No snapshot existed
2378
 
    dtr_error("No snapshot existed");
 
2357
    mtr_error("No snapshot existed");
2379
2358
  }
2380
2359
}
2381
2360
 
2382
2361
sub report_failure_and_restart ($) {
2383
2362
  my $tinfo= shift;
2384
2363
 
2385
 
  dtr_report_test_failed($tinfo);
 
2364
  mtr_report_test_failed($tinfo);
2386
2365
  print "\n";
2387
2366
  if ( $opt_force )
2388
2367
  {
2391
2370
 
2392
2371
    # Restore the snapshot of the installed test db
2393
2372
    restore_installed_db($tinfo->{'name'});
2394
 
    dtr_report("Resuming Tests\n");
 
2373
    mtr_report("Resuming Tests\n");
2395
2374
    return;
2396
2375
  }
2397
2376
 
2398
2377
  my $test_mode= join(" ", @::glob_test_mode) || "default";
2399
 
  dtr_report("Aborting: $tinfo->{'name'} failed in $test_mode mode. ");
2400
 
  dtr_report("To continue, re-run with '--force'.");
 
2378
  mtr_report("Aborting: $tinfo->{'name'} failed in $test_mode mode. ");
 
2379
  mtr_report("To continue, re-run with '--force'.");
2401
2380
  if ( ! $glob_debugger and
2402
2381
       ! $opt_extern )
2403
2382
  {
2404
2383
    stop_all_servers();
2405
2384
  }
2406
 
  dtr_exit(1);
 
2385
  mtr_exit(1);
2407
2386
 
2408
2387
}
2409
2388
 
2415
2394
  # Run master initialization shell script if one exists
2416
2395
  if ( $init_script )
2417
2396
  {
2418
 
    my $ret= dtr_run("/bin/sh", [$init_script], "", "", "", "");
 
2397
    my $ret= mtr_run("/bin/sh", [$init_script], "", "", "", "");
2419
2398
    if ( $ret != 0 )
2420
2399
    {
2421
2400
      # FIXME rewrite those scripts to return 0 if successful
2422
 
      # dtr_warning("$init_script exited with code $ret");
 
2401
      # mtr_warning("$init_script exited with code $ret");
2423
2402
    }
2424
2403
  }
2425
2404
}
2478
2457
  # Run slave initialization shell script if one exists
2479
2458
  if ( $init_script )
2480
2459
  {
2481
 
    my $ret= dtr_run("/bin/sh", [$init_script], "", "", "", "");
 
2460
    my $ret= mtr_run("/bin/sh", [$init_script], "", "", "", "");
2482
2461
    if ( $ret != 0 )
2483
2462
    {
2484
2463
      # FIXME rewrite those scripts to return 0 if successful
2485
 
      # dtr_warning("$init_script exited with code $ret");
 
2464
      # mtr_warning("$init_script exited with code $ret");
2486
2465
    }
2487
2466
  }
2488
2467
 
2493
2472
}
2494
2473
 
2495
2474
 
2496
 
sub drizzled_arguments ($$$$) {
 
2475
sub mysqld_arguments ($$$$) {
2497
2476
  my $args=              shift;
2498
 
  my $drizzled=            shift;
 
2477
  my $mysqld=            shift;
2499
2478
  my $extra_opt=         shift;
2500
2479
  my $slave_master_info= shift;
2501
2480
 
2502
 
  my $idx= $drizzled->{'idx'};
 
2481
  my $idx= $mysqld->{'idx'};
2503
2482
  my $sidx= "";                 # Index as string, 0 is empty string
2504
2483
  if ( $idx> 0 )
2505
2484
  {
2508
2487
 
2509
2488
  my $prefix= "";               # If drizzletest server arg
2510
2489
 
2511
 
  dtr_add_arg($args, "%s--no-defaults", $prefix);
 
2490
  mtr_add_arg($args, "%s--no-defaults", $prefix);
2512
2491
 
2513
2492
  if ($opt_engine)
2514
2493
  {
2515
 
    dtr_add_arg($args, "%s--default-storage-engine=%s", $prefix, $opt_engine);
 
2494
    mtr_add_arg($args, "%s--default-storage-engine=%s", $prefix, $opt_engine);
2516
2495
  }
2517
2496
 
2518
2497
  if ( $drizzle_version_id >= 50036)
2519
2498
  {
2520
 
    # By default, prevent the started drizzled to access files outside of vardir
2521
 
    dtr_add_arg($args, "%s--secure-file-priv=%s", $prefix, $opt_vardir);
 
2499
    # By default, prevent the started mysqld to access files outside of vardir
 
2500
    mtr_add_arg($args, "%s--secure-file-priv=%s", $prefix, $opt_vardir);
2522
2501
  }
2523
2502
 
2524
 
  dtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
 
2503
  mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
2525
2504
 
2526
2505
  # Increase default connect_timeout to avoid intermittent
2527
2506
  # disconnects when test servers are put under load
2528
2507
  # see BUG#28359
2529
 
  dtr_add_arg($args, "%s--mysql-protocol.connect-timeout=60", $prefix);
2530
 
 
2531
 
 
2532
 
  # When drizzled is run by a root user(euid is 0), it will fail
 
2508
  mtr_add_arg($args, "%s--mysql-protocol.connect-timeout=60", $prefix);
 
2509
 
 
2510
 
 
2511
  # When mysqld is run by a root user(euid is 0), it will fail
2533
2512
  # to start unless we specify what user to run as, see BUG#30630
2534
2513
  my $euid= $>;
2535
 
  if (grep(/^--user/, @$extra_opt, @opt_extra_drizzled_opt) == 0) {
2536
 
    dtr_add_arg($args, "%s--user=root", $prefix);
 
2514
  if (grep(/^--user/, @$extra_opt, @opt_extra_mysqld_opt) == 0) {
 
2515
    mtr_add_arg($args, "%s--user=root", $prefix);
2537
2516
  }
2538
2517
 
2539
 
  dtr_add_arg($args, "%s--pid-file=%s", $prefix,
2540
 
              $drizzled->{'path_pid'});
2541
 
 
2542
 
  dtr_add_arg($args, "%s--mysql-protocol.port=%d", $prefix,
2543
 
              $drizzled->{'port'});
2544
 
 
2545
 
  dtr_add_arg($args, "%s--drizzle-protocol.port=%d", $prefix,
2546
 
              $drizzled->{'secondary_port'});
2547
 
 
2548
 
  dtr_add_arg($args, "%s--datadir=%s", $prefix,
2549
 
              $drizzled->{'path_myddir'});
2550
 
 
2551
 
  dtr_add_arg($args, "%s--mysql-unix-socket-protocol.path=%s", $prefix,
2552
 
              $drizzled->{'path_sock'});
 
2518
  mtr_add_arg($args, "%s--pid-file=%s", $prefix,
 
2519
              $mysqld->{'path_pid'});
 
2520
 
 
2521
  mtr_add_arg($args, "%s--mysql-protocol.port=%d", $prefix,
 
2522
              $mysqld->{'port'});
 
2523
 
 
2524
  mtr_add_arg($args, "%s--drizzle-protocol.port=%d", $prefix,
 
2525
              $mysqld->{'secondary_port'});
 
2526
 
 
2527
  mtr_add_arg($args, "%s--datadir=%s", $prefix,
 
2528
              $mysqld->{'path_myddir'});
2553
2529
 
2554
2530
  # Check if "extra_opt" contains --skip-log-bin
2555
 
  if ( $drizzled->{'type'} eq 'master' )
 
2531
  if ( $mysqld->{'type'} eq 'master' )
2556
2532
  {
2557
 
    dtr_add_arg($args, "%s--server-id=%d", $prefix,
 
2533
    mtr_add_arg($args, "%s--server-id=%d", $prefix,
2558
2534
               $idx > 0 ? $idx + 101 : 1);
2559
2535
 
2560
 
    dtr_add_arg($args,
 
2536
    mtr_add_arg($args,
2561
2537
      "%s--innodb.data-file-path=ibdata1:20M:autoextend", $prefix);
2562
2538
 
2563
2539
  }
2564
2540
  else
2565
2541
  {
2566
 
    dtr_error("unknown drizzled type")
2567
 
      unless $drizzled->{'type'} eq 'slave';
 
2542
    mtr_error("unknown mysqld type")
 
2543
      unless $mysqld->{'type'} eq 'slave';
2568
2544
 
2569
2545
    # Directory where slaves find the dumps generated by "load data"
2570
2546
    # on the server. The path need to have constant length otherwise
2575
2551
    {
2576
2552
      foreach my $arg ( @$slave_master_info )
2577
2553
      {
2578
 
        dtr_add_arg($args, "%s%s", $prefix, $arg);
 
2554
        mtr_add_arg($args, "%s%s", $prefix, $arg);
2579
2555
      }
2580
2556
    }
2581
2557
    else
2582
2558
    {
2583
2559
      my $slave_server_id=  2 + $idx;
2584
2560
      my $slave_rpl_rank= $slave_server_id;
2585
 
      dtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
 
2561
      mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
2586
2562
    }
2587
2563
  } # end slave
2588
2564
 
2589
2565
  if ( $opt_debug )
2590
2566
  {
2591
 
    dtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/%s%s.trace",
2592
 
                $prefix, $path_vardir_trace, $drizzled->{'type'}, $sidx);
 
2567
    mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/%s%s.trace",
 
2568
                $prefix, $path_vardir_trace, $mysqld->{'type'}, $sidx);
2593
2569
  }
2594
2570
 
2595
 
  dtr_add_arg($args, "%s--sort-buffer-size=256K", $prefix);
2596
 
  dtr_add_arg($args, "%s--max-heap-table-size=1M", $prefix);
 
2571
  mtr_add_arg($args, "%s--sort-buffer-size=256K", $prefix);
 
2572
  mtr_add_arg($args, "%s--max-heap-table-size=1M", $prefix);
2597
2573
 
2598
2574
  if ( $opt_warnings )
2599
2575
  {
2600
 
    dtr_add_arg($args, "%s--log-warnings", $prefix);
 
2576
    mtr_add_arg($args, "%s--log-warnings", $prefix);
2601
2577
  }
2602
2578
 
2603
 
  # Indicate to "drizzled" it will be debugged in debugger
 
2579
  # Indicate to "mysqld" it will be debugged in debugger
2604
2580
  if ( $glob_debugger )
2605
2581
  {
2606
 
    dtr_add_arg($args, "%s--gdb", $prefix);
 
2582
    mtr_add_arg($args, "%s--gdb", $prefix);
2607
2583
  }
2608
2584
 
2609
2585
  my $found_skip_core= 0;
2610
 
  foreach my $arg ( @opt_extra_drizzled_opt, @$extra_opt )
 
2586
  foreach my $arg ( @opt_extra_mysqld_opt, @$extra_opt )
2611
2587
  {
2612
2588
    # Allow --skip-core-file to be set in <testname>-[master|slave].opt file
2613
2589
    if ($arg eq "--skip-core-file")
2616
2592
    }
2617
2593
    else
2618
2594
    {
2619
 
      dtr_add_arg($args, "%s%s", $prefix, $arg);
 
2595
      mtr_add_arg($args, "%s%s", $prefix, $arg);
2620
2596
    }
2621
2597
  }
2622
2598
  if ( !$found_skip_core )
2623
2599
  {
2624
 
    dtr_add_arg($args, "%s%s", $prefix, "--core-file");
 
2600
    mtr_add_arg($args, "%s%s", $prefix, "--core-file");
2625
2601
  }
2626
2602
 
2627
2603
  return $args;
2630
2606
 
2631
2607
##############################################################################
2632
2608
#
2633
 
#  Start drizzled and return the PID
 
2609
#  Start mysqld and return the PID
2634
2610
#
2635
2611
##############################################################################
2636
2612
 
2637
 
sub drizzled_start ($$$) {
2638
 
  my $drizzled=            shift;
 
2613
sub mysqld_start ($$$) {
 
2614
  my $mysqld=            shift;
2639
2615
  my $extra_opt=         shift;
2640
2616
  my $slave_master_info= shift;
2641
2617
 
2644
2620
  my $pid= -1;
2645
2621
  my $wait_for_pid_file= 1;
2646
2622
 
2647
 
  my $type= $drizzled->{'type'};
2648
 
  my $idx= $drizzled->{'idx'};
 
2623
  my $type= $mysqld->{'type'};
 
2624
  my $idx= $mysqld->{'idx'};
2649
2625
 
2650
2626
  if ( $type eq 'master' )
2651
2627
  {
2652
 
    $exe= $exe_master_drizzled;
 
2628
    $exe= $exe_master_mysqld;
2653
2629
  }
2654
2630
  elsif ( $type eq 'slave' )
2655
2631
  {
2656
 
    $exe= $exe_slave_drizzled;
 
2632
    $exe= $exe_slave_mysqld;
2657
2633
  }
2658
2634
  else
2659
2635
  {
2660
 
    dtr_error("Unknown 'type' \"$type\" passed to drizzled_start");
 
2636
    mtr_error("Unknown 'type' \"$type\" passed to mysqld_start");
2661
2637
  }
2662
2638
 
2663
 
  dtr_init_args(\$args);
 
2639
  mtr_init_args(\$args);
2664
2640
 
2665
 
  if ( $opt_valgrind_drizzled )
 
2641
  if ( $opt_valgrind_mysqld )
2666
2642
  {
2667
2643
    valgrind_arguments($args, \$exe);
2668
2644
  }
2669
2645
 
2670
 
  drizzled_arguments($args,$drizzled,$extra_opt,$slave_master_info);
 
2646
  mysqld_arguments($args,$mysqld,$extra_opt,$slave_master_info);
2671
2647
 
2672
2648
  if ( $opt_gdb || $opt_manual_gdb)
2673
2649
  {
2688
2664
  elsif ( $opt_manual_debug )
2689
2665
  {
2690
2666
     print "\nStart $type in your debugger\n" .
2691
 
           "dir: $glob_drizzle_test_dir\n" .
 
2667
           "dir: $glob_mysql_test_dir\n" .
2692
2668
           "exe: $exe\n" .
2693
2669
           "args:  " . join(" ", @$args)  . "\n\n" .
2694
2670
           "Waiting ....\n";
2703
2679
  }
2704
2680
 
2705
2681
  # Remove the pidfile
2706
 
  unlink($drizzled->{'path_pid'});
 
2682
  unlink($mysqld->{'path_pid'});
2707
2683
 
2708
2684
  if ( defined $exe )
2709
2685
  {
2710
 
    dtr_verbose("running Drizzle with: $exe @$args");
2711
 
    $pid= dtr_spawn($exe, $args, "",
2712
 
                    $drizzled->{'path_myerr'},
2713
 
                    $drizzled->{'path_myerr'},
 
2686
    mtr_verbose("running Drizzle with: $exe @$args");
 
2687
    $pid= mtr_spawn($exe, $args, "",
 
2688
                    $mysqld->{'path_myerr'},
 
2689
                    $mysqld->{'path_myerr'},
2714
2690
                    "",
2715
2691
                    { append_log_file => 1 });
2716
2692
  }
2717
2693
 
2718
2694
 
2719
 
  if ( $wait_for_pid_file && !sleep_until_file_created($drizzled->{'path_pid'},
2720
 
                                                       $drizzled->{'start_timeout'},
 
2695
  if ( $wait_for_pid_file && !sleep_until_file_created($mysqld->{'path_pid'},
 
2696
                                                       $mysqld->{'start_timeout'},
2721
2697
                                                       $pid))
2722
2698
  {
2723
2699
 
2724
 
    dtr_error("Failed to start drizzled $drizzled->{'type'}");
 
2700
    mtr_error("Failed to start mysqld $mysqld->{'type'}");
2725
2701
  }
2726
2702
 
2727
2703
 
2728
2704
  # Remember pid of the started process
2729
 
  $drizzled->{'pid'}= $pid;
 
2705
  $mysqld->{'pid'}= $pid;
2730
2706
 
2731
2707
  # Remember options used when starting
2732
 
  $drizzled->{'start_opts'}= $extra_opt;
2733
 
  $drizzled->{'start_slave_master_info'}= $slave_master_info;
 
2708
  $mysqld->{'start_opts'}= $extra_opt;
 
2709
  $mysqld->{'start_slave_master_info'}= $slave_master_info;
2734
2710
 
2735
 
  dtr_verbose("drizzled pid: $pid");
 
2711
  mtr_verbose("mysqld pid: $pid");
2736
2712
  return $pid;
2737
2713
}
2738
2714
 
2739
2715
 
2740
2716
sub stop_all_servers () {
2741
2717
 
2742
 
  dtr_report("Stopping All Servers");
 
2718
  mtr_report("Stopping All Servers");
2743
2719
 
2744
2720
  my %admin_pids; # hash of admin processes that requests shutdown
2745
2721
  my @kill_pids;  # list of processes to shutdown/kill
2746
2722
  my $pid;
2747
2723
 
2748
2724
  # Start shutdown of all started masters
2749
 
  foreach my $drizzled (@{$slave}, @{$master})
 
2725
  foreach my $mysqld (@{$slave}, @{$master})
2750
2726
  {
2751
 
    if ( $drizzled->{'pid'} )
 
2727
    if ( $mysqld->{'pid'} )
2752
2728
    {
2753
 
      $pid= dtr_server_shutdown($drizzled);
 
2729
      $pid= mtr_server_shutdown($mysqld);
2754
2730
      $admin_pids{$pid}= 1;
2755
2731
 
2756
2732
      push(@kill_pids,{
2757
 
                       pid      => $drizzled->{'pid'},
2758
 
                       real_pid => $drizzled->{'real_pid'},
2759
 
                       pidfile  => $drizzled->{'path_pid'},
2760
 
                       sockfile => $drizzled->{'path_sock'},
2761
 
                       port     => $drizzled->{'port'},
2762
 
                       errfile  => $drizzled->{'path_myerr'},
 
2733
                       pid      => $mysqld->{'pid'},
 
2734
                       real_pid => $mysqld->{'real_pid'},
 
2735
                       pidfile  => $mysqld->{'path_pid'},
 
2736
                       sockfile => $mysqld->{'path_sock'},
 
2737
                       port     => $mysqld->{'port'},
 
2738
                       errfile  => $mysqld->{'path_myerr'},
2763
2739
                      });
2764
2740
 
2765
 
      $drizzled->{'pid'}= 0; # Assume we are done with it
 
2741
      $mysqld->{'pid'}= 0; # Assume we are done with it
2766
2742
    }
2767
2743
  }
2768
2744
 
2769
2745
  # Wait blocking until all shutdown processes has completed
2770
 
  dtr_wait_blocking(\%admin_pids);
 
2746
  mtr_wait_blocking(\%admin_pids);
2771
2747
 
2772
2748
  # Make sure that process has shutdown else try to kill them
2773
 
  dtr_check_stop_servers(\@kill_pids);
 
2749
  mtr_check_stop_servers(\@kill_pids);
2774
2750
}
2775
2751
 
2776
2752
 
2784
2760
  if ( $tinfo->{'master_sh'} )
2785
2761
  {
2786
2762
    $do_restart= 1;           # Always restart if script to run
2787
 
    dtr_verbose("Restart master: Always restart if script to run");
 
2763
    mtr_verbose("Restart master: Always restart if script to run");
2788
2764
  }
2789
2765
  if ( $tinfo->{'force_restart'} )
2790
2766
  {
2791
2767
    $do_restart= 1; # Always restart if --force-restart in -opt file
2792
 
    dtr_verbose("Restart master: Restart forced with --force-restart");
 
2768
    mtr_verbose("Restart master: Restart forced with --force-restart");
2793
2769
  }
2794
2770
  elsif( $tinfo->{'component_id'} eq 'im' )
2795
2771
  {
2796
2772
    $do_restart= 1;
2797
 
    dtr_verbose("Restart master: Always restart for im tests");
 
2773
    mtr_verbose("Restart master: Always restart for im tests");
2798
2774
  }
2799
2775
  elsif ( $master->[0]->{'running_master_options'} and
2800
2776
          $master->[0]->{'running_master_options'}->{'timezone'} ne
2801
2777
          $tinfo->{'timezone'})
2802
2778
  {
2803
2779
    $do_restart= 1;
2804
 
    dtr_verbose("Restart master: Different timezone");
 
2780
    mtr_verbose("Restart master: Different timezone");
2805
2781
  }
2806
2782
  # Check that running master was started with same options
2807
2783
  # as the current test requires
2808
 
  elsif (! dtr_same_opts($master->[0]->{'start_opts'},
 
2784
  elsif (! mtr_same_opts($master->[0]->{'start_opts'},
2809
2785
                         $tinfo->{'master_opt'}) )
2810
2786
  {
2811
2787
    # Chech that diff is binlog format only
2812
 
    my $diff_opts= dtr_diff_opts($master->[0]->{'start_opts'},$tinfo->{'master_opt'});
 
2788
    my $diff_opts= mtr_diff_opts($master->[0]->{'start_opts'},$tinfo->{'master_opt'});
2813
2789
    if (scalar(@$diff_opts) eq 2) 
2814
2790
    {
2815
2791
      $do_restart= 1;
2817
2793
    else
2818
2794
    {
2819
2795
      $do_restart= 1;
2820
 
      dtr_verbose("Restart master: running with different options '" .
 
2796
      mtr_verbose("Restart master: running with different options '" .
2821
2797
                 join(" ", @{$tinfo->{'master_opt'}}) . "' != '" .
2822
2798
                join(" ", @{$master->[0]->{'start_opts'}}) . "'" );
2823
2799
    }
2827
2803
    if ( $opt_extern )
2828
2804
    {
2829
2805
      $do_restart= 0;
2830
 
      dtr_verbose("No restart: using extern master");
 
2806
      mtr_verbose("No restart: using extern master");
2831
2807
    }
2832
2808
    else
2833
2809
    {
2834
2810
      $do_restart= 1;
2835
 
      dtr_verbose("Restart master: master is not started");
 
2811
      mtr_verbose("Restart master: master is not started");
2836
2812
    }
2837
2813
  }
2838
2814
  return $do_restart;
2847
2823
 
2848
2824
  if ( $max_slave_num == 0)
2849
2825
  {
2850
 
    dtr_verbose("Skip slave restart: No testcase use slaves");
 
2826
    mtr_verbose("Skip slave restart: No testcase use slaves");
2851
2827
  }
2852
2828
  else
2853
2829
  {
2854
2830
 
2855
2831
    # Check if any slave is currently started
2856
2832
    my $any_slave_started= 0;
2857
 
    foreach my $drizzled (@{$slave})
 
2833
    foreach my $mysqld (@{$slave})
2858
2834
    {
2859
 
      if ( $drizzled->{'pid'} )
 
2835
      if ( $mysqld->{'pid'} )
2860
2836
      {
2861
2837
        $any_slave_started= 1;
2862
2838
        last;
2865
2841
 
2866
2842
    if ($any_slave_started)
2867
2843
    {
2868
 
      dtr_verbose("Restart slave: Slave is started, always restart");
 
2844
      mtr_verbose("Restart slave: Slave is started, always restart");
2869
2845
      $do_slave_restart= 1;
2870
2846
    }
2871
2847
    elsif ( $tinfo->{'slave_num'} )
2872
2848
    {
2873
 
      dtr_verbose("Restart slave: Test need slave");
 
2849
      mtr_verbose("Restart slave: Test need slave");
2874
2850
      $do_slave_restart= 1;
2875
2851
    }
2876
2852
  }
2904
2880
    delete $master->[0]->{'running_master_options'}; # Forget history
2905
2881
 
2906
2882
    # Start shutdown of all started masters
2907
 
    foreach my $drizzled (@{$master})
 
2883
    foreach my $mysqld (@{$master})
2908
2884
    {
2909
 
      if ( $drizzled->{'pid'} )
 
2885
      if ( $mysqld->{'pid'} )
2910
2886
      {
2911
 
        $pid= dtr_server_shutdown($drizzled);
 
2887
        $pid= mtr_server_shutdown($mysqld);
2912
2888
 
2913
2889
        $admin_pids{$pid}= 1;
2914
2890
 
2915
2891
        push(@kill_pids,{
2916
 
              pid      => $drizzled->{'pid'},
2917
 
              real_pid => $drizzled->{'real_pid'},
2918
 
              pidfile  => $drizzled->{'path_pid'},
2919
 
              sockfile => $drizzled->{'path_sock'},
2920
 
              port     => $drizzled->{'port'},
2921
 
              errfile   => $drizzled->{'path_myerr'},
 
2892
              pid      => $mysqld->{'pid'},
 
2893
              real_pid => $mysqld->{'real_pid'},
 
2894
              pidfile  => $mysqld->{'path_pid'},
 
2895
              sockfile => $mysqld->{'path_sock'},
 
2896
              port     => $mysqld->{'port'},
 
2897
              errfile   => $mysqld->{'path_myerr'},
2922
2898
        });
2923
2899
 
2924
 
        $drizzled->{'pid'}= 0; # Assume we are done with it
 
2900
        $mysqld->{'pid'}= 0; # Assume we are done with it
2925
2901
      }
2926
2902
    }
2927
2903
  }
2932
2908
    delete $slave->[0]->{'running_slave_options'}; # Forget history
2933
2909
 
2934
2910
    # Start shutdown of all started slaves
2935
 
    foreach my $drizzled (@{$slave})
 
2911
    foreach my $mysqld (@{$slave})
2936
2912
    {
2937
 
      if ( $drizzled->{'pid'} )
 
2913
      if ( $mysqld->{'pid'} )
2938
2914
      {
2939
 
        $pid= dtr_server_shutdown($drizzled);
 
2915
        $pid= mtr_server_shutdown($mysqld);
2940
2916
 
2941
2917
        $admin_pids{$pid}= 1;
2942
2918
 
2943
2919
        push(@kill_pids,{
2944
 
              pid      => $drizzled->{'pid'},
2945
 
              real_pid => $drizzled->{'real_pid'},
2946
 
              pidfile  => $drizzled->{'path_pid'},
2947
 
              sockfile => $drizzled->{'path_sock'},
2948
 
              port     => $drizzled->{'port'},
2949
 
              errfile  => $drizzled->{'path_myerr'},
 
2920
              pid      => $mysqld->{'pid'},
 
2921
              real_pid => $mysqld->{'real_pid'},
 
2922
              pidfile  => $mysqld->{'path_pid'},
 
2923
              sockfile => $mysqld->{'path_sock'},
 
2924
              port     => $mysqld->{'port'},
 
2925
              errfile  => $mysqld->{'path_myerr'},
2950
2926
        });
2951
2927
 
2952
 
        $drizzled->{'pid'}= 0; # Assume we are done with it
 
2928
        $mysqld->{'pid'}= 0; # Assume we are done with it
2953
2929
      }
2954
2930
    }
2955
2931
  }
2960
2936
  # ----------------------------------------------------------------------
2961
2937
 
2962
2938
  # Wait blocking until all shutdown processes has completed
2963
 
  dtr_wait_blocking(\%admin_pids);
 
2939
  mtr_wait_blocking(\%admin_pids);
2964
2940
 
2965
2941
 
2966
2942
  # Make sure that process has shutdown else try to kill them
2967
 
  dtr_check_stop_servers(\@kill_pids);
 
2943
  mtr_check_stop_servers(\@kill_pids);
2968
2944
}
2969
2945
 
2970
2946
 
2982
2958
  my $tinfo= shift;
2983
2959
  my $tname= $tinfo->{'name'};
2984
2960
 
2985
 
  if ( $tinfo->{'component_id'} eq 'drizzled' )
 
2961
  if ( $tinfo->{'component_id'} eq 'mysqld' )
2986
2962
  {
2987
2963
    if ( !$master->[0]->{'pid'} )
2988
2964
    {
2989
 
      # Master drizzled is not started
 
2965
      # Master mysqld is not started
2990
2966
      do_before_start_master($tinfo);
2991
2967
 
2992
 
      drizzled_start($master->[0],$tinfo->{'master_opt'},[]);
 
2968
      mysqld_start($master->[0],$tinfo->{'master_opt'},[]);
2993
2969
 
2994
2970
    }
2995
2971
 
3010
2986
    {
3011
2987
      if ( ! $slave->[$idx]->{'pid'} )
3012
2988
      {
3013
 
        drizzled_start($slave->[$idx],$tinfo->{'slave_opt'},
 
2989
        mysqld_start($slave->[$idx],$tinfo->{'slave_opt'},
3014
2990
                     $tinfo->{'slave_mi'});
3015
2991
 
3016
2992
      }
3020
2996
    $slave->[0]->{'running_slave_options'}= $tinfo;
3021
2997
  }
3022
2998
 
3023
 
  # Wait for drizzled's to start
3024
 
  foreach my $drizzled (@{$master},@{$slave})
 
2999
  # Wait for mysqld's to start
 
3000
  foreach my $mysqld (@{$master},@{$slave})
3025
3001
  {
3026
3002
 
3027
 
    next if !$drizzled->{'pid'};
 
3003
    next if !$mysqld->{'pid'};
3028
3004
 
3029
 
    if (drizzled_wait_started($drizzled))
 
3005
    if (mysqld_wait_started($mysqld))
3030
3006
    {
3031
3007
      # failed to start
3032
3008
      $tinfo->{'comment'}=
3033
 
        "Failed to start $drizzled->{'type'} drizzled $drizzled->{'idx'}";
 
3009
        "Failed to start $mysqld->{'type'} mysqld $mysqld->{'idx'}";
3034
3010
      return 1;
3035
3011
    }
3036
3012
  }
3049
3025
sub run_check_testcase ($$) {
3050
3026
 
3051
3027
  my $mode=     shift;
3052
 
  my $drizzled=   shift;
 
3028
  my $mysqld=   shift;
3053
3029
 
3054
 
  my $name= "check-" . $drizzled->{'type'} . $drizzled->{'idx'};
 
3030
  my $name= "check-" . $mysqld->{'type'} . $mysqld->{'idx'};
3055
3031
 
3056
3032
  my $args;
3057
 
  dtr_init_args(\$args);
3058
 
 
3059
 
  dtr_add_arg($args, "--no-defaults");
3060
 
  dtr_add_arg($args, "--silent");
3061
 
  dtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
3062
 
 
3063
 
  dtr_add_arg($args, "--port=%d", $drizzled->{'port'});
3064
 
  dtr_add_arg($args, "--database=test");
3065
 
  dtr_add_arg($args, "--user=%s", $opt_user);
3066
 
  dtr_add_arg($args, "--password=");
3067
 
 
3068
 
  dtr_add_arg($args, "-R");
3069
 
  dtr_add_arg($args, "$opt_vardir/tmp/$name.result");
 
3033
  mtr_init_args(\$args);
 
3034
 
 
3035
  mtr_add_arg($args, "--no-defaults");
 
3036
  mtr_add_arg($args, "--silent");
 
3037
  mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
 
3038
 
 
3039
  mtr_add_arg($args, "--port=%d", $mysqld->{'port'});
 
3040
  mtr_add_arg($args, "--database=test");
 
3041
  mtr_add_arg($args, "--user=%s", $opt_user);
 
3042
  mtr_add_arg($args, "--password=");
 
3043
 
 
3044
  mtr_add_arg($args, "-R");
 
3045
  mtr_add_arg($args, "$opt_vardir/tmp/$name.result");
3070
3046
 
3071
3047
  if ( $mode eq "before" )
3072
3048
  {
3073
 
    dtr_add_arg($args, "--record");
 
3049
    mtr_add_arg($args, "--record");
3074
3050
  }
3075
3051
 
3076
3052
  if ( $opt_testdir )
3077
3053
  {
3078
 
    dtr_add_arg($args, "--testdir=%s", $opt_testdir);
 
3054
    mtr_add_arg($args, "--testdir=%s", $opt_testdir);
3079
3055
  }
3080
3056
 
3081
 
  my $res = dtr_run_test($exe_drizzletest,$args,
 
3057
  my $res = mtr_run_test($exe_drizzletest,$args,
3082
3058
                "include/check-testcase.test", "", "", "");
3083
3059
 
3084
3060
  if ( $res == 1  and $mode eq "after")
3085
3061
  {
3086
 
    dtr_run("diff",["-u",
 
3062
    mtr_run("diff",["-u",
3087
3063
                    "$opt_vardir/tmp/$name.result",
3088
3064
                    "$opt_vardir/tmp/$name.reject"],
3089
3065
            "", "", "", "");
3090
3066
  }
3091
3067
  elsif ( $res )
3092
3068
  {
3093
 
    dtr_error("Could not execute 'check-testcase' $mode testcase");
 
3069
    mtr_error("Could not execute 'check-testcase' $mode testcase");
3094
3070
  }
3095
3071
  return $res;
3096
3072
}
3105
3081
  my $args;
3106
3082
 
3107
3083
  {
3108
 
    drizzled_start($master->[0],[],[]);
 
3084
    mysqld_start($master->[0],[],[]);
3109
3085
    if ( ! $master->[0]->{'pid'} )
3110
3086
    {
3111
 
      dtr_error("Can't start the drizzled server");
 
3087
      mtr_error("Can't start the mysqld server");
3112
3088
    }
3113
 
    drizzled_wait_started($master->[0]);
 
3089
    mysqld_wait_started($master->[0]);
3114
3090
  }
3115
3091
 
3116
3092
  my $tinfo = {};
3117
3093
  $tinfo->{'name'} = 'report features';
3118
3094
  $tinfo->{'result_file'} = undef;
3119
 
  $tinfo->{'component_id'} = 'drizzled';
 
3095
  $tinfo->{'component_id'} = 'mysqld';
3120
3096
  $tinfo->{'path'} = 'include/report-features.test';
3121
3097
  $tinfo->{'timezone'}=  "GMT-3";
3122
3098
  $tinfo->{'slave_num'} = 0;
3137
3113
  my $exe= $exe_drizzletest;
3138
3114
  my $args;
3139
3115
 
3140
 
  dtr_init_args(\$args);
 
3116
  mtr_init_args(\$args);
3141
3117
 
3142
 
  dtr_add_arg($args, "--no-defaults");
3143
 
  dtr_add_arg($args, "--silent");
3144
 
  dtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
3145
 
  dtr_add_arg($args, "--logdir=%s/log", $opt_vardir);
 
3118
  mtr_add_arg($args, "--no-defaults");
 
3119
  mtr_add_arg($args, "--silent");
 
3120
  mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
 
3121
  mtr_add_arg($args, "--logdir=%s/log", $opt_vardir);
3146
3122
 
3147
3123
  # Log line number and time  for each line in .test file
3148
 
  dtr_add_arg($args, "--mark-progress")
 
3124
  mtr_add_arg($args, "--mark-progress")
3149
3125
    if $opt_mark_progress;
3150
3126
 
3151
3127
  {
3152
 
    dtr_add_arg($args, "--port=%d", $master->[0]->{'port'});
3153
 
    dtr_add_arg($args, "--database=test");
3154
 
    dtr_add_arg($args, "--user=%s", $opt_user);
3155
 
    dtr_add_arg($args, "--password=");
 
3128
    mtr_add_arg($args, "--port=%d", $master->[0]->{'port'});
 
3129
    mtr_add_arg($args, "--database=test");
 
3130
    mtr_add_arg($args, "--user=%s", $opt_user);
 
3131
    mtr_add_arg($args, "--password=");
3156
3132
  }
3157
3133
 
3158
3134
  if ( $opt_strace_client )
3159
3135
  {
3160
3136
    $exe=  "strace";            # FIXME there are ktrace, ....
3161
 
    dtr_add_arg($args, "-o");
3162
 
    dtr_add_arg($args, "%s/log/drizzletest.strace", $opt_vardir);
3163
 
    dtr_add_arg($args, "$exe_drizzletest");
 
3137
    mtr_add_arg($args, "-o");
 
3138
    mtr_add_arg($args, "%s/log/drizzletest.strace", $opt_vardir);
 
3139
    mtr_add_arg($args, "$exe_drizzletest");
3164
3140
  }
3165
3141
 
3166
3142
  if ( $opt_timer )
3167
3143
  {
3168
 
    dtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir);
 
3144
    mtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir);
3169
3145
  }
3170
3146
 
3171
3147
  if ( $opt_compress )
3172
3148
  {
3173
 
    dtr_add_arg($args, "--compress");
 
3149
    mtr_add_arg($args, "--compress");
3174
3150
  }
3175
3151
 
3176
3152
  if ( $opt_sleep )
3177
3153
  {
3178
 
    dtr_add_arg($args, "--sleep=%d", $opt_sleep);
 
3154
    mtr_add_arg($args, "--sleep=%d", $opt_sleep);
3179
3155
  }
3180
3156
 
3181
3157
  if ( $opt_debug )
3182
3158
  {
3183
 
    dtr_add_arg($args, "--debug=d:t:A,%s/log/drizzletest.trace",
 
3159
    mtr_add_arg($args, "--debug=d:t:A,%s/log/drizzletest.trace",
3184
3160
                $path_vardir_trace);
3185
3161
  }
3186
3162
 
3187
3163
  if ( $opt_testdir )
3188
3164
  {
3189
 
    dtr_add_arg($args, "--testdir=%s", $opt_testdir);
 
3165
    mtr_add_arg($args, "--testdir=%s", $opt_testdir);
3190
3166
  }
3191
3167
 
3192
3168
 
3194
3170
  # export DRIZZLE_TEST variable containing <path>/drizzletest <args>
3195
3171
  # ----------------------------------------------------------------------
3196
3172
  $ENV{'DRIZZLE_TEST'}=
3197
 
    dtr_native_path($exe_drizzletest) . " " . join(" ", @$args);
 
3173
    mtr_native_path($exe_drizzletest) . " " . join(" ", @$args);
3198
3174
 
3199
3175
  # ----------------------------------------------------------------------
3200
3176
  # Add arguments that should not go into the DRIZZLE_TEST env var
3206
3182
    # We do this here, since we do not want to Valgrind the nested invocations
3207
3183
    # of drizzletest; that would mess up the stderr output causing test failure.
3208
3184
    my @args_saved = @$args;
3209
 
    dtr_init_args(\$args);
 
3185
    mtr_init_args(\$args);
3210
3186
    valgrind_arguments($args, \$exe);
3211
 
    dtr_add_arg($args, "%s", $_) for @args_saved;
 
3187
    mtr_add_arg($args, "%s", $_) for @args_saved;
3212
3188
  }
3213
3189
 
3214
 
  dtr_add_arg($args, "--test-file=%s", $tinfo->{'path'});
 
3190
  mtr_add_arg($args, "--test-file=%s", $tinfo->{'path'});
3215
3191
 
3216
3192
  # Number of lines of resut to include in failure report
3217
 
  dtr_add_arg($args, "--tail-lines=20");
 
3193
  mtr_add_arg($args, "--tail-lines=20");
3218
3194
 
3219
3195
  if ( defined $tinfo->{'result_file'} ) {
3220
 
    dtr_add_arg($args, "--result-file=%s", $tinfo->{'result_file'});
 
3196
    mtr_add_arg($args, "--result-file=%s", $tinfo->{'result_file'});
3221
3197
  }
3222
3198
 
3223
3199
  if ( $opt_record )
3224
3200
  {
3225
 
    dtr_add_arg($args, "--record");
 
3201
    mtr_add_arg($args, "--record");
3226
3202
  }
3227
3203
 
3228
3204
  if ( $opt_client_gdb )
3240
3216
 
3241
3217
  if ( $opt_check_testcases )
3242
3218
  {
3243
 
    foreach my $drizzled (@{$master}, @{$slave})
 
3219
    foreach my $mysqld (@{$master}, @{$slave})
3244
3220
    {
3245
 
      if ($drizzled->{'pid'})
 
3221
      if ($mysqld->{'pid'})
3246
3222
      {
3247
 
        run_check_testcase("before", $drizzled);
 
3223
        run_check_testcase("before", $mysqld);
3248
3224
      }
3249
3225
    }
3250
3226
  }
3251
3227
 
3252
 
  my $res = dtr_run_test($exe,$args,"","",$path_timefile,"");
 
3228
  my $res = mtr_run_test($exe,$args,"","",$path_timefile,"");
3253
3229
 
3254
3230
  if ( $opt_check_testcases )
3255
3231
  {
3256
 
    foreach my $drizzled (@{$master}, @{$slave})
 
3232
    foreach my $mysqld (@{$master}, @{$slave})
3257
3233
    {
3258
 
      if ($drizzled->{'pid'})
 
3234
      if ($mysqld->{'pid'})
3259
3235
      {
3260
 
        if (run_check_testcase("after", $drizzled))
 
3236
        if (run_check_testcase("after", $mysqld))
3261
3237
        {
3262
3238
          # Check failed, mark the test case with that info
3263
3239
          $tinfo->{'check_testcase_failed'}= 1;
3287
3263
  if ( $type eq "client" )
3288
3264
  {
3289
3265
    # write init file for client
3290
 
    dtr_tofile($dbx_init_file,
 
3266
    mtr_tofile($dbx_init_file,
3291
3267
               "runargs $str\n" .
3292
3268
               "run\n");
3293
3269
  }
3294
3270
  else
3295
3271
  {
3296
3272
    # write init file for drizzled
3297
 
    dtr_tofile($dbx_init_file,
 
3273
    mtr_tofile($dbx_init_file,
3298
3274
               "stop in __1cIdrizzledLmysql_parse6Fpn0AHSession_pkcI_v_\n" .
3299
3275
               "runargs $str\n" .
3300
3276
               "run\n" .
3312
3288
  }
3313
3289
 
3314
3290
  $$args= [];
3315
 
  dtr_add_arg($$args, "-title");
3316
 
  dtr_add_arg($$args, "$type");
3317
 
  dtr_add_arg($$args, "-e");
 
3291
  mtr_add_arg($$args, "-title");
 
3292
  mtr_add_arg($$args, "$type");
 
3293
  mtr_add_arg($$args, "-e");
3318
3294
 
3319
 
  dtr_add_arg($$args, "dbx");
3320
 
  dtr_add_arg($$args, "-c");
3321
 
  dtr_add_arg($$args, "source $dbx_init_file");
3322
 
  dtr_add_arg($$args, "$$exe");
 
3295
  mtr_add_arg($$args, "dbx");
 
3296
  mtr_add_arg($$args, "-c");
 
3297
  mtr_add_arg($$args, "source $dbx_init_file");
 
3298
  mtr_add_arg($$args, "$$exe");
3323
3299
 
3324
3300
  $$exe= "xterm";
3325
3301
}
3354
3330
  if ( $type eq "client" )
3355
3331
  {
3356
3332
    # write init file for client
3357
 
    dtr_tofile($gdb_init_file,
 
3333
    mtr_tofile($gdb_init_file,
3358
3334
               "set args $str\n" .
3359
3335
               "$extra_gdb_init" .
3360
3336
               "break main\n");
3361
3337
  }
3362
3338
  else
3363
3339
  {
3364
 
    # write init file for drizzled
3365
 
    dtr_tofile($gdb_init_file,
 
3340
    # write init file for mysqld
 
3341
    mtr_tofile($gdb_init_file,
3366
3342
               "set args $str\n" .
3367
3343
               "$extra_gdb_init" .
3368
3344
               "set breakpoint pending on\n" .
3377
3353
  if ( $opt_manual_gdb )
3378
3354
  {
3379
3355
     print "\nTo start gdb for $type, type in another window:\n";
3380
 
     print "$glob_drizzle_test_dir/../libtool --mode=execute gdb -cd $glob_drizzle_test_dir -x $gdb_init_file $$exe\n";
 
3356
     print "$glob_mysql_test_dir/../libtool --mode=execute gdb -cd $glob_mysql_test_dir -x $gdb_init_file $$exe\n";
3381
3357
 
3382
3358
     # Indicate the exe should not be started
3383
3359
     $$exe= undef;
3385
3361
  }
3386
3362
 
3387
3363
  $$args= [];
3388
 
  dtr_add_arg($$args, "-title");
3389
 
  dtr_add_arg($$args, "$type");
3390
 
  dtr_add_arg($$args, "-e");
 
3364
  mtr_add_arg($$args, "-title");
 
3365
  mtr_add_arg($$args, "$type");
 
3366
  mtr_add_arg($$args, "-e");
3391
3367
 
3392
3368
  if ( $exe_libtool )
3393
3369
  {
3394
 
    dtr_add_arg($$args, $exe_libtool);
3395
 
    dtr_add_arg($$args, "--mode=execute");
 
3370
    mtr_add_arg($$args, $exe_libtool);
 
3371
    mtr_add_arg($$args, "--mode=execute");
3396
3372
  }
3397
3373
 
3398
 
  dtr_add_arg($$args, "gdb");
3399
 
  dtr_add_arg($$args, "-x");
3400
 
  dtr_add_arg($$args, "$gdb_init_file");
3401
 
  dtr_add_arg($$args, "$$exe");
 
3374
  mtr_add_arg($$args, "gdb");
 
3375
  mtr_add_arg($$args, "-x");
 
3376
  mtr_add_arg($$args, "$gdb_init_file");
 
3377
  mtr_add_arg($$args, "$$exe");
3402
3378
 
3403
3379
  $$exe= "xterm";
3404
3380
}
3422
3398
  if ( $type eq "client" )
3423
3399
  {
3424
3400
    # write init file for client
3425
 
    dtr_tofile($gdb_init_file,
 
3401
    mtr_tofile($gdb_init_file,
3426
3402
               "set args $str\n" .
3427
3403
               "break main\n");
3428
3404
  }
3429
3405
  else
3430
3406
  {
3431
 
    # write init file for drizzled
3432
 
    dtr_tofile($gdb_init_file,
 
3407
    # write init file for mysqld
 
3408
    mtr_tofile($gdb_init_file,
3433
3409
               "file $$exe\n" .
3434
3410
               "set args $str\n" .
3435
3411
               "break drizzled::mysql_parse\n" .
3441
3417
  if ( $opt_manual_ddd )
3442
3418
  {
3443
3419
     print "\nTo start ddd for $type, type in another window:\n";
3444
 
     print "ddd -cd $glob_drizzle_test_dir -x $gdb_init_file $$exe\n";
 
3420
     print "ddd -cd $glob_mysql_test_dir -x $gdb_init_file $$exe\n";
3445
3421
 
3446
3422
     # Indicate the exe should not be started
3447
3423
     $$exe= undef;
3453
3429
  if ( $exe_libtool )
3454
3430
  {
3455
3431
    $$exe= $exe_libtool;
3456
 
    dtr_add_arg($$args, "--mode=execute");
3457
 
    dtr_add_arg($$args, "ddd");
 
3432
    mtr_add_arg($$args, "--mode=execute");
 
3433
    mtr_add_arg($$args, "ddd");
3458
3434
  }
3459
3435
  else
3460
3436
  {
3461
3437
    $$exe= "ddd";
3462
3438
  }
3463
 
  dtr_add_arg($$args, "--command=$gdb_init_file");
3464
 
  dtr_add_arg($$args, "$save_exe");
 
3439
  mtr_add_arg($$args, "--command=$gdb_init_file");
 
3440
  mtr_add_arg($$args, "$save_exe");
3465
3441
}
3466
3442
 
3467
3443
 
3499
3475
#  }
3500
3476
  else
3501
3477
  {
3502
 
    dtr_error("Unknown argument \"$debugger\" passed to --debugger");
 
3478
    mtr_error("Unknown argument \"$debugger\" passed to --debugger");
3503
3479
  }
3504
3480
}
3505
3481
 
3513
3489
 
3514
3490
  if ( $opt_callgrind)
3515
3491
  {
3516
 
    dtr_add_arg($args, "--tool=callgrind");
 
3492
    mtr_add_arg($args, "--tool=callgrind");
3517
3493
  }
3518
3494
  elsif ($opt_massif)
3519
3495
  {
3520
 
    dtr_add_arg($args, "--tool=massif");
 
3496
    mtr_add_arg($args, "--tool=massif");
3521
3497
  }
3522
3498
  else
3523
3499
  {
3524
 
    dtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
3525
 
    dtr_add_arg($args, "--leak-check=yes");
3526
 
    dtr_add_arg($args, "--num-callers=16");
3527
 
    dtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_drizzle_test_dir)
3528
 
      if -f "$glob_drizzle_test_dir/valgrind.supp";
 
3500
    mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
 
3501
    mtr_add_arg($args, "--leak-check=yes");
 
3502
    mtr_add_arg($args, "--num-callers=16");
 
3503
    mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir)
 
3504
      if -f "$glob_mysql_test_dir/valgrind.supp";
3529
3505
  }
3530
3506
 
3531
3507
  # Add valgrind options, can be overriden by user
3532
 
  dtr_add_arg($args, '%s', $_) for (@valgrind_args);
 
3508
  mtr_add_arg($args, '%s', $_) for (@valgrind_args);
3533
3509
 
3534
 
  dtr_add_arg($args, $$exe);
 
3510
  mtr_add_arg($args, $$exe);
3535
3511
 
3536
3512
  $$exe= $opt_valgrind_path || "valgrind";
3537
3513
 
3545
3521
}
3546
3522
 
3547
3523
 
3548
 
sub drizzled_wait_started($){
3549
 
  my $drizzled= shift;
 
3524
sub mysqld_wait_started($){
 
3525
  my $mysqld= shift;
3550
3526
 
3551
 
  if (sleep_until_file_created($drizzled->{'path_pid'},
3552
 
            $drizzled->{'start_timeout'},
3553
 
            $drizzled->{'pid'}) == 0)
 
3527
  if (sleep_until_file_created($mysqld->{'path_pid'},
 
3528
            $mysqld->{'start_timeout'},
 
3529
            $mysqld->{'pid'}) == 0)
3554
3530
  {
3555
3531
    # Failed to wait for pid file
3556
3532
    return 1;
3558
3534
 
3559
3535
  # Get the "real pid" of the process, it will be used for killing
3560
3536
  # the process in ActiveState's perl on windows
3561
 
  $drizzled->{'real_pid'}= dtr_get_pid_from_file($drizzled->{'path_pid'});
 
3537
  $mysqld->{'real_pid'}= mtr_get_pid_from_file($mysqld->{'path_pid'});
3562
3538
 
3563
3539
  return 0;
3564
3540
}
3628
3604
                        using a builtin list of standard locations
3629
3605
                        for tmpfs (/dev/shm)
3630
3606
                        The option can also be set using environment
3631
 
                        variable DTR_MEM=[DIR]
 
3607
                        variable MTR_MEM=[DIR]
3632
3608
 
3633
3609
Options to control what test suites or cases to run
3634
3610
 
3644
3620
                        list of suite names.
3645
3621
                        The default is: "$opt_suites_default"
3646
3622
  skip-rpl              Skip the replication test cases.
3647
 
  combination="ARG1 .. ARG2" Specify a set of "drizzled" arguments for one
 
3623
  combination="ARG1 .. ARG2" Specify a set of "mysqld" arguments for one
3648
3624
                        combination.
3649
3625
  skip-combination      Skip any combination options and combinations files
3650
3626
  repeat-test=n         How many times to repeat each test (default: 1)
3653
3629
 
3654
3630
  master_port=PORT      Specify the port number used by the first master
3655
3631
  slave_port=PORT       Specify the port number used by the first slave
3656
 
  dtr-build-thread=#    Specify unique collection of ports. Can also be set by
3657
 
                        setting the environment variable DTR_BUILD_THREAD.
 
3632
  mtr-build-thread=#    Specify unique collection of ports. Can also be set by
 
3633
                        setting the environment variable MTR_BUILD_THREAD.
3658
3634
 
3659
3635
Options for test case authoring
3660
3636
 
3664
3640
 
3665
3641
Options that pass on options
3666
3642
 
3667
 
  drizzled=ARGS           Specify additional arguments to "drizzled"
 
3643
  mysqld=ARGS           Specify additional arguments to "mysqld"
3668
3644
 
3669
3645
Options to run test on running server
3670
3646
 
3676
3652
  client-ddd            Start drizzletest client in ddd
3677
3653
  client-debugger=NAME  Start drizzletest in the selected debugger
3678
3654
  client-gdb            Start drizzletest client in gdb
3679
 
  ddd                   Start drizzled in ddd
 
3655
  ddd                   Start mysqld in ddd
3680
3656
  debug                 Dump trace output for all servers and client programs
3681
 
  debugger=NAME         Start drizzled in the selected debugger
3682
 
  gdb                   Start the drizzled(s) in gdb
3683
 
  manual-debug          Let user manually start drizzled in debugger, before
 
3657
  debugger=NAME         Start mysqld in the selected debugger
 
3658
  gdb                   Start the mysqld(s) in gdb
 
3659
  manual-debug          Let user manually start mysqld in debugger, before
3684
3660
                        running test(s)
3685
 
  manual-gdb            Let user manually start drizzled in gdb, before running
3686
 
                        test(s)
3687
 
  manual-ddd            Let user manually start drizzled in ddd, before running
3688
 
                        test(s)
3689
 
  master-binary=PATH    Specify the master "drizzled" to use
3690
 
  slave-binary=PATH     Specify the slave "drizzled" to use
 
3661
  manual-gdb            Let user manually start mysqld in gdb, before running
 
3662
                        test(s)
 
3663
  manual-ddd            Let user manually start mysqld in ddd, before running
 
3664
                        test(s)
 
3665
  master-binary=PATH    Specify the master "mysqld" to use
 
3666
  slave-binary=PATH     Specify the slave "mysqld" to use
3691
3667
  strace-client         Create strace output for drizzletest client
3692
3668
  max-save-core         Limit the number of core files saved (to avoid filling
3693
3669
                        up disks for heavily crashing server). Defaults to
3697
3673
 
3698
3674
  gcov                  FIXME
3699
3675
  gprof                 See online documentation on how to use it.
3700
 
  valgrind              Run the "drizzletest" and "drizzled" executables using
 
3676
  valgrind              Run the "drizzletest" and "mysqld" executables using
3701
3677
                        valgrind with default options
3702
3678
  valgrind-all          Synonym for --valgrind
3703
3679
  valgrind-drizzleslap  Run "drizzleslap" with valgrind.
3704
3680
  valgrind-drizzletest  Run the "drizzletest" and "drizzle_client_test" executable
3705
3681
                        with valgrind
3706
 
  valgrind-drizzled       Run the "drizzled" executable with valgrind
 
3682
  valgrind-mysqld       Run the "mysqld" executable with valgrind
3707
3683
  valgrind-options=ARGS Deprecated, use --valgrind-option
3708
3684
  valgrind-option=ARGS  Option to give valgrind, replaces default option(s),
3709
3685
                        can be specified more then once
3727
3703
 
3728
3704
  testcase-timeout=MINUTES Max test case run time (default $default_testcase_timeout)
3729
3705
  suite-timeout=MINUTES Max test suite run time (default $default_suite_timeout)
3730
 
  warnings | log-warnings Pass --log-warnings to drizzled
 
3706
  warnings | log-warnings Pass --log-warnings to mysqld
3731
3707
 
3732
3708
  sleep=SECONDS         Passed to drizzletest, will be used as fixed sleep time
3733
3709
 
3734
3710
HERE
3735
 
  dtr_exit(1);
 
3711
  mtr_exit(1);
3736
3712
 
3737
3713
}