~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/test-run.pl

  • Committer: Monty Taylor
  • Date: 2009-12-08 23:39:39 UTC
  • mto: (1240.1.8 build)
  • mto: This revision was merged to the branch mainline in revision 1241.
  • Revision ID: mordred@inaugust.com-20091208233939-w0v4o04xer9pqqhu
Make range test shut up.

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
 
114
98
##############################################################################
115
99
 
116
100
# Misc global variables
117
 
our $drizzle_version_id;
 
101
our $mysql_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;
131
115
our $path_snapshot;
132
116
our $path_drizzletest_log;
133
117
our $path_current_test_log;
 
118
our $path_my_basedir;
134
119
 
135
120
our $opt_vardir;                 # A path but set directly on cmd line
136
 
our $opt_top_srcdir;
137
 
our $opt_top_builddir;
138
121
our $path_vardir_trace;          # unix formatted opt_vardir for trace files
139
122
our $opt_tmpdir;                 # A path but set directly on cmd line
140
123
our $opt_suitepath;
143
126
our $opt_subunit;
144
127
 
145
128
our $default_vardir;
146
 
our $default_top_srcdir;
147
 
our $default_top_builddir;
148
129
 
149
130
our $opt_usage;
150
131
our $opt_suites;
154
135
 
155
136
our $opt_repeat_test= 1;
156
137
 
157
 
our $exe_master_drizzled;
 
138
our $exe_master_mysqld;
158
139
our $exe_drizzle;
159
 
our $exe_drizzleadmin;
160
140
our $exe_drizzle_client_test;
161
141
our $exe_bug25714;
162
142
our $exe_drizzled;
165
145
our $exe_drizzleimport;
166
146
our $exe_drizzle_fix_system_tables;
167
147
our $exe_drizzletest;
168
 
our $exe_slave_drizzled;
 
148
our $exe_slave_mysqld;
 
149
our $exe_my_print_defaults;
169
150
our $exe_perror;
170
151
our $lib_udf_example;
171
152
our $lib_example_plugin;
172
153
our $exe_libtool;
173
 
our $exe_schemawriter;
174
154
 
175
155
our $opt_bench= 0;
176
156
our $opt_small_bench= 0;
178
158
our @opt_combinations;
179
159
our $opt_skip_combination;
180
160
 
181
 
our @opt_extra_drizzled_opt;
 
161
our @opt_extra_mysqld_opt;
182
162
 
183
163
our $opt_compress;
184
164
 
194
174
our $opt_force;
195
175
our $opt_reorder= 0;
196
176
our $opt_enable_disabled;
197
 
our $opt_mem= $ENV{'DTR_MEM'};
 
177
our $opt_mem= $ENV{'MTR_MEM'};
198
178
 
199
179
our $opt_gcov;
200
180
our $opt_gcov_err;
213
193
our $opt_manual_ddd;
214
194
our $opt_manual_debug;
215
195
# Magic number -69.4 results in traditional test ports starting from 9306.
216
 
our $opt_dtr_build_thread=-69.4;
 
196
our $opt_mtr_build_thread=-69.4;
217
197
our $opt_debugger;
218
198
our $opt_client_debugger;
219
199
 
229
209
our $opt_master_myport;
230
210
our $opt_slave_myport;
231
211
our $opt_memc_myport;
232
 
our $opt_pbms_myport;
233
 
our $opt_rabbitmq_myport;
234
212
our $opt_record;
235
213
my $opt_report_features;
236
214
our $opt_check_testcases;
260
238
our $opt_user;
261
239
 
262
240
my $opt_valgrind= 0;
263
 
my $opt_valgrind_drizzled= 0;
 
241
my $opt_valgrind_mysqld= 0;
264
242
my $opt_valgrind_drizzletest= 0;
265
 
my $opt_valgrind_drizzleslap= 0;
266
 
my @default_valgrind_args= ("--show-reachable=yes --malloc-fill=0xDEADBEEF --free-fill=0xDEADBEEF");
 
243
my @default_valgrind_args= ("--show-reachable=yes");
267
244
my @valgrind_args;
268
245
my $opt_valgrind_path;
269
246
my $opt_callgrind;
270
 
my $opt_massif;
271
247
 
272
248
our $opt_stress=               "";
273
249
our $opt_stress_suite=     "main";
288
264
our $used_default_engine;
289
265
our $debug_compiled_binaries;
290
266
 
291
 
our %drizzled_variables;
 
267
our %mysqld_variables;
292
268
 
293
269
my $source_dist= 0;
294
270
 
295
271
our $opt_max_save_core= 5;
296
272
my $num_saved_cores= 0;  # Number of core files saved in vardir/log/ so far.
297
 
our $secondary_port_offset= 50;
298
273
 
299
274
######################################################################
300
275
#
305
280
sub main ();
306
281
sub initial_setup ();
307
282
sub command_line_setup ();
308
 
sub set_dtr_build_thread_ports($);
 
283
sub set_mtr_build_thread_ports($);
309
284
sub datadir_list_setup ();
310
285
sub executable_setup ();
311
286
sub environment_setup ();
313
288
sub remove_stale_vardir ();
314
289
sub setup_vardir ();
315
290
sub check_running_as_root();
316
 
sub drizzled_wait_started($);
 
291
sub mysqld_wait_started($);
317
292
sub run_benchmarks ($);
318
293
sub initialize_servers ();
319
 
sub drizzle_install_db ();
 
294
sub mysql_install_db ();
320
295
sub copy_install_db ($$);
321
296
sub run_testcase ($);
322
297
sub run_testcase_stop_servers ($$$);
325
300
sub report_failure_and_restart ($);
326
301
sub do_before_start_master ($);
327
302
sub do_before_start_slave ($);
328
 
sub drizzled_start ($$$);
329
 
sub drizzled_arguments ($$$$);
 
303
sub mysqld_start ($$$);
 
304
sub mysqld_arguments ($$$$);
330
305
sub stop_all_servers ();
331
306
sub run_drizzletest ($);
332
307
sub collapse_path ($);
345
320
 
346
321
  command_line_setup();
347
322
 
348
 
  check_debug_support(\%drizzled_variables);
 
323
  check_debug_support(\%mysqld_variables);
349
324
 
350
325
  executable_setup();
351
326
 
374
349
  }
375
350
  else
376
351
  {
377
 
 
 
352
    # Figure out which tests we are going to run
378
353
    if (!$opt_suites)
379
354
    {
380
 
 
381
 
        $opt_suites= $opt_suites_default;
382
 
 
383
 
        my %extra_suites= ();
384
 
 
385
 
        foreach my $dir ( reverse splitdir($glob_basedir) )
386
 
        {
387
 
            my $extra_suite= $extra_suites{$dir};
388
 
            if (defined $extra_suite){
389
 
                dtr_report("Found extra suite: $extra_suite");
390
 
                $opt_suites= "$extra_suite,$opt_suites";
391
 
                last;
392
 
            }
393
 
        }
 
355
      $opt_suites= $opt_suites_default;
 
356
 
 
357
      # Check for any extra suites to enable based on the path name
 
358
      my %extra_suites= ();
 
359
 
 
360
      foreach my $dir ( reverse splitdir($glob_basedir) )
 
361
      {
 
362
        my $extra_suite= $extra_suites{$dir};
 
363
        if (defined $extra_suite){
 
364
          mtr_report("Found extra suite: $extra_suite");
 
365
          $opt_suites= "$extra_suite,$opt_suites";
 
366
          last;
 
367
        }
 
368
      }
394
369
    }
395
370
 
396
371
    my $tests= collect_test_cases($opt_suites);
405
380
        # Count max number of slaves used by a test case
406
381
        if ( $test->{slave_num} > $max_slave_num) {
407
382
          $max_slave_num= $test->{slave_num};
408
 
          dtr_error("Too many slaves") if $max_slave_num > 3;
 
383
          mtr_error("Too many slaves") if $max_slave_num > 3;
409
384
        }
410
385
 
411
386
        # Count max number of masters used by a test case
412
387
        if ( $test->{master_num} > $max_master_num) {
413
388
          $max_master_num= $test->{master_num};
414
 
          dtr_error("Too many masters") if $max_master_num > 2;
415
 
          dtr_error("Too few masters") if $max_master_num < 1;
 
389
          mtr_error("Too many masters") if $max_master_num > 2;
 
390
          mtr_error("Too few masters") if $max_master_num < 1;
416
391
        }
417
392
      }
418
393
      $use_innodb||= $test->{'innodb_test'};
427
402
    run_tests($tests);
428
403
  }
429
404
 
430
 
  dtr_exit(0);
 
405
  mtr_exit(0);
431
406
}
432
407
 
433
408
##############################################################################
438
413
 
439
414
#
440
415
# When an option is no longer used by this program, it must be explicitly
441
 
# ignored or else it will be passed through to drizzled.  GetOptions will call
 
416
# ignored or else it will be passed through to mysqld.  GetOptions will call
442
417
# this subroutine once for each such option on the command line.  See
443
418
# Getopt::Long documentation.
444
419
#
456
431
  my $opt_comment;
457
432
 
458
433
  # If so requested, we try to avail ourselves of a unique build thread number.
459
 
  if ( $ENV{'DTR_BUILD_THREAD'} ) {
460
 
    if ( lc($ENV{'DTR_BUILD_THREAD'}) eq 'auto' ) {
 
434
  if ( $ENV{'MTR_BUILD_THREAD'} ) {
 
435
    if ( lc($ENV{'MTR_BUILD_THREAD'}) eq 'auto' ) {
461
436
      print "Requesting build thread... ";
462
 
      $ENV{'DTR_BUILD_THREAD'} = dtr_require_unique_id_and_wait("/tmp/drizzle-test-ports", 200, 299);
463
 
      print "got ".$ENV{'DTR_BUILD_THREAD'}."\n";
 
437
      $ENV{'MTR_BUILD_THREAD'} = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299);
 
438
      print "got ".$ENV{'MTR_BUILD_THREAD'}."\n";
464
439
    }
465
440
  }
466
441
 
467
 
  if ( $ENV{'DTR_BUILD_THREAD'} )
 
442
  if ( $ENV{'MTR_BUILD_THREAD'} )
468
443
  {
469
 
    set_dtr_build_thread_ports($ENV{'DTR_BUILD_THREAD'});
 
444
    set_mtr_build_thread_ports($ENV{'MTR_BUILD_THREAD'});
470
445
  }
471
446
 
472
447
  # This is needed for test log evaluation in "gen-build-status-page"
478
453
  # Note: Keep list, and the order, in sync with usage at end of this file
479
454
 
480
455
  # Options that are no longer used must still be processed, because all
481
 
  # unprocessed options are passed directly to drizzled.  The user will be
 
456
  # unprocessed options are passed directly to mysqld.  The user will be
482
457
  # warned that the option is being ignored.
483
458
  #
484
459
  # Put the complete option string here.  For example, to remove the --suite
508
483
             'master_port=i'            => \$opt_master_myport,
509
484
             'slave_port=i'             => \$opt_slave_myport,
510
485
             'memc_port=i'              => \$opt_memc_myport,
511
 
             'pbms_port=i'              => \$opt_pbms_myport,
512
 
             'rabbitmq_port=i'              => \$opt_rabbitmq_myport,
513
 
             'dtr-build-thread=i'       => \$opt_dtr_build_thread,
 
486
             'mtr-build-thread=i'       => \$opt_mtr_build_thread,
514
487
 
515
488
             # Test case authoring
516
489
             'record'                   => \$opt_record,
517
490
             'check-testcases'          => \$opt_check_testcases,
518
491
             'mark-progress'            => \$opt_mark_progress,
519
492
 
520
 
             # Extra options used when starting drizzled
521
 
             'drizzled=s'                 => \@opt_extra_drizzled_opt,
 
493
             # Extra options used when starting mysqld
 
494
             'mysqld=s'                 => \@opt_extra_mysqld_opt,
522
495
             'engine=s'                 => \$opt_engine,
523
496
 
524
497
             # Run test on running server
541
514
             'debugger=s'               => \$opt_debugger,
542
515
             'client-debugger=s'        => \$opt_client_debugger,
543
516
             'strace-client'            => \$opt_strace_client,
544
 
             'master-binary=s'          => \$exe_master_drizzled,
545
 
             'slave-binary=s'           => \$exe_slave_drizzled,
 
517
             'master-binary=s'          => \$exe_master_mysqld,
 
518
             'slave-binary=s'           => \$exe_slave_mysqld,
546
519
             'max-save-core=i'          => \$opt_max_save_core,
547
520
 
548
521
             # Coverage, profiling etc
550
523
             'gprof'                    => \$opt_gprof,
551
524
             'valgrind|valgrind-all'    => \$opt_valgrind,
552
525
             'valgrind-drizzletest'       => \$opt_valgrind_drizzletest,
553
 
             'valgrind-drizzleslap'       => \$opt_valgrind_drizzleslap,
554
 
             'valgrind-drizzled'          => \$opt_valgrind_drizzled,
 
526
             'valgrind-mysqld'          => \$opt_valgrind_mysqld,
555
527
             'valgrind-options=s'       => sub {
556
528
               my ($opt, $value)= @_;
557
529
               # Deprecated option unless it's what we know pushbuild uses
566
538
             'valgrind-option=s'        => \@valgrind_args,
567
539
             'valgrind-path=s'          => \$opt_valgrind_path,
568
540
             'callgrind'                => \$opt_callgrind,
569
 
             'massif'                   => \$opt_massif,
570
541
 
571
542
             # Stress testing 
572
543
             'stress'                   => \$opt_stress,
582
553
             # Directories
583
554
             'tmpdir=s'                 => \$opt_tmpdir,
584
555
             'vardir=s'                 => \$opt_vardir,
585
 
             'top-builddir=s'           => \$opt_top_builddir,
586
 
             'top-srcdir=s'             => \$opt_top_srcdir,
587
556
             'suitepath=s'              => \$opt_suitepath,
588
557
             'testdir=s'                => \$opt_testdir,
589
 
             'benchdir=s'               => \$glob_drizzle_bench_dir,
 
558
             'benchdir=s'               => \$glob_mysql_bench_dir,
590
559
             'mem'                      => \$opt_mem,
591
560
 
592
561
             # Misc
615
584
             'help|h'                   => \$opt_usage,
616
585
            ) or usage("Can't read options");
617
586
 
 
587
  usage("") if $opt_usage;
 
588
 
618
589
  usage("you cannot specify --gdb and --dbx both!") if 
619
590
        ($opt_gdb && $opt_dbx) ||
620
591
        ($opt_manual_gdb && $opt_manual_dbx);
621
592
 
622
593
  $glob_scriptname=  basename($0);
623
594
 
624
 
  if ($opt_dtr_build_thread != 0)
 
595
  if ($opt_mtr_build_thread != 0)
625
596
  {
626
 
    set_dtr_build_thread_ports($opt_dtr_build_thread)
 
597
    set_mtr_build_thread_ports($opt_mtr_build_thread)
627
598
  }
628
 
  elsif ($ENV{'DTR_BUILD_THREAD'})
 
599
  elsif ($ENV{'MTR_BUILD_THREAD'})
629
600
  {
630
 
    $opt_dtr_build_thread= $ENV{'DTR_BUILD_THREAD'};
 
601
    $opt_mtr_build_thread= $ENV{'MTR_BUILD_THREAD'};
631
602
  }
632
603
 
633
604
  if ( -d "../drizzled" )
638
609
  # Find the absolute path to the test directory
639
610
  if ( ! $opt_testdir )
640
611
  {
641
 
    $glob_drizzle_test_dir=  cwd();
 
612
    $glob_mysql_test_dir=  cwd();
642
613
  } 
643
614
  else
644
615
  {
645
 
    $glob_drizzle_test_dir= $opt_testdir;
 
616
    $glob_mysql_test_dir= $opt_testdir;
646
617
  }
647
 
  $default_vardir= "$glob_drizzle_test_dir/var";
648
 
  $default_top_srcdir= "$glob_drizzle_test_dir/..";
649
 
  $default_top_builddir= "$glob_drizzle_test_dir/..";
 
618
  $default_vardir= "$glob_mysql_test_dir/var";
650
619
 
651
620
  if ( ! $opt_suitepath )
652
621
  {
653
 
    $glob_suite_path= "$glob_drizzle_test_dir/../plugin";
 
622
    $glob_suite_path= "$glob_mysql_test_dir/../plugin";
654
623
  }
655
624
  else
656
625
  {
657
626
    $glob_suite_path= $opt_suitepath;
658
627
  }
659
628
  # In most cases, the base directory we find everything relative to,
660
 
  # is the parent directory of the "drizzle-test" directory. For source
 
629
  # is the parent directory of the "mysql-test" directory. For source
661
630
  # distributions, TAR binary distributions and some other packages.
662
 
  $glob_basedir= dirname($glob_drizzle_test_dir);
663
 
 
664
 
  # Figure out which tests we are going to run
665
 
  my $suitedir= "$glob_drizzle_test_dir/suite";
666
 
  if ( -d $suitedir )
667
 
  {
668
 
      opendir(SUITE_DIR, $suitedir)
669
 
          or dtr_error("can't open directory \"$suitedir\": $!");
670
 
 
671
 
      while ( my $elem= readdir(SUITE_DIR) )
672
 
      {
673
 
          next if $elem eq ".";
674
 
          next if $elem eq "..";
675
 
          next if $elem eq "big"; # Eats up too much disk
676
 
          next if $elem eq "large_tests"; # Eats up too much disk
677
 
          next if $elem eq "stress"; # Currently fails
678
 
          next if $elem eq "broken"; # Old broken test, mainly unsupported featurs
679
 
 
680
 
          my $local_dir= "$suitedir/$elem";
681
 
 
682
 
          next unless -d $local_dir;
683
 
          next unless -d "$local_dir/t"; # We want to make sure it has tests
684
 
          next unless -d "$local_dir/r"; # Ditto, results
685
 
 
686
 
          $opt_suites_default.= ",$elem";
687
 
      }
688
 
      closedir(SUITE_DIR);
689
 
  }
690
 
 
691
 
  usage("") if $opt_usage;
 
631
  $glob_basedir= dirname($glob_mysql_test_dir);
692
632
 
693
633
  # In the RPM case, binaries and libraries are installed in the
694
634
  # default system locations, instead of having our own private base
695
 
  # directory. And we install "/usr/share/drizzle-test". Moving up one
696
 
  # more directory relative to "drizzle-test" gives us a usable base
 
635
  # directory. And we install "/usr/share/mysql-test". Moving up one
 
636
  # more directory relative to "mysql-test" gives us a usable base
697
637
  # directory for RPM installs.
698
638
  if ( ! $source_dist and ! -d "$glob_basedir/bin" )
699
639
  {
711
651
    $glob_builddir="..";
712
652
  }
713
653
 
714
 
  # Expect drizzle-bench to be located adjacent to the source tree, by default
715
 
  $glob_drizzle_bench_dir= "$glob_basedir/../drizzle-bench"
716
 
    unless defined $glob_drizzle_bench_dir;
717
 
  $glob_drizzle_bench_dir= undef
718
 
    unless -d $glob_drizzle_bench_dir;
719
 
 
720
 
  $glob_timers= dtr_init_timers();
 
654
  # Expect mysql-bench to be located adjacent to the source tree, by default
 
655
  $glob_mysql_bench_dir= "$glob_basedir/../mysql-bench"
 
656
    unless defined $glob_mysql_bench_dir;
 
657
  $glob_mysql_bench_dir= undef
 
658
    unless -d $glob_mysql_bench_dir;
 
659
 
 
660
  $path_my_basedir=
 
661
    $source_dist ? $glob_mysql_test_dir : $glob_basedir;
 
662
 
 
663
  $glob_timers= mtr_init_timers();
721
664
 
722
665
  #
723
 
  # Find the drizzled executable to be able to find the drizzled version
 
666
  # Find the mysqld executable to be able to find the mysqld version
724
667
  # number as early as possible
725
668
  #
726
669
 
727
670
  # Look for the client binaries directory
728
 
  $path_client_bindir= dtr_path_exists("$glob_builddir/client",
 
671
  $path_client_bindir= mtr_path_exists("$glob_builddir/client",
729
672
                                       "$glob_basedir/client",
730
673
                                       "$glob_basedir/bin");
731
674
 
732
675
  if (!$opt_extern)
733
676
  {
734
 
    $exe_drizzled=       dtr_exe_exists ("$glob_basedir/drizzled/drizzled",
 
677
    $exe_drizzled=       mtr_exe_exists ("$glob_basedir/drizzled/drizzled",
735
678
                                       "$path_client_bindir/drizzled",
736
679
                                       "$glob_basedir/libexec/drizzled",
737
680
                                       "$glob_basedir/bin/drizzled",
738
681
                                       "$glob_basedir/sbin/drizzled",
739
682
                                       "$glob_builddir/drizzled/drizzled");
740
683
 
741
 
    # Use the drizzled found above to find out what features are available
742
 
    collect_drizzled_features();
 
684
    # Use the mysqld found above to find out what features are available
 
685
    collect_mysqld_features();
743
686
  }
744
687
  else
745
688
  {
746
 
    $drizzled_variables{'port'}= 4427;
 
689
    $mysqld_variables{'port'}= 4427;
747
690
  }
748
691
 
749
692
  if (!$opt_engine)
763
706
  {
764
707
    if ( $arg =~ /^--skip-/ )
765
708
    {
766
 
      push(@opt_extra_drizzled_opt, $arg);
 
709
      push(@opt_extra_mysqld_opt, $arg);
767
710
    }
768
711
    elsif ( $arg =~ /^--$/ )
769
712
    {
784
727
  # --------------------------------------------------------------------------
785
728
  # Find out default storage engine being used(if any)
786
729
  # --------------------------------------------------------------------------
787
 
  foreach my $arg ( @opt_extra_drizzled_opt )
 
730
  foreach my $arg ( @opt_extra_mysqld_opt )
788
731
  {
789
732
    if ( $arg =~ /default-storage-engine=(\S+)/ )
790
733
    {
791
734
      $used_default_engine= $1;
792
735
    }
793
736
  }
794
 
  dtr_report("Using default engine '$used_default_engine'")
 
737
  mtr_report("Using default engine '$used_default_engine'")
795
738
    if defined $used_default_engine;
796
739
 
797
740
  # --------------------------------------------------------------------------
799
742
  # --------------------------------------------------------------------------
800
743
  if ( defined $opt_mem )
801
744
  {
802
 
    dtr_error("Can't use --mem and --vardir at the same time ")
 
745
    mtr_error("Can't use --mem and --vardir at the same time ")
803
746
      if $opt_vardir;
804
 
    dtr_error("Can't use --mem and --tmpdir at the same time ")
 
747
    mtr_error("Can't use --mem and --tmpdir at the same time ")
805
748
      if $opt_tmpdir;
806
749
 
807
750
    # Search through list of locations that are known
813
756
    {
814
757
      if ( -d $fs )
815
758
      {
816
 
        dtr_report("Using tmpfs in $fs");
 
759
        mtr_report("Using tmpfs in $fs");
817
760
        $opt_mem= "$fs/var";
818
 
        $opt_mem .= $opt_dtr_build_thread if $opt_dtr_build_thread;
 
761
        $opt_mem .= $opt_mtr_build_thread if $opt_mtr_build_thread;
819
762
        last;
820
763
      }
821
764
    }
829
772
    $opt_vardir= $default_vardir;
830
773
  }
831
774
 
832
 
  if ( ! $opt_top_srcdir )
833
 
  {
834
 
    $opt_top_srcdir= $default_top_srcdir;
835
 
  }
836
 
  else
837
 
  {
838
 
    $opt_top_srcdir= rel2abs($opt_top_srcdir);
839
 
  }
840
 
 
841
 
  if ( ! $opt_top_builddir )
842
 
  {
843
 
    $opt_top_builddir= $default_top_builddir;
844
 
  }
845
 
  else
846
 
  {
847
 
    $opt_top_builddir= rel2abs($opt_top_builddir);
848
 
  }
849
 
 
850
775
  $path_vardir_trace= $opt_vardir;
851
776
  # Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/...
852
777
  $path_vardir_trace=~ s/^\w://;
864
789
# --------------------------------------------------------------------------
865
790
  if ( $opt_record and ! @opt_cases )
866
791
  {
867
 
    dtr_error("Will not run in record mode without a specific test case");
 
792
    mtr_error("Will not run in record mode without a specific test case");
868
793
  }
869
794
 
870
795
  if ( $opt_record )
885
810
  # --------------------------------------------------------------------------
886
811
  if ( $opt_gcov and ! $source_dist )
887
812
  {
888
 
    dtr_error("Coverage test needs the source - please use source dist");
 
813
    mtr_error("Coverage test needs the source - please use source dist");
889
814
  }
890
815
 
891
816
  # --------------------------------------------------------------------------
899
824
    $glob_debugger= 1;
900
825
    if ( $opt_extern )
901
826
    {
902
 
      dtr_error("Can't use --extern when using debugger");
 
827
      mtr_error("Can't use --extern when using debugger");
903
828
    }
904
829
  }
905
830
 
906
831
  # --------------------------------------------------------------------------
907
832
  # Check if special exe was selected for master or slave
908
833
  # --------------------------------------------------------------------------
909
 
  $exe_master_drizzled= $exe_master_drizzled || $exe_drizzled;
910
 
  $exe_slave_drizzled=  $exe_slave_drizzled  || $exe_drizzled;
 
834
  $exe_master_mysqld= $exe_master_mysqld || $exe_drizzled;
 
835
  $exe_slave_mysqld=  $exe_slave_mysqld  || $exe_drizzled;
911
836
 
912
837
  # --------------------------------------------------------------------------
913
838
  # Check valgrind arguments
914
839
  # --------------------------------------------------------------------------
915
840
  if ( $opt_valgrind or $opt_valgrind_path or @valgrind_args)
916
841
  {
917
 
    dtr_report("Turning on valgrind for all executables");
 
842
    mtr_report("Turning on valgrind for all executables");
918
843
    $opt_valgrind= 1;
919
 
    $opt_valgrind_drizzled= 1;
 
844
    $opt_valgrind_mysqld= 1;
920
845
    $opt_valgrind_drizzletest= 1;
921
 
    $ENV{'VALGRIND_RUN'} = '1';
922
846
  }
923
 
  elsif ( $opt_valgrind_drizzled )
 
847
  elsif ( $opt_valgrind_mysqld )
924
848
  {
925
 
    dtr_report("Turning on valgrind for drizzled(s) only");
 
849
    mtr_report("Turning on valgrind for mysqld(s) only");
926
850
    $opt_valgrind= 1;
927
851
  }
928
852
  elsif ( $opt_valgrind_drizzletest )
929
853
  {
930
 
    dtr_report("Turning on valgrind for drizzletest and drizzle_client_test only");
931
 
    $opt_valgrind= 1;
932
 
  }
933
 
  elsif ( $opt_valgrind_drizzleslap )
934
 
  {
935
 
    dtr_report("Turning on valgrind for drizzleslap only");
 
854
    mtr_report("Turning on valgrind for drizzletest and drizzle_client_test only");
936
855
    $opt_valgrind= 1;
937
856
  }
938
857
 
939
858
  if ( $opt_callgrind )
940
859
  {
941
 
    dtr_report("Turning on valgrind with callgrind for drizzled(s)");
 
860
    mtr_report("Turning on valgrind with callgrind for mysqld(s)");
942
861
    $opt_valgrind= 1;
943
 
    $opt_valgrind_drizzled= 1;
 
862
    $opt_valgrind_mysqld= 1;
944
863
 
945
864
    # Set special valgrind options unless options passed on command line
946
865
    push(@valgrind_args, "--trace-children=yes")
947
866
      unless @valgrind_args;
948
867
  }
949
868
 
950
 
  if ( $opt_massif )
951
 
  {
952
 
    dtr_report("Valgrind with Massif tool for drizzled(s)");
953
 
    $opt_valgrind= 1;
954
 
    $opt_valgrind_drizzled= 1;
955
 
  }
956
 
 
957
869
  if ( $opt_valgrind )
958
870
  {
959
871
    # Set valgrind_options to default unless already defined
960
872
    push(@valgrind_args, @default_valgrind_args)
961
873
      unless @valgrind_args;
962
874
 
963
 
    dtr_report("Running valgrind with options \"",
 
875
    mtr_report("Running valgrind with options \"",
964
876
               join(" ", @valgrind_args), "\"");
965
877
  }
966
878
 
988
900
    }
989
901
  }
990
902
 
 
903
  # On QNX, /tmp/dir/master.sock and /tmp/dir//master.sock seem to be
 
904
  # considered different, so avoid the extra slash (/) in the socket
 
905
  # paths.
 
906
  my $sockdir = $opt_tmpdir;
 
907
  $sockdir =~ s|/+$||;
 
908
 
 
909
  # On some operating systems, there is a limit to the length of a
 
910
  # UNIX domain socket's path far below PATH_MAX, so try to avoid long
 
911
  # socket path names.
 
912
  $sockdir = tempdir(CLEANUP => 0) if ( length($sockdir) >= 70 );
 
913
 
991
914
  $master->[0]=
992
915
  {
993
 
   pid            => 0,
994
 
   type           => "master",
995
 
   idx            => 0,
996
 
   path_myddir    => "$opt_vardir/master-data",
997
 
   path_myerr     => "$opt_vardir/log/master.err",
998
 
   path_pid       => "$opt_vardir/run/master.pid",
999
 
   path_sock      => "$opt_vardir/master.sock",
1000
 
   port           =>  $opt_master_myport,
1001
 
   secondary_port =>  $opt_master_myport + $secondary_port_offset,
1002
 
   start_timeout  =>  400, # enough time create innodb tables
1003
 
   cluster        =>  0, # index in clusters list
1004
 
   start_opts     => [],
 
916
   pid           => 0,
 
917
   type          => "master",
 
918
   idx           => 0,
 
919
   path_myddir   => "$opt_vardir/master-data",
 
920
   path_myerr    => "$opt_vardir/log/master.err",
 
921
   path_pid      => "$opt_vardir/run/master.pid",
 
922
   path_sock     => "$sockdir/master.sock",
 
923
   port          =>  $opt_master_myport,
 
924
   start_timeout =>  400, # enough time create innodb tables
 
925
   cluster       =>  0, # index in clusters list
 
926
   start_opts    => [],
1005
927
  };
1006
928
 
1007
929
  $master->[1]=
1008
930
  {
1009
 
   pid            => 0,
1010
 
   type           => "master",
1011
 
   idx            => 1,
1012
 
   path_myddir    => "$opt_vardir/master1-data",
1013
 
   path_myerr     => "$opt_vardir/log/master1.err",
1014
 
   path_pid       => "$opt_vardir/run/master1.pid",
1015
 
   path_sock      => "$opt_vardir/master1.sock",
1016
 
   port           => $opt_master_myport + 1,
1017
 
   secondary_port => $opt_master_myport + 1 + $secondary_port_offset,
1018
 
   start_timeout  => 400, # enough time create innodb tables
1019
 
   cluster        =>  0, # index in clusters list
1020
 
   start_opts     => [],
 
931
   pid           => 0,
 
932
   type          => "master",
 
933
   idx           => 1,
 
934
   path_myddir   => "$opt_vardir/master1-data",
 
935
   path_myerr    => "$opt_vardir/log/master1.err",
 
936
   path_pid      => "$opt_vardir/run/master1.pid",
 
937
   path_sock     => "$sockdir/master1.sock",
 
938
   port          => $opt_master_myport + 1,
 
939
   start_timeout => 400, # enough time create innodb tables
 
940
   cluster       =>  0, # index in clusters list
 
941
   start_opts    => [],
1021
942
  };
1022
943
 
1023
944
  $slave->[0]=
1024
945
  {
1025
 
   pid            => 0,
1026
 
   type           => "slave",
1027
 
   idx            => 0,
1028
 
   path_myddir    => "$opt_vardir/slave-data",
1029
 
   path_myerr     => "$opt_vardir/log/slave.err",
1030
 
   path_pid       => "$opt_vardir/run/slave.pid",
1031
 
   path_sock      => "$opt_vardir/slave.sock",
1032
 
   port           => $opt_slave_myport,
1033
 
   secondary_port => $opt_slave_myport + $secondary_port_offset,
1034
 
   start_timeout  => 400,
1035
 
   cluster        =>  1, # index in clusters list
1036
 
   start_opts     => [],
 
946
   pid           => 0,
 
947
   type          => "slave",
 
948
   idx           => 0,
 
949
   path_myddir   => "$opt_vardir/slave-data",
 
950
   path_myerr    => "$opt_vardir/log/slave.err",
 
951
   path_pid    => "$opt_vardir/run/slave.pid",
 
952
   path_sock   => "$sockdir/slave.sock",
 
953
   port   => $opt_slave_myport,
 
954
   start_timeout => 400,
 
955
 
 
956
   cluster       =>  1, # index in clusters list
 
957
   start_opts    => [],
1037
958
  };
1038
959
 
1039
960
  $slave->[1]=
1040
961
  {
1041
 
   pid            => 0,
1042
 
   type           => "slave",
1043
 
   idx            => 1,
1044
 
   path_myddir    => "$opt_vardir/slave1-data",
1045
 
   path_myerr     => "$opt_vardir/log/slave1.err",
1046
 
   path_pid       => "$opt_vardir/run/slave1.pid",
1047
 
   path_sock      => "$opt_vardir/slave1.sock",
1048
 
   port           => $opt_slave_myport + 1,
1049
 
   secondary_port => $opt_slave_myport + 1 + $secondary_port_offset,
1050
 
   start_timeout  => 300,
1051
 
   cluster        =>  -1, # index in clusters list
1052
 
   start_opts     => [],
 
962
   pid           => 0,
 
963
   type          => "slave",
 
964
   idx           => 1,
 
965
   path_myddir   => "$opt_vardir/slave1-data",
 
966
   path_myerr    => "$opt_vardir/log/slave1.err",
 
967
   path_pid    => "$opt_vardir/run/slave1.pid",
 
968
   path_sock   => "$sockdir/slave1.sock",
 
969
   port   => $opt_slave_myport + 1,
 
970
   start_timeout => 300,
 
971
   cluster       =>  -1, # index in clusters list
 
972
   start_opts    => [],
1053
973
  };
1054
974
 
1055
975
  $slave->[2]=
1056
976
  {
1057
 
   pid            => 0,
1058
 
   type           => "slave",
1059
 
   idx            => 2,
1060
 
   path_myddir    => "$opt_vardir/slave2-data",
1061
 
   path_myerr     => "$opt_vardir/log/slave2.err",
1062
 
   path_pid       => "$opt_vardir/run/slave2.pid",
1063
 
   path_sock      => "$opt_vardir/slave2.sock",
1064
 
   port           => $opt_slave_myport + 2,
1065
 
   secondary_port => $opt_slave_myport + 2 + $secondary_port_offset,
1066
 
   start_timeout  => 300,
1067
 
   cluster        =>  -1, # index in clusters list
1068
 
   start_opts     => [],
 
977
   pid           => 0,
 
978
   type          => "slave",
 
979
   idx           => 2,
 
980
   path_myddir   => "$opt_vardir/slave2-data",
 
981
   path_myerr    => "$opt_vardir/log/slave2.err",
 
982
   path_pid    => "$opt_vardir/run/slave2.pid",
 
983
   path_sock   => "$sockdir/slave2.sock",
 
984
   port   => $opt_slave_myport + 2,
 
985
   start_timeout => 300,
 
986
   cluster       =>  -1, # index in clusters list
 
987
   start_opts    => [],
1069
988
  };
1070
989
 
1071
990
 
1079
998
    warn("Currenty broken --extern");
1080
999
 
1081
1000
    # Setup master->[0] with the settings for the extern server
1082
 
    $master->[0]->{'path_sock'}=  $opt_socket ? $opt_socket : "/tmp/drizzle.sock";
1083
 
    dtr_report("Using extern server at '$master->[0]->{path_sock}'");
 
1001
    $master->[0]->{'path_sock'}=  $opt_socket ? $opt_socket : "/tmp/mysql.sock";
 
1002
    mtr_report("Using extern server at '$master->[0]->{path_sock}'");
1084
1003
  }
1085
1004
  else
1086
1005
  {
1087
 
    dtr_error("--socket can only be used in combination with --extern")
 
1006
    mtr_error("--socket can only be used in combination with --extern")
1088
1007
      if $opt_socket;
1089
1008
  }
1090
1009
 
1100
1019
    # When both --valgrind and --debug is selected, send
1101
1020
    # all output to the trace file, making it possible to
1102
1021
    # see the exact location where valgrind complains
1103
 
    foreach my $drizzled (@{$master}, @{$slave})
 
1022
    foreach my $mysqld (@{$master}, @{$slave})
1104
1023
    {
1105
 
      my $sidx= $drizzled->{idx} ? "$drizzled->{idx}" : "";
1106
 
      $drizzled->{path_myerr}=
1107
 
        "$opt_vardir/log/" . $drizzled->{type} . "$sidx.trace";
1108
 
    }
1109
 
  }
1110
 
}
1111
 
 
1112
 
sub gimme_a_good_port($)
1113
 
{
1114
 
  my $port_to_test= shift;
1115
 
  if ($port_to_test == 8000)
1116
 
  {
1117
 
    $port_to_test = 8001;
1118
 
  }
1119
 
  my $is_port_bad= 1;
1120
 
  while ($is_port_bad) {
1121
 
    my $sock = new IO::Socket::INET( PeerAddr => 'localhost',
1122
 
                                     PeerPort => $port_to_test,
1123
 
                                     Proto => 'tcp' );
1124
 
    if ($sock) {
1125
 
      close($sock);
1126
 
      $port_to_test += 1;
1127
 
      if ($port_to_test >= 32767) {
1128
 
        $port_to_test = 5001;
1129
 
      }
1130
 
 
1131
 
    } else {
1132
 
      $is_port_bad= 0;
1133
 
    }
1134
 
  }
1135
 
  return $port_to_test;
1136
 
 
1137
 
}
 
1024
      my $sidx= $mysqld->{idx} ? "$mysqld->{idx}" : "";
 
1025
      $mysqld->{path_myerr}=
 
1026
        "$opt_vardir/log/" . $mysqld->{type} . "$sidx.trace";
 
1027
    }
 
1028
  }
 
1029
}
 
1030
 
1138
1031
#
1139
1032
# To make it easier for different devs to work on the same host,
1140
1033
# an environment variable can be used to control all ports. A small
1142
1035
#
1143
1036
# Note the MASTER_MYPORT has to be set the same in all 4.x and 5.x
1144
1037
# versions of this script, else a 4.0 test run might conflict with a
1145
 
# 5.1 test run, even if different DTR_BUILD_THREAD is used. This means
 
1038
# 5.1 test run, even if different MTR_BUILD_THREAD is used. This means
1146
1039
# all port numbers might not be used in this version of the script.
1147
1040
#
1148
1041
# Also note the limitation of ports we are allowed to hand out. This
1151
1044
# But a fairly safe range seems to be 5001 - 32767
1152
1045
#
1153
1046
 
1154
 
sub set_dtr_build_thread_ports($) {
1155
 
  my $dtr_build_thread= shift;
 
1047
sub set_mtr_build_thread_ports($) {
 
1048
  my $mtr_build_thread= shift;
1156
1049
 
1157
 
  if ( lc($dtr_build_thread) eq 'auto' ) {
 
1050
  if ( lc($mtr_build_thread) eq 'auto' ) {
1158
1051
    print "Requesting build thread... ";
1159
 
    $ENV{'DTR_BUILD_THREAD'} = $dtr_build_thread = dtr_require_unique_id_and_wait("/tmp/drizzle-test-ports", 200, 299);
1160
 
    print "got ".$dtr_build_thread."\n";
 
1052
    $ENV{'MTR_BUILD_THREAD'} = $mtr_build_thread = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299);
 
1053
    print "got ".$mtr_build_thread."\n";
1161
1054
  }
1162
1055
 
1163
 
  $dtr_build_thread= (($dtr_build_thread * 10) % 2000) - 1000;
 
1056
  $mtr_build_thread= (($mtr_build_thread * 10) % 2000) - 1000;
1164
1057
 
1165
1058
  # Up to two masters, up to three slaves
1166
1059
  # A magic value in command_line_setup depends on these equations.
1167
 
  $opt_master_myport=         gimme_a_good_port($dtr_build_thread + 9000); # and 1
1168
 
 
1169
 
 
1170
 
  $opt_slave_myport=          gimme_a_good_port($opt_master_myport + 2);  # and 3 4
1171
 
  $opt_memc_myport= gimme_a_good_port($opt_master_myport + 10);
1172
 
  $opt_pbms_myport= gimme_a_good_port($opt_master_myport + 11);
1173
 
  $opt_rabbitmq_myport= gimme_a_good_port($opt_master_myport + 12);
 
1060
  $opt_master_myport=         $mtr_build_thread + 9000; # and 1
 
1061
  $opt_slave_myport=          $opt_master_myport + 2;  # and 3 4
 
1062
  $opt_memc_myport= $opt_master_myport + 10;
1174
1063
 
1175
1064
  if ( $opt_master_myport < 5001 or $opt_master_myport + 10 >= 32767 )
1176
1065
  {
1177
 
    dtr_error("DTR_BUILD_THREAD number results in a port",
 
1066
    mtr_error("MTR_BUILD_THREAD number results in a port",
1178
1067
              "outside 5001 - 32767",
1179
1068
              "($opt_master_myport - $opt_master_myport + 10)");
1180
1069
  }
1203
1092
##############################################################################
1204
1093
 
1205
1094
 
1206
 
sub collect_drizzled_features () {
 
1095
sub collect_mysqld_features () {
1207
1096
  my $found_variable_list_start= 0;
1208
1097
  my $tmpdir= tempdir(CLEANUP => 0); # Directory removed by this function
1209
1098
 
1210
1099
  #
1211
 
  # Execute "drizzled --help" to get a list
 
1100
  # Execute "mysqld --help --verbose" to get a list
1212
1101
  # list of all features and settings
1213
1102
  #
1214
 
  # --no-defaults are to avoid loading
 
1103
  # --no-defaults and --skip-grant-tables are to avoid loading
1215
1104
  # system-wide configs and plugins
1216
1105
  #
1217
 
  my $list= `$exe_drizzled --no-defaults --help`;
 
1106
  # --datadir must exist, mysqld will chdir into it
 
1107
  #
 
1108
  my $list= `$exe_drizzled --no-defaults --datadir=$tmpdir --skip-grant-tables --verbose --help`;
1218
1109
 
1219
1110
  foreach my $line (split('\n', $list))
1220
1111
  {
1221
1112
    # First look for version
1222
 
    if ( !$drizzle_version_id )
 
1113
    if ( !$mysql_version_id )
1223
1114
    {
1224
1115
      # Look for version
1225
1116
      my $exe_name= basename($exe_drizzled);
1226
 
      dtr_verbose("exe_name: $exe_name");
 
1117
      mtr_verbose("exe_name: $exe_name");
1227
1118
      if ( $line =~ /^\S*$exe_name\s\sVer\s([0-9]*)\.([0-9]*)\.([0-9]*)/ )
1228
1119
      {
1229
1120
        #print "Major: $1 Minor: $2 Build: $3\n";
1230
 
        $drizzle_version_id= $1*10000 + $2*100 + $3;
1231
 
        #print "drizzle_version_id: $drizzle_version_id\n";
1232
 
        dtr_report("Drizzle Version $1.$2.$3");
 
1121
        $mysql_version_id= $1*10000 + $2*100 + $3;
 
1122
        #print "mysql_version_id: $mysql_version_id\n";
 
1123
        mtr_report("MySQL Version $1.$2.$3");
 
1124
      }
 
1125
    }
 
1126
    else
 
1127
    {
 
1128
      if (!$found_variable_list_start)
 
1129
      {
 
1130
        # Look for start of variables list
 
1131
        if ( $line =~ /[\-]+\s[\-]+/ )
 
1132
        {
 
1133
          $found_variable_list_start= 1;
 
1134
        }
 
1135
      }
 
1136
      else
 
1137
      {
 
1138
        # Put variables into hash
 
1139
        if ( $line =~ /^([\S]+)[ \t]+(.*?)\r?$/ )
 
1140
        {
 
1141
          # print "$1=\"$2\"\n";
 
1142
          $mysqld_variables{$1}= $2;
 
1143
        }
 
1144
        else
 
1145
        {
 
1146
          # The variable list is ended with a blank line
 
1147
          if ( $line =~ /^[\s]*$/ )
 
1148
          {
 
1149
            last;
 
1150
          }
 
1151
          else
 
1152
          {
 
1153
            # Send out a warning, we should fix the variables that has no
 
1154
            # space between variable name and it's value
 
1155
            # or should it be fixed width column parsing? It does not
 
1156
            # look like that in function my_print_variables in my_getopt.c
 
1157
            mtr_warning("Could not parse variable list line : $line");
 
1158
          }
 
1159
        }
1233
1160
      }
1234
1161
    }
1235
1162
  }
1236
1163
  rmtree($tmpdir);
1237
 
  dtr_error("Could not find version of Drizzle") unless $drizzle_version_id;
 
1164
  mtr_error("Could not find version of MySQL") unless $mysql_version_id;
 
1165
  mtr_error("Could not find variabes list") unless $found_variable_list_start;
1238
1166
 
1239
1167
}
1240
1168
 
1241
1169
 
1242
1170
sub run_query($$) {
1243
 
  my ($drizzled, $query)= @_;
 
1171
  my ($mysqld, $query)= @_;
1244
1172
 
1245
1173
  my $args;
1246
 
  dtr_init_args(\$args);
 
1174
  mtr_init_args(\$args);
1247
1175
 
1248
 
  dtr_add_arg($args, "--no-defaults");
1249
 
  dtr_add_arg($args, "--skip-stack-trace");
1250
 
  dtr_add_arg($args, "--user=%s", $opt_user);
1251
 
  dtr_add_arg($args, "--port=%d", $drizzled->{'port'});
1252
 
  dtr_add_arg($args, "--silent"); # Tab separated output
1253
 
  dtr_add_arg($args, "-e '%s'", $query);
 
1176
  mtr_add_arg($args, "--no-defaults");
 
1177
  mtr_add_arg($args, "--skip-stack-trace");
 
1178
  mtr_add_arg($args, "--user=%s", $opt_user);
 
1179
  mtr_add_arg($args, "--port=%d", $mysqld->{'port'});
 
1180
  mtr_add_arg($args, "--silent"); # Tab separated output
 
1181
  mtr_add_arg($args, "-e '%s'", $query);
1254
1182
 
1255
1183
  my $cmd= "$exe_drizzle " . join(' ', @$args);
1256
 
  dtr_verbose("cmd: $cmd");
 
1184
  mtr_verbose("cmd: $cmd");
1257
1185
  return `$cmd`;
1258
1186
}
1259
1187
 
1260
1188
 
1261
 
sub collect_drizzled_features_from_running_server ()
 
1189
sub collect_mysqld_features_from_running_server ()
1262
1190
{
1263
 
  my $list= run_query($master->[0], "use drizzle; SHOW VARIABLES");
 
1191
  my $list= run_query($master->[0], "use mysql; SHOW VARIABLES");
1264
1192
 
1265
1193
  foreach my $line (split('\n', $list))
1266
1194
  {
1268
1196
    if ( $line =~ /^([\S]+)[ \t]+(.*?)\r?$/ )
1269
1197
    {
1270
1198
      print "$1=\"$2\"\n";
1271
 
      $drizzled_variables{$1}= $2;
 
1199
      $mysqld_variables{$1}= $2;
1272
1200
    }
1273
1201
  }
1274
1202
}
1286
1214
    $exe_libtool= "../libtool";
1287
1215
    if ($opt_valgrind or $glob_debugger)
1288
1216
    {
1289
 
      dtr_report("Using \"$exe_libtool\" when running valgrind or debugger");
 
1217
      mtr_report("Using \"$exe_libtool\" when running valgrind or debugger");
1290
1218
    }
1291
1219
  }
1292
1220
 
 
1221
# Look for my_print_defaults
 
1222
  $exe_my_print_defaults=
 
1223
    mtr_exe_exists(
 
1224
        "$path_client_bindir/my_print_defaults",
 
1225
        "$glob_basedir/extra/my_print_defaults",
 
1226
        "$glob_builddir/extra/my_print_defaults");
 
1227
 
1293
1228
# Look for perror
1294
1229
  $exe_perror= "perror";
1295
1230
 
1296
1231
# Look for the client binaries
1297
 
  $exe_drizzledump= dtr_exe_exists("$path_client_bindir/drizzledump");
1298
 
  $exe_drizzleimport= dtr_exe_exists("$path_client_bindir/drizzleimport");
1299
 
  $exe_drizzle=          dtr_exe_exists("$path_client_bindir/drizzle");
1300
 
  $exe_drizzleadmin= dtr_exe_exists("$path_client_bindir/drizzleadmin");
 
1232
  $exe_drizzledump= mtr_exe_exists("$path_client_bindir/drizzledump");
 
1233
  $exe_drizzleimport= mtr_exe_exists("$path_client_bindir/drizzleimport");
 
1234
  $exe_drizzle=          mtr_exe_exists("$path_client_bindir/drizzle");
1301
1235
 
1302
1236
  if (!$opt_extern)
1303
1237
  {
1304
1238
# Look for SQL scripts directory
1305
 
     if ( $drizzle_version_id >= 50100 )
 
1239
     if ( $mysql_version_id >= 50100 )
1306
1240
     {
1307
 
         $exe_drizzleslap= dtr_exe_exists("$path_client_bindir/drizzleslap");
 
1241
         $exe_drizzleslap= mtr_exe_exists("$path_client_bindir/drizzleslap");
1308
1242
     }
1309
1243
  }
1310
1244
 
1311
 
# Look for schema_writer
1312
 
  {
1313
 
    $exe_schemawriter= dtr_exe_exists("$glob_basedir/drizzled/message/schema_writer",
1314
 
                                      "$glob_builddir/drizzled/message/schema_writer");
1315
 
  }
1316
 
 
1317
1245
# Look for drizzletest executable
1318
1246
  {
1319
 
    $exe_drizzletest= dtr_exe_exists("$path_client_bindir/drizzletest");
 
1247
    $exe_drizzletest= mtr_exe_exists("$path_client_bindir/drizzletest");
1320
1248
  }
1321
1249
 
1322
1250
# Look for drizzle_client_test executable which may _not_ exist in
1323
1251
# some versions, test using it should be skipped
1324
1252
  {
1325
1253
    $exe_drizzle_client_test=
1326
 
      dtr_exe_maybe_exists(
 
1254
      mtr_exe_maybe_exists(
1327
1255
          "$glob_basedir/tests/drizzle_client_test",
1328
1256
          "$glob_basedir/bin/drizzle_client_test");
1329
1257
  }
1331
1259
# Look for bug25714 executable which may _not_ exist in
1332
1260
# some versions, test using it should be skipped
1333
1261
  $exe_bug25714=
1334
 
    dtr_exe_maybe_exists(
 
1262
    mtr_exe_maybe_exists(
1335
1263
        "$glob_basedir/tests/bug25714");
1336
1264
}
1337
1265
 
1338
1266
 
1339
1267
 
1340
 
sub generate_cmdline_drizzledump ($) {
1341
 
  my($drizzled) = @_;
 
1268
sub generate_cmdline_mysqldump ($) {
 
1269
  my($mysqld) = @_;
1342
1270
  return
1343
 
    dtr_native_path($exe_drizzledump) .
 
1271
    mtr_native_path($exe_drizzledump) .
1344
1272
      " --no-defaults -uroot " .
1345
 
      "--port=$drizzled->{'port'} ";
1346
 
}
1347
 
 
1348
 
sub generate_cmdline_drizzle ($) {
1349
 
  my($drizzled) = @_;
1350
 
  return
1351
 
    dtr_native_path($exe_drizzle) .
1352
 
    " -uroot --port=$drizzled->{'port'} ";
1353
 
}
1354
 
 
1355
 
sub generate_cmdline_drizzleadmin ($) {
1356
 
  my($drizzled) = @_;
1357
 
  return
1358
 
    dtr_native_path($exe_drizzleadmin) .
1359
 
    " -uroot --port=$drizzled->{'port'} ";
1360
 
}
 
1273
      "--port=$mysqld->{'port'} ";
 
1274
}
 
1275
 
1361
1276
 
1362
1277
##############################################################################
1363
1278
#
1371
1286
  my $exe= $exe_drizzle_client_test;
1372
1287
 
1373
1288
  my $args;
1374
 
  dtr_init_args(\$args);
 
1289
  mtr_init_args(\$args);
1375
1290
  if ( $opt_valgrind_drizzletest )
1376
1291
  {
1377
1292
    valgrind_arguments($args, \$exe);
1378
1293
  }
1379
1294
 
1380
 
  dtr_add_arg($args, "--no-defaults");
1381
 
  dtr_add_arg($args, "--testcase");
1382
 
  dtr_add_arg($args, "--user=root");
1383
 
  dtr_add_arg($args, "--port=$master->[0]->{'port'}");
 
1295
  mtr_add_arg($args, "--no-defaults");
 
1296
  mtr_add_arg($args, "--testcase");
 
1297
  mtr_add_arg($args, "--user=root");
 
1298
  mtr_add_arg($args, "--port=$master->[0]->{'port'}");
1384
1299
 
1385
 
  if ( $opt_extern || $drizzle_version_id >= 50000 )
 
1300
  if ( $opt_extern || $mysql_version_id >= 50000 )
1386
1301
  {
1387
 
    dtr_add_arg($args, "--vardir=$opt_vardir")
 
1302
    mtr_add_arg($args, "--vardir=$opt_vardir")
1388
1303
  }
1389
1304
 
1390
1305
  if ( $opt_debug )
1391
1306
  {
1392
 
    dtr_add_arg($args,
 
1307
    mtr_add_arg($args,
1393
1308
      "--debug=d:t:A,$path_vardir_trace/log/drizzle_client_test.trace");
1394
1309
  }
1395
1310
 
1397
1312
}
1398
1313
 
1399
1314
 
1400
 
# Note that some env is setup in spawn/run, in "dtr_process.pl"
 
1315
# Note that some env is setup in spawn/run, in "mtr_process.pl"
1401
1316
 
1402
1317
sub environment_setup () {
1403
1318
 
1436
1351
  my $deb_version;
1437
1352
  if (  $opt_valgrind and -d $debug_libraries_path and
1438
1353
        (! -e '/etc/debian_version' or
1439
 
         ($deb_version= dtr_grab_file('/etc/debian_version')) !~ /^[0-9]+\.[0-9]$/ or
 
1354
         ($deb_version= mtr_grab_file('/etc/debian_version')) !~ /^[0-9]+\.[0-9]$/ or
1440
1355
         $deb_version > 3.1 ) )
1441
1356
  {
1442
1357
    push(@ld_library_paths, $debug_libraries_path);
1446
1361
                                $ENV{'LD_LIBRARY_PATH'} ?
1447
1362
                                split(':', $ENV{'LD_LIBRARY_PATH'}) : (),
1448
1363
                                @ld_library_paths);
1449
 
  dtr_debug("LD_LIBRARY_PATH: $ENV{'LD_LIBRARY_PATH'}");
 
1364
  mtr_debug("LD_LIBRARY_PATH: $ENV{'LD_LIBRARY_PATH'}");
1450
1365
 
1451
1366
  $ENV{'DYLD_LIBRARY_PATH'}= join(":", @ld_library_paths,
1452
1367
                                  $ENV{'DYLD_LIBRARY_PATH'} ?
1453
1368
                                  split(':', $ENV{'DYLD_LIBRARY_PATH'}) : ());
1454
 
  dtr_debug("DYLD_LIBRARY_PATH: $ENV{'DYLD_LIBRARY_PATH'}");
 
1369
  mtr_debug("DYLD_LIBRARY_PATH: $ENV{'DYLD_LIBRARY_PATH'}");
1455
1370
 
1456
1371
  # The environment variable used for shared libs on AIX
1457
1372
  $ENV{'SHLIB_PATH'}= join(":", @ld_library_paths,
1458
1373
                           $ENV{'SHLIB_PATH'} ?
1459
1374
                           split(':', $ENV{'SHLIB_PATH'}) : ());
1460
 
  dtr_debug("SHLIB_PATH: $ENV{'SHLIB_PATH'}");
 
1375
  mtr_debug("SHLIB_PATH: $ENV{'SHLIB_PATH'}");
1461
1376
 
1462
1377
  # The environment variable used for shared libs on hp-ux
1463
1378
  $ENV{'LIBPATH'}= join(":", @ld_library_paths,
1464
1379
                        $ENV{'LIBPATH'} ?
1465
1380
                        split(':', $ENV{'LIBPATH'}) : ());
1466
 
  dtr_debug("LIBPATH: $ENV{'LIBPATH'}");
 
1381
  mtr_debug("LIBPATH: $ENV{'LIBPATH'}");
1467
1382
 
1468
1383
  # --------------------------------------------------------------------------
1469
1384
  # Also command lines in .opt files may contain env vars
1474
1389
  $ENV{'UMASK_DIR'}=          "0770"; # The octal *string*
1475
1390
  
1476
1391
  #
1477
 
  # drizzle tests can produce output in various character sets
 
1392
  # MySQL tests can produce output in various character sets
1478
1393
  # (especially, ctype_xxx.test). To avoid confusing Perl
1479
1394
  # with output which is incompatible with the current locale
1480
1395
  # settings, we reset the current values of LC_ALL and LC_CTYPE to "C".
1486
1401
  
1487
1402
  $ENV{'LC_COLLATE'}=         "C";
1488
1403
  $ENV{'USE_RUNNING_SERVER'}= $opt_extern;
1489
 
  $ENV{'DRIZZLE_TEST_DIR'}=     collapse_path($glob_drizzle_test_dir);
1490
 
  $ENV{'DRIZZLETEST_VARDIR'}=   $opt_vardir;
1491
 
  $ENV{'TOP_SRCDIR'}= $opt_top_srcdir;
1492
 
  $ENV{'TOP_BUILDDIR'}= $opt_top_builddir;
 
1404
  $ENV{'DRIZZLE_TEST_DIR'}=     collapse_path($glob_mysql_test_dir);
 
1405
  $ENV{'MYSQLTEST_VARDIR'}=   $opt_vardir;
1493
1406
  $ENV{'DRIZZLE_TMP_DIR'}=      $opt_tmpdir;
1494
1407
  $ENV{'MASTER_MYSOCK'}=      $master->[0]->{'path_sock'};
1495
1408
  $ENV{'MASTER_MYSOCK1'}=     $master->[1]->{'path_sock'};
1500
1413
  $ENV{'SLAVE_MYPORT1'}=      $slave->[1]->{'port'};
1501
1414
  $ENV{'SLAVE_MYPORT2'}=      $slave->[2]->{'port'};
1502
1415
  $ENV{'MC_PORT'}=            $opt_memc_myport;
1503
 
  $ENV{'PBMS_PORT'}=          $opt_pbms_myport;
1504
 
  $ENV{'RABBITMQ_NODE_PORT'}= $opt_rabbitmq_myport;
1505
 
  $ENV{'DRIZZLE_TCP_PORT'}=   $drizzled_variables{'drizzle-protocol.port'};
1506
 
 
1507
 
  $ENV{'DTR_BUILD_THREAD'}=      $opt_dtr_build_thread;
1508
 
 
1509
 
  $ENV{'EXE_DRIZZLE'}=          $exe_drizzle;
 
1416
  $ENV{'DRIZZLE_TCP_PORT'}=     $mysqld_variables{'port'};
 
1417
 
 
1418
  $ENV{'MTR_BUILD_THREAD'}=      $opt_mtr_build_thread;
 
1419
 
 
1420
  $ENV{'EXE_MYSQL'}=          $exe_drizzle;
1510
1421
 
1511
1422
 
1512
1423
  # ----------------------------------------------------
1513
1424
  # Setup env to childs can execute myqldump
1514
1425
  # ----------------------------------------------------
1515
 
  my $cmdline_drizzleadmin= generate_cmdline_drizzleadmin($master->[0]);
1516
 
  my $cmdline_drizzledump= generate_cmdline_drizzledump($master->[0]);
1517
 
  my $cmdline_drizzledumpslave= generate_cmdline_drizzledump($slave->[0]);
1518
 
  my $cmdline_drizzledump_secondary= dtr_native_path($exe_drizzledump) .
1519
 
       " --no-defaults -uroot " .
1520
 
       " --port=$master->[0]->{'secondary_port'} ";
 
1426
  my $cmdline_mysqldump= generate_cmdline_mysqldump($master->[0]);
 
1427
  my $cmdline_mysqldumpslave= generate_cmdline_mysqldump($slave->[0]);
1521
1428
 
1522
1429
  if ( $opt_debug )
1523
1430
  {
1524
 
    $cmdline_drizzledump .=
1525
 
      " --debug=d:t:A,$path_vardir_trace/log/drizzledump-master.trace";
1526
 
    $cmdline_drizzledumpslave .=
1527
 
      " --debug=d:t:A,$path_vardir_trace/log/drizzledump-slave.trace";
1528
 
    $cmdline_drizzledump_secondary .=
1529
 
      " --debug=d:t:A,$path_vardir_trace/log/drizzledump-drizzle.trace";
 
1431
    $cmdline_mysqldump .=
 
1432
      " --debug=d:t:A,$path_vardir_trace/log/mysqldump-master.trace";
 
1433
    $cmdline_mysqldumpslave .=
 
1434
      " --debug=d:t:A,$path_vardir_trace/log/mysqldump-slave.trace";
1530
1435
  }
1531
 
  $ENV{'DRIZZLE_ADMIN'}= $cmdline_drizzleadmin;
1532
 
  $ENV{'DRIZZLE_DUMP'}= $cmdline_drizzledump;
1533
 
  $ENV{'DRIZZLE_DUMP_SLAVE'}= $cmdline_drizzledumpslave;
1534
 
  $ENV{'DRIZZLE_DUMP_SECONDARY'}= $cmdline_drizzledump_secondary;
1535
 
 
1536
 
  # ----------------------------------------------------
1537
 
  # Setup env so we can execute drizzle client
1538
 
  # ----------------------------------------------------
1539
 
  #my $cmdline_drizzle = generate_cmdline_drizzle($master->[0]);
1540
 
  #$ENV{'DRIZZLE'}= $cmdline_drizzle;
1541
 
 
1542
 
  # ----------------------------------------------------
1543
 
  # Setup env so childs can execute drizzleslap
 
1436
  $ENV{'DRIZZLE_DUMP'}= $cmdline_mysqldump;
 
1437
  $ENV{'DRIZZLE_DUMP_SLAVE'}= $cmdline_mysqldumpslave;
 
1438
 
 
1439
  # ----------------------------------------------------
 
1440
  # Setup env so childs can execute mysqlslap
1544
1441
  # ----------------------------------------------------
1545
1442
  if ( $exe_drizzleslap )
1546
1443
  {
1547
 
    my $cmdline_drizzleslap;
1548
 
 
1549
 
    if ( $opt_valgrind_drizzleslap )
1550
 
    {
1551
 
      $cmdline_drizzleslap= "$glob_basedir/libtool --mode=execute valgrind --log-file=$opt_vardir/log/drizzleslap-valgrind.log ";
1552
 
    }
1553
 
    $cmdline_drizzleslap .=
1554
 
      dtr_native_path($exe_drizzleslap) .
 
1444
    my $cmdline_drizzleslap=
 
1445
      mtr_native_path($exe_drizzleslap) .
1555
1446
      " -uroot " .
1556
1447
      "--port=$master->[0]->{'port'} ";
1557
 
    my $cmdline_drizzleslap_secondary=
1558
 
      dtr_native_path($exe_drizzleslap) .
1559
 
      " -uroot " .
1560
 
      " --port=$master->[0]->{'secondary_port'} ";
1561
1448
 
1562
1449
    if ( $opt_debug )
1563
1450
   {
1564
1451
      $cmdline_drizzleslap .=
1565
1452
        " --debug=d:t:A,$path_vardir_trace/log/drizzleslap.trace";
1566
 
      $cmdline_drizzleslap_secondary .=
1567
 
        " --debug=d:t:A,$path_vardir_trace/log/drizzleslap.trace";
1568
1453
    }
1569
1454
    $ENV{'DRIZZLE_SLAP'}= $cmdline_drizzleslap;
1570
 
    $ENV{'DRIZZLE_SLAP_SECONDARY'}= $cmdline_drizzleslap_secondary;
1571
1455
  }
1572
1456
 
1573
1457
 
1574
1458
 
1575
1459
  # ----------------------------------------------------
1576
 
  # Setup env so childs can execute drizzleimport
 
1460
  # Setup env so childs can execute mysqlimport
1577
1461
  # ----------------------------------------------------
1578
 
  my $cmdline_drizzleimport=
1579
 
    dtr_native_path($exe_drizzleimport) .
 
1462
  my $cmdline_mysqlimport=
 
1463
    mtr_native_path($exe_drizzleimport) .
1580
1464
    " -uroot " .
1581
1465
    "--port=$master->[0]->{'port'} ";
1582
1466
 
1583
1467
  if ( $opt_debug )
1584
1468
  {
1585
 
    $cmdline_drizzleimport .=
1586
 
      " --debug=d:t:A,$path_vardir_trace/log/drizzleimport.trace";
 
1469
    $cmdline_mysqlimport .=
 
1470
      " --debug=d:t:A,$path_vardir_trace/log/mysqlimport.trace";
1587
1471
  }
1588
 
  $ENV{'DRIZZLE_IMPORT'}= $cmdline_drizzleimport;
1589
 
 
1590
 
 
1591
 
  # ----------------------------------------------------
1592
 
  # Setup env so childs can execute drizzle
1593
 
  # ----------------------------------------------------
1594
 
  my $cmdline_drizzle=
1595
 
    dtr_native_path($exe_drizzle) .
 
1472
  $ENV{'DRIZZLE_IMPORT'}= $cmdline_mysqlimport;
 
1473
 
 
1474
 
 
1475
  # ----------------------------------------------------
 
1476
  # Setup env so childs can execute mysql
 
1477
  # ----------------------------------------------------
 
1478
  my $cmdline_mysql=
 
1479
    mtr_native_path($exe_drizzle) .
1596
1480
    " --no-defaults --host=localhost  --user=root --password= " .
1597
1481
    "--port=$master->[0]->{'port'} ";
1598
 
  my $cmdline_drizzle_secondary=
1599
 
    dtr_native_path($exe_drizzle) .
1600
 
    " --no-defaults --host=localhost  --user=root --password= " .
1601
 
    " --port=$master->[0]->{'secondary_port'} ";
1602
1482
 
1603
 
  $ENV{'DRIZZLE'}= $cmdline_drizzle;
1604
 
  $ENV{'DRIZZLE_SECONDARY'}= $cmdline_drizzle_secondary;
 
1483
  $ENV{'MYSQL'}= $cmdline_mysql;
1605
1484
 
1606
1485
  # ----------------------------------------------------
1607
1486
  # Setup env so childs can execute bug25714
1615
1494
 
1616
1495
 
1617
1496
  # ----------------------------------------------------
1618
 
  # Setup env so childs can execute drizzle_fix_system_tables
 
1497
  # Setup env so childs can execute mysql_fix_system_tables
1619
1498
  # ----------------------------------------------------
1620
1499
  #if ( !$opt_extern)
1621
1500
  if ( 0 )
1622
1501
  {
1623
 
    my $cmdline_drizzle_fix_system_tables=
 
1502
    my $cmdline_mysql_fix_system_tables=
1624
1503
      "$exe_drizzle_fix_system_tables --no-defaults --host=localhost " .
1625
1504
      "--user=root --password= " .
1626
1505
      "--basedir=$glob_basedir --bindir=$path_client_bindir --verbose " .
1627
1506
      "--port=$master->[0]->{'port'} ";
1628
 
    $ENV{'DRIZZLE_FIX_SYSTEM_TABLES'}=  $cmdline_drizzle_fix_system_tables;
 
1507
    $ENV{'DRIZZLE_FIX_SYSTEM_TABLES'}=  $cmdline_mysql_fix_system_tables;
1629
1508
 
1630
1509
  }
1631
1510
 
1632
1511
  # ----------------------------------------------------
 
1512
  # Setup env so childs can execute my_print_defaults
 
1513
  # ----------------------------------------------------
 
1514
  $ENV{'DRIZZLE_MY_PRINT_DEFAULTS'}= mtr_native_path($exe_my_print_defaults);
 
1515
 
 
1516
  # ----------------------------------------------------
1633
1517
  # Setup env so childs can shutdown the server
1634
1518
  # ----------------------------------------------------
1635
 
  $ENV{'DRIZZLED_SHUTDOWN'}= dtr_native_path($exe_drizzle);
 
1519
  $ENV{'DRIZZLED_SHUTDOWN'}= mtr_native_path($exe_drizzle);
1636
1520
 
1637
1521
  # ----------------------------------------------------
1638
1522
  # Setup env so childs can execute perror  
1639
1523
  # ----------------------------------------------------
1640
 
  $ENV{'MY_PERROR'}= dtr_native_path($exe_perror);
 
1524
  $ENV{'MY_PERROR'}= mtr_native_path($exe_perror);
1641
1525
 
1642
1526
  # ----------------------------------------------------
1643
 
  # Add the path where drizzled will find ha_example.so
 
1527
  # Add the path where mysqld will find ha_example.so
1644
1528
  # ----------------------------------------------------
1645
1529
  $ENV{'EXAMPLE_PLUGIN'}=
1646
1530
    ($lib_example_plugin ? basename($lib_example_plugin) : "");
1648
1532
    ($lib_example_plugin ? "--plugin_dir=" . dirname($lib_example_plugin) : "");
1649
1533
 
1650
1534
  # ----------------------------------------------------
 
1535
  # Setup env so childs can execute myisampack and myisamchk
 
1536
  # ----------------------------------------------------
 
1537
#  $ENV{'MYISAMCHK'}= mtr_native_path(mtr_exe_exists(
 
1538
#                       "$path_client_bindir/myisamchk",
 
1539
#                       "$glob_basedir/storage/myisam/myisamchk",
 
1540
#                       "$glob_basedir/myisam/myisamchk"));
 
1541
#  $ENV{'MYISAMPACK'}= mtr_native_path(mtr_exe_exists(
 
1542
#                        "$path_client_bindir/myisampack",
 
1543
#                        "$glob_basedir/storage/myisam/myisampack",
 
1544
#                        "$glob_basedir/myisam/myisampack"));
 
1545
 
 
1546
  # ----------------------------------------------------
1651
1547
  # We are nice and report a bit about our settings
1652
1548
  # ----------------------------------------------------
1653
1549
  if (!$opt_extern)
1654
1550
  {
1655
 
    print "Using DTR_BUILD_THREAD      = $ENV{DTR_BUILD_THREAD}\n";
 
1551
    print "Using MTR_BUILD_THREAD      = $ENV{MTR_BUILD_THREAD}\n";
1656
1552
    print "Using MASTER_MYPORT         = $ENV{MASTER_MYPORT}\n";
1657
1553
    print "Using MASTER_MYPORT1        = $ENV{MASTER_MYPORT1}\n";
1658
1554
    print "Using SLAVE_MYPORT          = $ENV{SLAVE_MYPORT}\n";
1659
1555
    print "Using SLAVE_MYPORT1         = $ENV{SLAVE_MYPORT1}\n";
1660
1556
    print "Using SLAVE_MYPORT2         = $ENV{SLAVE_MYPORT2}\n";
1661
1557
    print "Using MC_PORT               = $ENV{MC_PORT}\n";
1662
 
    print "Using PBMS_PORT             = $ENV{PBMS_PORT}\n";
1663
 
    print "Using RABBITMQ_NODE_PORT    = $ENV{RABBITMQ_NODE_PORT}\n";
1664
1558
  }
1665
1559
 
1666
1560
  # Create an environment variable to make it possible
1684
1578
 
1685
1579
sub handle_int_signal () {
1686
1580
  $SIG{INT}= 'DEFAULT';         # If we get a ^C again, we die...
1687
 
  dtr_warning("got INT signal, cleaning up.....");
 
1581
  mtr_warning("got INT signal, cleaning up.....");
1688
1582
  stop_all_servers();
1689
 
  dtr_error("We die from ^C signal from user");
 
1583
  mtr_error("We die from ^C signal from user");
1690
1584
}
1691
1585
 
1692
1586
 
1698
1592
 
1699
1593
sub kill_running_servers () {
1700
1594
  {
1701
 
    # Ensure that no old drizzled test servers are running
 
1595
    # Ensure that no old mysqld test servers are running
1702
1596
    # This is different from terminating processes we have
1703
1597
    # started from this run of the script, this is terminating
1704
1598
    # leftovers from previous runs.
1705
 
    dtr_kill_leftovers();
 
1599
    mtr_kill_leftovers();
1706
1600
   }
1707
1601
}
1708
1602
 
1712
1606
#
1713
1607
sub remove_stale_vardir () {
1714
1608
 
1715
 
  dtr_report("Removing Stale Files");
 
1609
  mtr_report("Removing Stale Files");
1716
1610
 
1717
1611
  # Safety!
1718
 
  dtr_error("No, don't remove the vardir when running with --extern")
 
1612
  mtr_error("No, don't remove the vardir when running with --extern")
1719
1613
    if $opt_extern;
1720
1614
 
1721
 
  dtr_verbose("opt_vardir: $opt_vardir");
 
1615
  mtr_verbose("opt_vardir: $opt_vardir");
1722
1616
  if ( $opt_vardir eq $default_vardir )
1723
1617
  {
1724
1618
    #
1725
 
    # Running with "var" in drizzle-test dir
 
1619
    # Running with "var" in mysql-test dir
1726
1620
    #
1727
1621
    if ( -l $opt_vardir)
1728
1622
    {
1731
1625
      if ( $opt_mem and readlink($opt_vardir) eq $opt_mem )
1732
1626
      {
1733
1627
        # Remove the directory which the link points at
1734
 
        dtr_verbose("Removing " . readlink($opt_vardir));
1735
 
        dtr_rmtree(readlink($opt_vardir));
 
1628
        mtr_verbose("Removing " . readlink($opt_vardir));
 
1629
        mtr_rmtree(readlink($opt_vardir));
1736
1630
 
1737
1631
        # Remove the "var" symlink
1738
 
        dtr_verbose("unlink($opt_vardir)");
 
1632
        mtr_verbose("unlink($opt_vardir)");
1739
1633
        unlink($opt_vardir);
1740
1634
      }
1741
1635
      elsif ( $opt_mem )
1742
1636
      {
1743
1637
        # Just remove the "var" symlink
1744
 
        dtr_report("WARNING: Removing '$opt_vardir' symlink it's wrong");
 
1638
        mtr_report("WARNING: Removing '$opt_vardir' symlink it's wrong");
1745
1639
 
1746
 
        dtr_verbose("unlink($opt_vardir)");
 
1640
        mtr_verbose("unlink($opt_vardir)");
1747
1641
        unlink($opt_vardir);
1748
1642
      }
1749
1643
      else
1750
1644
      {
1751
 
        # Some users creates a soft link in drizzle-test/var to another area
 
1645
        # Some users creates a soft link in mysql-test/var to another area
1752
1646
        # - allow it, but remove all files in it
1753
1647
 
1754
 
        dtr_report("WARNING: Using the 'drizzle-test/var' symlink");
 
1648
        mtr_report("WARNING: Using the 'mysql-test/var' symlink");
1755
1649
 
1756
1650
        # Make sure the directory where it points exist
1757
 
        dtr_error("The destination for symlink $opt_vardir does not exist")
 
1651
        mtr_error("The destination for symlink $opt_vardir does not exist")
1758
1652
          if ! -d readlink($opt_vardir);
1759
1653
 
1760
1654
        foreach my $bin ( glob("$opt_vardir/*") )
1761
1655
        {
1762
 
          dtr_verbose("Removing bin $bin");
1763
 
          dtr_rmtree($bin);
 
1656
          mtr_verbose("Removing bin $bin");
 
1657
          mtr_rmtree($bin);
1764
1658
        }
1765
1659
      }
1766
1660
    }
1767
1661
    else
1768
1662
    {
1769
1663
      # Remove the entire "var" dir
1770
 
      dtr_verbose("Removing $opt_vardir/");
1771
 
      dtr_rmtree("$opt_vardir/");
 
1664
      mtr_verbose("Removing $opt_vardir/");
 
1665
      mtr_rmtree("$opt_vardir/");
1772
1666
    }
1773
1667
 
1774
1668
    if ( $opt_mem )
1776
1670
      # A symlink from var/ to $opt_mem will be set up
1777
1671
      # remove the $opt_mem dir to assure the symlink
1778
1672
      # won't point at an old directory
1779
 
      dtr_verbose("Removing $opt_mem");
1780
 
      dtr_rmtree($opt_mem);
 
1673
      mtr_verbose("Removing $opt_mem");
 
1674
      mtr_rmtree($opt_mem);
1781
1675
    }
1782
1676
 
1783
1677
  }
1787
1681
    # Running with "var" in some other place
1788
1682
    #
1789
1683
 
1790
 
    # Remove the var/ dir in drizzle-test dir if any
 
1684
    # Remove the var/ dir in mysql-test dir if any
1791
1685
    # this could be an old symlink that shouldn't be there
1792
 
    dtr_verbose("Removing $default_vardir");
1793
 
    dtr_rmtree($default_vardir);
 
1686
    mtr_verbose("Removing $default_vardir");
 
1687
    mtr_rmtree($default_vardir);
1794
1688
 
1795
1689
    # Remove the "var" dir
1796
 
    dtr_verbose("Removing $opt_vardir/");
1797
 
    dtr_rmtree("$opt_vardir/");
 
1690
    mtr_verbose("Removing $opt_vardir/");
 
1691
    mtr_rmtree("$opt_vardir/");
1798
1692
  }
1799
1693
}
1800
1694
 
1802
1696
# Create var and the directories needed in var
1803
1697
#
1804
1698
sub setup_vardir() {
1805
 
  dtr_report("Creating Directories");
 
1699
  mtr_report("Creating Directories");
1806
1700
 
1807
1701
  if ( $opt_vardir eq $default_vardir )
1808
1702
  {
1809
1703
    #
1810
 
    # Running with "var" in drizzle-test dir
 
1704
    # Running with "var" in mysql-test dir
1811
1705
    #
1812
1706
    if ( -l $opt_vardir )
1813
1707
    {
1814
1708
      #  it's a symlink
1815
1709
 
1816
1710
      # Make sure the directory where it points exist
1817
 
      dtr_error("The destination for symlink $opt_vardir does not exist")
 
1711
      mtr_error("The destination for symlink $opt_vardir does not exist")
1818
1712
        if ! -d readlink($opt_vardir);
1819
1713
    }
1820
1714
    elsif ( $opt_mem )
1821
1715
    {
1822
1716
      # Runinng with "var" as a link to some "memory" location, normally tmpfs
1823
 
      dtr_verbose("Creating $opt_mem");
 
1717
      mtr_verbose("Creating $opt_mem");
1824
1718
      mkpath($opt_mem);
1825
1719
 
1826
 
      dtr_report("Symlinking 'var' to '$opt_mem'");
 
1720
      mtr_report("Symlinking 'var' to '$opt_mem'");
1827
1721
      symlink($opt_mem, $opt_vardir);
1828
1722
    }
1829
1723
  }
1830
1724
 
1831
1725
  if ( ! -d $opt_vardir )
1832
1726
  {
1833
 
    dtr_verbose("Creating $opt_vardir");
 
1727
    mtr_verbose("Creating $opt_vardir");
1834
1728
    mkpath($opt_vardir);
1835
1729
  }
1836
1730
 
1837
1731
  # Ensure a proper error message if vardir couldn't be created
1838
1732
  unless ( -d $opt_vardir and -w $opt_vardir )
1839
1733
  {
1840
 
    dtr_error("Writable 'var' directory is needed, use the " .
 
1734
    mtr_error("Writable 'var' directory is needed, use the " .
1841
1735
              "'--vardir=<path>' option");
1842
1736
  }
1843
1737
 
1849
1743
  # Create new data dirs
1850
1744
  foreach my $data_dir (@data_dir_lst)
1851
1745
  {
1852
 
    mkpath("$data_dir/local/mysql");
1853
 
    system("$exe_schemawriter mysql $data_dir/local/mysql/db.opt");
1854
 
 
1855
 
    mkpath("$data_dir/local/test");
1856
 
    system("$exe_schemawriter test $data_dir/local/test/db.opt");
 
1746
    mkpath("$data_dir/mysql");
 
1747
    mkpath("$data_dir/test");
1857
1748
  }
1858
1749
 
1859
1750
  # Make a link std_data_ln in var/ that points to std_data
1860
 
  symlink(collapse_path("$glob_drizzle_test_dir/std_data"),
 
1751
  symlink(collapse_path("$glob_mysql_test_dir/std_data"),
1861
1752
          "$opt_vardir/std_data_ln");
1862
1753
 
1863
 
  symlink(collapse_path("$glob_suite_path/filesystem_engine/tests/t"),
1864
 
          "$opt_vardir/filesystem_ln");
1865
 
 
1866
1754
  # Remove old log files
1867
1755
  foreach my $name (glob("r/*.progress r/*.log r/*.warnings"))
1868
1756
  {
1870
1758
  }
1871
1759
  system("chmod -R ugo+r $opt_vardir");
1872
1760
  system("chmod -R ugo+r $opt_vardir/std_data_ln/*");
1873
 
  system("chmod -R ugo+rw $opt_vardir/filesystem_ln/*");
1874
 
  system("chmod -R ugo+w $glob_suite_path/filesystem_engine/tests/t");
1875
1761
}
1876
1762
 
1877
1763
 
1879
1765
  # Check if running as root
1880
1766
  # i.e a file can be read regardless what mode we set it to
1881
1767
  my $test_file= "$opt_vardir/test_running_as_root.txt";
1882
 
  dtr_tofile($test_file, "Drizzle");
 
1768
  mtr_tofile($test_file, "MySQL");
1883
1769
  chmod(oct("0000"), $test_file);
1884
1770
 
1885
1771
  my $result="";
1895
1781
  my $file_mode= (stat($test_file))[2] & 07777;
1896
1782
 
1897
1783
  $ENV{'DRIZZLE_TEST_ROOT'}= "NO";
1898
 
  dtr_verbose("result: $result, file_mode: $file_mode");
1899
 
  if ($result eq "Drizzle" && $file_mode == 0)
 
1784
  mtr_verbose("result: $result, file_mode: $file_mode");
 
1785
  if ($result eq "MySQL" && $file_mode == 0)
1900
1786
  {
1901
 
    dtr_warning("running this script as _root_ will cause some " .
 
1787
    mtr_warning("running this script as _root_ will cause some " .
1902
1788
                "tests to be skipped");
1903
1789
    $ENV{'DRIZZLE_TEST_ROOT'}= "YES";
1904
1790
  }
1910
1796
 
1911
1797
 
1912
1798
sub check_debug_support ($) {
1913
 
  my $drizzled_variables= shift;
 
1799
  my $mysqld_variables= shift;
1914
1800
 
1915
 
  if ( ! $drizzled_variables->{'debug'} )
 
1801
  if ( ! $mysqld_variables->{'debug'} )
1916
1802
  {
1917
 
    #dtr_report("Binaries are not debug compiled");
 
1803
    #mtr_report("Binaries are not debug compiled");
1918
1804
    $debug_compiled_binaries= 0;
1919
1805
 
1920
1806
    if ( $opt_debug )
1921
1807
    {
1922
 
      dtr_error("Can't use --debug, binaries does not support it");
 
1808
      mtr_error("Can't use --debug, binaries does not support it");
1923
1809
    }
1924
1810
    return;
1925
1811
  }
1926
 
  dtr_report("Binaries are debug compiled");
 
1812
  mtr_report("Binaries are debug compiled");
1927
1813
  $debug_compiled_binaries= 1;
1928
1814
}
1929
1815
 
1940
1826
  my $args;
1941
1827
 
1942
1828
  {
1943
 
    drizzled_start($master->[0],[],[]);
 
1829
    mysqld_start($master->[0],[],[]);
1944
1830
    if ( ! $master->[0]->{'pid'} )
1945
1831
    {
1946
 
      dtr_error("Can't start the drizzled server");
 
1832
      mtr_error("Can't start the mysqld server");
1947
1833
    }
1948
1834
  }
1949
1835
 
1950
 
  dtr_init_args(\$args);
 
1836
  mtr_init_args(\$args);
1951
1837
 
1952
 
  dtr_add_arg($args, "--user=%s", $opt_user);
 
1838
  mtr_add_arg($args, "--user=%s", $opt_user);
1953
1839
 
1954
1840
  if ( $opt_small_bench )
1955
1841
  {
1956
 
    dtr_add_arg($args, "--small-test");
1957
 
    dtr_add_arg($args, "--small-tables");
 
1842
    mtr_add_arg($args, "--small-test");
 
1843
    mtr_add_arg($args, "--small-tables");
1958
1844
  }
1959
1845
 
1960
 
  chdir($glob_drizzle_bench_dir)
1961
 
    or dtr_error("Couldn't chdir to '$glob_drizzle_bench_dir': $!");
 
1846
  chdir($glob_mysql_bench_dir)
 
1847
    or mtr_error("Couldn't chdir to '$glob_mysql_bench_dir': $!");
1962
1848
 
1963
1849
  if ( ! $benchmark )
1964
1850
  {
1965
 
    dtr_run("$glob_drizzle_bench_dir/run-all-tests", $args, "", "", "", "");
 
1851
    mtr_run("$glob_mysql_bench_dir/run-all-tests", $args, "", "", "", "");
1966
1852
    # FIXME check result code?!
1967
1853
  }
1968
1854
  elsif ( -x $benchmark )
1969
1855
  {
1970
 
    dtr_run("$glob_drizzle_bench_dir/$benchmark", $args, "", "", "", "");
 
1856
    mtr_run("$glob_mysql_bench_dir/$benchmark", $args, "", "", "", "");
1971
1857
    # FIXME check result code?!
1972
1858
  }
1973
1859
  else
1974
1860
  {
1975
 
    dtr_error("Benchmark $benchmark not found");
 
1861
    mtr_error("Benchmark $benchmark not found");
1976
1862
  }
1977
1863
 
1978
 
  chdir($glob_drizzle_test_dir);          # Go back
 
1864
  chdir($glob_mysql_test_dir);          # Go back
1979
1865
 
1980
1866
  {
1981
1867
    stop_masters();
1992
1878
sub run_tests () {
1993
1879
  my ($tests)= @_;
1994
1880
 
1995
 
  dtr_print_thick_line();
1996
 
 
1997
 
  dtr_timer_start($glob_timers,"suite", 60 * $opt_suite_timeout);
1998
 
 
1999
 
  dtr_report_tests_not_skipped_though_disabled($tests);
2000
 
 
2001
 
  dtr_print_header();
 
1881
  mtr_print_thick_line();
 
1882
 
 
1883
  mtr_timer_start($glob_timers,"suite", 60 * $opt_suite_timeout);
 
1884
 
 
1885
  mtr_report_tests_not_skipped_though_disabled($tests);
 
1886
 
 
1887
  mtr_print_header();
2002
1888
 
2003
1889
  foreach my $tinfo ( @$tests )
2004
1890
  {
2009
1895
          next;
2010
1896
        }
2011
1897
 
2012
 
      dtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout);
 
1898
      mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout);
2013
1899
      run_testcase($tinfo);
2014
 
      dtr_timer_stop($glob_timers,"testcase");
 
1900
      mtr_timer_stop($glob_timers,"testcase");
2015
1901
    }
2016
1902
  }
2017
1903
 
2018
 
  dtr_print_line();
 
1904
  mtr_print_line();
2019
1905
 
2020
1906
  if ( ! $glob_debugger and
2021
1907
       ! $opt_extern )
2032
1918
    gprof_collect(); # collect coverage information
2033
1919
  }
2034
1920
 
2035
 
  dtr_report_stats($tests);
 
1921
  mtr_report_stats($tests);
2036
1922
 
2037
 
  dtr_timer_stop($glob_timers,"suite");
 
1923
  mtr_timer_stop($glob_timers,"suite");
2038
1924
}
2039
1925
 
2040
1926
 
2054
1940
    # vardir does not already exist it should be created
2055
1941
    if ( ! -d $opt_vardir )
2056
1942
    {
2057
 
      dtr_report("Creating '$opt_vardir'");
 
1943
      mtr_report("Creating '$opt_vardir'");
2058
1944
      setup_vardir();
2059
1945
    }
2060
1946
    else
2061
1947
    {
2062
 
      dtr_verbose("No need to create '$opt_vardir' it already exists");
 
1948
      mtr_verbose("No need to create '$opt_vardir' it already exists");
2063
1949
    }
2064
1950
  }
2065
1951
  else
2071
1957
      remove_stale_vardir();
2072
1958
      setup_vardir();
2073
1959
 
2074
 
      drizzle_install_db();
 
1960
      mysql_install_db();
2075
1961
      if ( $opt_force )
2076
1962
      {
2077
1963
        # Save a snapshot of the freshly installed db
2082
1968
  }
2083
1969
  check_running_as_root();
2084
1970
 
2085
 
  dtr_log_init("$opt_vardir/log/drizzle-test-run.log");
 
1971
  mtr_log_init("$opt_vardir/log/drizzle-test-run.log");
2086
1972
 
2087
1973
}
2088
1974
 
2089
 
sub drizzle_install_db () {
 
1975
sub mysql_install_db () {
2090
1976
 
2091
1977
  if ($max_master_num > 1)
2092
1978
  {
2093
 
    copy_install_db('master', $master->[1]->{'path_myddir'} . "/local");
 
1979
    copy_install_db('master', $master->[1]->{'path_myddir'});
2094
1980
  }
2095
1981
 
2096
1982
  # Install the number of slave databses needed
2107
1993
  my $type=      shift;
2108
1994
  my $data_dir=  shift;
2109
1995
 
2110
 
  dtr_report("Installing \u$type Database");
 
1996
  mtr_report("Installing \u$type Database");
2111
1997
 
2112
1998
  # Just copy the installed db from first master
2113
 
  dtr_copy_dir($master->[0]->{'path_myddir'}, $data_dir);
 
1999
  mtr_copy_dir($master->[0]->{'path_myddir'}, $data_dir);
2114
2000
 
2115
2001
}
2116
2002
 
2128
2014
    {
2129
2015
      my $data_dir= $slave->[$idx]->{'path_myddir'};
2130
2016
      my $name= basename($data_dir);
2131
 
      dtr_rmtree($data_dir);
2132
 
      dtr_copy_dir("$path_snapshot/$name", $data_dir);
 
2017
      mtr_rmtree($data_dir);
 
2018
      mtr_copy_dir("$path_snapshot/$name", $data_dir);
2133
2019
    }
2134
2020
  }
2135
2021
}
2148
2034
 
2149
2035
  if ( $tinfo->{'skip'} )
2150
2036
  {
2151
 
    dtr_report_test_name($tinfo);
2152
 
    dtr_report_test_skipped($tinfo);
 
2037
    mtr_report_test_name($tinfo);
 
2038
    mtr_report_test_skipped($tinfo);
2153
2039
    return 1;
2154
2040
  }
2155
2041
 
2163
2049
  my $args;
2164
2050
 
2165
2051
  # Remove old files produced by drizzletest
2166
 
  my $base_file= dtr_match_extension($tinfo->{'result_file'},
 
2052
  my $base_file= mtr_match_extension($tinfo->{'result_file'},
2167
2053
                                    "result"); # Trim extension
2168
2054
  unlink("$base_file.reject");
2169
2055
  unlink("$base_file.progress");
2177
2063
  my $tinfo= shift;
2178
2064
 
2179
2065
  # Save info from this testcase run to drizzletest.log
2180
 
  dtr_appendfile_to_file($path_current_test_log, $path_drizzletest_log)
 
2066
  mtr_appendfile_to_file($path_current_test_log, $path_drizzletest_log)
2181
2067
    if -f $path_current_test_log;
2182
 
  dtr_appendfile_to_file($path_timefile, $path_drizzletest_log)
 
2068
  mtr_appendfile_to_file($path_timefile, $path_drizzletest_log)
2183
2069
    if -f $path_timefile;
2184
2070
}
2185
2071
 
2191
2077
  # Write a marker to all log files
2192
2078
 
2193
2079
  # The file indicating current test name
2194
 
  dtr_tonewfile($path_current_test_log, $log_msg);
 
2080
  mtr_tonewfile($path_current_test_log, $log_msg);
2195
2081
 
2196
 
  # each drizzled's .err file
2197
 
  foreach my $drizzled (@{$master}, @{$slave})
 
2082
  # each mysqld's .err file
 
2083
  foreach my $mysqld (@{$master}, @{$slave})
2198
2084
  {
2199
 
    dtr_tofile($drizzled->{path_myerr}, $log_msg);
 
2085
    mtr_tofile($mysqld->{path_myerr}, $log_msg);
2200
2086
  }
2201
2087
 
2202
2088
}
2224
2110
 
2225
2111
  if ( ! $reason )
2226
2112
  {
2227
 
    dtr_warning("Could not find reason for skipping test in $path_timefile");
 
2113
    mtr_warning("Could not find reason for skipping test in $path_timefile");
2228
2114
    $reason= "Detected by testcase(reason unknown) ";
2229
2115
  }
2230
2116
  $tinfo->{'comment'}= $reason;
2244
2130
 
2245
2131
# We don't start and kill the servers for each testcase. But some
2246
2132
# testcases needs a restart, because they specify options to start
2247
 
# drizzled with. After that testcase, we need to restart again, to set
 
2133
# mysqld with. After that testcase, we need to restart again, to set
2248
2134
# back the normal options.
2249
2135
 
2250
2136
sub run_testcase ($) {
2255
2141
  # -------------------------------------------------------
2256
2142
 
2257
2143
  $ENV{'TZ'}= $tinfo->{'timezone'};
2258
 
  dtr_verbose("Setting timezone: $tinfo->{'timezone'}");
 
2144
  mtr_verbose("Setting timezone: $tinfo->{'timezone'}");
2259
2145
 
2260
2146
  my $master_restart= run_testcase_need_master_restart($tinfo);
2261
2147
  my $slave_restart= run_testcase_need_slave_restart($tinfo);
2265
2151
    # Can't restart a running server that may be in use
2266
2152
    if ( $opt_extern )
2267
2153
    {
2268
 
      dtr_report_test_name($tinfo);
 
2154
      mtr_report_test_name($tinfo);
2269
2155
      $tinfo->{comment}= "Can't restart a running server";
2270
 
      dtr_report_test_skipped($tinfo);
 
2156
      mtr_report_test_skipped($tinfo);
2271
2157
      return;
2272
2158
    }
2273
2159
 
2277
2163
  # Write to all log files to indicate start of testcase
2278
2164
  run_testcase_mark_logs($tinfo, "CURRENT_TEST: $tinfo->{name}\n");
2279
2165
 
2280
 
  my $died= dtr_record_dead_children();
 
2166
  my $died= mtr_record_dead_children();
2281
2167
  if ($died or $master_restart or $slave_restart)
2282
2168
  {
2283
2169
    if (run_testcase_start_servers($tinfo))
2284
2170
    {
2285
 
      dtr_report_test_name($tinfo);
 
2171
      mtr_report_test_name($tinfo);
2286
2172
      report_failure_and_restart($tinfo);
2287
2173
      return 1;
2288
2174
    }
2293
2179
  # ----------------------------------------------------------------------
2294
2180
  if ( $opt_start_and_exit or $opt_start_dirty )
2295
2181
  {
2296
 
    dtr_timer_stop_all($glob_timers);
2297
 
    dtr_report("\nServers started, exiting");
 
2182
    mtr_timer_stop_all($glob_timers);
 
2183
    mtr_report("\nServers started, exiting");
2298
2184
    exit(0);
2299
2185
  }
2300
2186
 
2302
2188
    do_before_run_drizzletest($tinfo);
2303
2189
 
2304
2190
    my $res= run_drizzletest($tinfo);
2305
 
    dtr_report_test_name($tinfo);
 
2191
    mtr_report_test_name($tinfo);
2306
2192
 
2307
2193
    do_after_run_drizzletest($tinfo);
2308
2194
 
2309
2195
    if ( $res == 0 )
2310
2196
    {
2311
 
      dtr_report_test_passed($tinfo);
 
2197
      mtr_report_test_passed($tinfo);
2312
2198
    }
2313
2199
    elsif ( $res == 62 )
2314
2200
    {
2316
2202
 
2317
2203
      # Try to get reason from drizzletest.log
2318
2204
      find_testcase_skipped_reason($tinfo);
2319
 
      dtr_report_test_skipped($tinfo);
 
2205
      mtr_report_test_skipped($tinfo);
2320
2206
    }
2321
2207
    elsif ( $res == 63 )
2322
2208
    {
2352
2238
#
2353
2239
sub save_installed_db () {
2354
2240
 
2355
 
  dtr_report("Saving snapshot of installed databases");
2356
 
  dtr_rmtree($path_snapshot);
 
2241
  mtr_report("Saving snapshot of installed databases");
 
2242
  mtr_rmtree($path_snapshot);
2357
2243
 
2358
2244
  foreach my $data_dir (@data_dir_lst)
2359
2245
  {
2360
2246
    my $name= basename($data_dir);
2361
 
    dtr_copy_dir("$data_dir", "$path_snapshot/$name");
 
2247
    mtr_copy_dir("$data_dir", "$path_snapshot/$name");
2362
2248
  }
2363
2249
}
2364
2250
 
2377
2263
  {
2378
2264
    last if $opt_max_save_core > 0 && $num_saved_cores >= $opt_max_save_core;
2379
2265
    my $core_name= basename($core_file);
2380
 
    dtr_report("Saving $core_name");
 
2266
    mtr_report("Saving $core_name");
2381
2267
    mkdir($save_name) if ! -d $save_name;
2382
2268
    rename("$core_file", "$save_name/$core_name");
2383
2269
    ++$num_saved_cores;
2394
2280
 
2395
2281
  if ( -d $path_snapshot)
2396
2282
  {
2397
 
    dtr_report("Restoring snapshot of databases");
 
2283
    mtr_report("Restoring snapshot of databases");
2398
2284
 
2399
2285
    foreach my $data_dir (@data_dir_lst)
2400
2286
    {
2401
2287
      my $name= basename($data_dir);
2402
2288
      save_files_before_restore($test_name, $data_dir);
2403
 
      dtr_rmtree("$data_dir");
2404
 
      dtr_copy_dir("$path_snapshot/$name", "$data_dir");
 
2289
      mtr_rmtree("$data_dir");
 
2290
      mtr_copy_dir("$path_snapshot/$name", "$data_dir");
2405
2291
    }
2406
2292
  }
2407
2293
  else
2408
2294
  {
2409
2295
    # No snapshot existed
2410
 
    dtr_error("No snapshot existed");
 
2296
    mtr_error("No snapshot existed");
2411
2297
  }
2412
2298
}
2413
2299
 
2414
2300
sub report_failure_and_restart ($) {
2415
2301
  my $tinfo= shift;
2416
2302
 
2417
 
  dtr_report_test_failed($tinfo);
 
2303
  mtr_report_test_failed($tinfo);
2418
2304
  print "\n";
2419
2305
  if ( $opt_force )
2420
2306
  {
2423
2309
 
2424
2310
    # Restore the snapshot of the installed test db
2425
2311
    restore_installed_db($tinfo->{'name'});
2426
 
    dtr_report("Resuming Tests\n");
 
2312
    mtr_report("Resuming Tests\n");
2427
2313
    return;
2428
2314
  }
2429
2315
 
2430
2316
  my $test_mode= join(" ", @::glob_test_mode) || "default";
2431
 
  dtr_report("Aborting: $tinfo->{'name'} failed in $test_mode mode. ");
2432
 
  dtr_report("To continue, re-run with '--force'.");
 
2317
  mtr_report("Aborting: $tinfo->{'name'} failed in $test_mode mode. ");
 
2318
  mtr_report("To continue, re-run with '--force'.");
2433
2319
  if ( ! $glob_debugger and
2434
2320
       ! $opt_extern )
2435
2321
  {
2436
2322
    stop_all_servers();
2437
2323
  }
2438
 
  dtr_exit(1);
 
2324
  mtr_exit(1);
2439
2325
 
2440
2326
}
2441
2327
 
2447
2333
  # Run master initialization shell script if one exists
2448
2334
  if ( $init_script )
2449
2335
  {
2450
 
    my $ret= dtr_run("/bin/sh", [$init_script], "", "", "", "");
 
2336
    my $ret= mtr_run("/bin/sh", [$init_script], "", "", "", "");
2451
2337
    if ( $ret != 0 )
2452
2338
    {
2453
2339
      # FIXME rewrite those scripts to return 0 if successful
2454
 
      # dtr_warning("$init_script exited with code $ret");
 
2340
      # mtr_warning("$init_script exited with code $ret");
2455
2341
    }
2456
2342
  }
2457
2343
}
2510
2396
  # Run slave initialization shell script if one exists
2511
2397
  if ( $init_script )
2512
2398
  {
2513
 
    my $ret= dtr_run("/bin/sh", [$init_script], "", "", "", "");
 
2399
    my $ret= mtr_run("/bin/sh", [$init_script], "", "", "", "");
2514
2400
    if ( $ret != 0 )
2515
2401
    {
2516
2402
      # FIXME rewrite those scripts to return 0 if successful
2517
 
      # dtr_warning("$init_script exited with code $ret");
 
2403
      # mtr_warning("$init_script exited with code $ret");
2518
2404
    }
2519
2405
  }
2520
2406
 
2525
2411
}
2526
2412
 
2527
2413
 
2528
 
sub drizzled_arguments ($$$$) {
 
2414
sub mysqld_arguments ($$$$) {
2529
2415
  my $args=              shift;
2530
 
  my $drizzled=            shift;
 
2416
  my $mysqld=            shift;
2531
2417
  my $extra_opt=         shift;
2532
2418
  my $slave_master_info= shift;
2533
2419
 
2534
 
  my $idx= $drizzled->{'idx'};
 
2420
  my $idx= $mysqld->{'idx'};
2535
2421
  my $sidx= "";                 # Index as string, 0 is empty string
2536
2422
  if ( $idx> 0 )
2537
2423
  {
2540
2426
 
2541
2427
  my $prefix= "";               # If drizzletest server arg
2542
2428
 
2543
 
  dtr_add_arg($args, "%s--no-defaults", $prefix);
 
2429
  mtr_add_arg($args, "%s--no-defaults", $prefix);
 
2430
 
 
2431
  $path_my_basedir= collapse_path($path_my_basedir);
 
2432
  mtr_add_arg($args, "%s--basedir=%s", $prefix, $path_my_basedir);
2544
2433
 
2545
2434
  if ($opt_engine)
2546
2435
  {
2547
 
    dtr_add_arg($args, "%s--default-storage-engine=%s", $prefix, $opt_engine);
 
2436
    mtr_add_arg($args, "%s--default-storage-engine=%s", $prefix, $opt_engine);
2548
2437
  }
2549
2438
 
2550
 
  if ( $drizzle_version_id >= 50036)
 
2439
  if ( $mysql_version_id >= 50036)
2551
2440
  {
2552
 
    # By default, prevent the started drizzled to access files outside of vardir
2553
 
    dtr_add_arg($args, "%s--secure-file-priv=%s", $prefix, $opt_vardir);
 
2441
    # By default, prevent the started mysqld to access files outside of vardir
 
2442
    mtr_add_arg($args, "%s--secure-file-priv=%s", $prefix, $opt_vardir);
2554
2443
  }
2555
2444
 
2556
 
  dtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
 
2445
  mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
2557
2446
 
2558
2447
  # Increase default connect_timeout to avoid intermittent
2559
2448
  # disconnects when test servers are put under load
2560
2449
  # see BUG#28359
2561
 
  dtr_add_arg($args, "%s--mysql-protocol.connect-timeout=60", $prefix);
2562
 
 
2563
 
 
2564
 
  # When drizzled is run by a root user(euid is 0), it will fail
 
2450
  mtr_add_arg($args, "%s--drizzle-protocol-connect-timeout=60", $prefix);
 
2451
 
 
2452
 
 
2453
  # When mysqld is run by a root user(euid is 0), it will fail
2565
2454
  # to start unless we specify what user to run as, see BUG#30630
2566
2455
  my $euid= $>;
2567
 
  if (grep(/^--user/, @$extra_opt, @opt_extra_drizzled_opt) == 0) {
2568
 
    dtr_add_arg($args, "%s--user=root", $prefix);
 
2456
  if (grep(/^--user/, @$extra_opt, @opt_extra_mysqld_opt) == 0) {
 
2457
    mtr_add_arg($args, "%s--user=root", $prefix);
2569
2458
  }
2570
2459
 
2571
 
  dtr_add_arg($args, "%s--pid-file=%s", $prefix,
2572
 
              $drizzled->{'path_pid'});
2573
 
 
2574
 
  dtr_add_arg($args, "%s--mysql-protocol.port=%d", $prefix,
2575
 
              $drizzled->{'port'});
2576
 
 
2577
 
  dtr_add_arg($args, "%s--drizzle-protocol.port=%d", $prefix,
2578
 
              $drizzled->{'secondary_port'});
2579
 
 
2580
 
  dtr_add_arg($args, "%s--datadir=%s", $prefix,
2581
 
              $drizzled->{'path_myddir'});
2582
 
 
2583
 
  dtr_add_arg($args, "%s--mysql-unix-socket-protocol.path=%s", $prefix,
2584
 
              $drizzled->{'path_sock'});
 
2460
  mtr_add_arg($args, "%s--pid-file=%s", $prefix,
 
2461
              $mysqld->{'path_pid'});
 
2462
 
 
2463
  mtr_add_arg($args, "%s--drizzle-protocol-port=%d", $prefix,
 
2464
                $mysqld->{'port'});
 
2465
 
 
2466
  mtr_add_arg($args, "%s--mysql-protocol-port=%d", $prefix,
 
2467
                $mysqld->{'port'} + 50);
 
2468
 
 
2469
  mtr_add_arg($args, "%s--datadir=%s", $prefix,
 
2470
              $mysqld->{'path_myddir'});
2585
2471
 
2586
2472
  # Check if "extra_opt" contains --skip-log-bin
2587
 
  if ( $drizzled->{'type'} eq 'master' )
 
2473
  if ( $mysqld->{'type'} eq 'master' )
2588
2474
  {
2589
 
    dtr_add_arg($args, "%s--server-id=%d", $prefix,
 
2475
    mtr_add_arg($args, "%s--server-id=%d", $prefix,
2590
2476
               $idx > 0 ? $idx + 101 : 1);
2591
2477
 
2592
 
    dtr_add_arg($args,
2593
 
      "%s--innodb.data-file-path=ibdata1:20M:autoextend", $prefix);
2594
 
 
 
2478
    mtr_add_arg($args, "%s--loose-innodb_data_file_path=ibdata1:10M:autoextend",
 
2479
                $prefix);
 
2480
 
 
2481
    mtr_add_arg($args, "%s--loose-innodb-lock-wait-timeout=5", $prefix);
 
2482
 
 
2483
    if ( $idx > 0 or !$use_innodb)
 
2484
    {
 
2485
      mtr_add_arg($args, "%s--loose-skip-innodb", $prefix);
 
2486
    }
2595
2487
  }
2596
2488
  else
2597
2489
  {
2598
 
    dtr_error("unknown drizzled type")
2599
 
      unless $drizzled->{'type'} eq 'slave';
 
2490
    mtr_error("unknown mysqld type")
 
2491
      unless $mysqld->{'type'} eq 'slave';
2600
2492
 
2601
2493
    # Directory where slaves find the dumps generated by "load data"
2602
2494
    # on the server. The path need to have constant length otherwise
2607
2499
    {
2608
2500
      foreach my $arg ( @$slave_master_info )
2609
2501
      {
2610
 
        dtr_add_arg($args, "%s%s", $prefix, $arg);
 
2502
        mtr_add_arg($args, "%s%s", $prefix, $arg);
2611
2503
      }
2612
2504
    }
2613
2505
    else
2614
2506
    {
2615
2507
      my $slave_server_id=  2 + $idx;
2616
2508
      my $slave_rpl_rank= $slave_server_id;
2617
 
      dtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
 
2509
      mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
2618
2510
    }
2619
2511
  } # end slave
2620
2512
 
2621
2513
  if ( $opt_debug )
2622
2514
  {
2623
 
    dtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/%s%s.trace",
2624
 
                $prefix, $path_vardir_trace, $drizzled->{'type'}, $sidx);
 
2515
    mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/%s%s.trace",
 
2516
                $prefix, $path_vardir_trace, $mysqld->{'type'}, $sidx);
2625
2517
  }
2626
2518
 
2627
 
  dtr_add_arg($args, "%s--sort-buffer-size=256K", $prefix);
2628
 
  dtr_add_arg($args, "%s--max-heap-table-size=1M", $prefix);
 
2519
  mtr_add_arg($args, "%s--key_buffer_size=1M", $prefix);
 
2520
  mtr_add_arg($args, "%s--sort_buffer=256K", $prefix);
 
2521
  mtr_add_arg($args, "%s--max_heap_table_size=1M", $prefix);
2629
2522
 
2630
2523
  if ( $opt_warnings )
2631
2524
  {
2632
 
    dtr_add_arg($args, "%s--log-warnings", $prefix);
 
2525
    mtr_add_arg($args, "%s--log-warnings", $prefix);
2633
2526
  }
2634
2527
 
2635
 
  # Indicate to "drizzled" it will be debugged in debugger
 
2528
  # Indicate to "mysqld" it will be debugged in debugger
2636
2529
  if ( $glob_debugger )
2637
2530
  {
2638
 
    dtr_add_arg($args, "%s--gdb", $prefix);
 
2531
    mtr_add_arg($args, "%s--gdb", $prefix);
2639
2532
  }
2640
2533
 
2641
2534
  my $found_skip_core= 0;
2642
 
  foreach my $arg ( @opt_extra_drizzled_opt, @$extra_opt )
 
2535
  foreach my $arg ( @opt_extra_mysqld_opt, @$extra_opt )
2643
2536
  {
2644
2537
    # Allow --skip-core-file to be set in <testname>-[master|slave].opt file
2645
2538
    if ($arg eq "--skip-core-file")
2648
2541
    }
2649
2542
    else
2650
2543
    {
2651
 
      dtr_add_arg($args, "%s%s", $prefix, $arg);
 
2544
      mtr_add_arg($args, "%s%s", $prefix, $arg);
2652
2545
    }
2653
2546
  }
2654
2547
  if ( !$found_skip_core )
2655
2548
  {
2656
 
    dtr_add_arg($args, "%s%s", $prefix, "--core-file");
 
2549
    mtr_add_arg($args, "%s%s", $prefix, "--core-file");
2657
2550
  }
2658
2551
 
2659
2552
  return $args;
2662
2555
 
2663
2556
##############################################################################
2664
2557
#
2665
 
#  Start drizzled and return the PID
 
2558
#  Start mysqld and return the PID
2666
2559
#
2667
2560
##############################################################################
2668
2561
 
2669
 
sub drizzled_start ($$$) {
2670
 
  my $drizzled=            shift;
 
2562
sub mysqld_start ($$$) {
 
2563
  my $mysqld=            shift;
2671
2564
  my $extra_opt=         shift;
2672
2565
  my $slave_master_info= shift;
2673
2566
 
2676
2569
  my $pid= -1;
2677
2570
  my $wait_for_pid_file= 1;
2678
2571
 
2679
 
  my $type= $drizzled->{'type'};
2680
 
  my $idx= $drizzled->{'idx'};
 
2572
  my $type= $mysqld->{'type'};
 
2573
  my $idx= $mysqld->{'idx'};
2681
2574
 
2682
2575
  if ( $type eq 'master' )
2683
2576
  {
2684
 
    $exe= $exe_master_drizzled;
 
2577
    $exe= $exe_master_mysqld;
2685
2578
  }
2686
2579
  elsif ( $type eq 'slave' )
2687
2580
  {
2688
 
    $exe= $exe_slave_drizzled;
 
2581
    $exe= $exe_slave_mysqld;
2689
2582
  }
2690
2583
  else
2691
2584
  {
2692
 
    dtr_error("Unknown 'type' \"$type\" passed to drizzled_start");
 
2585
    mtr_error("Unknown 'type' \"$type\" passed to mysqld_start");
2693
2586
  }
2694
2587
 
2695
 
  dtr_init_args(\$args);
 
2588
  mtr_init_args(\$args);
2696
2589
 
2697
 
  if ( $opt_valgrind_drizzled )
 
2590
  if ( $opt_valgrind_mysqld )
2698
2591
  {
2699
2592
    valgrind_arguments($args, \$exe);
2700
2593
  }
2701
2594
 
2702
 
  drizzled_arguments($args,$drizzled,$extra_opt,$slave_master_info);
 
2595
  mysqld_arguments($args,$mysqld,$extra_opt,$slave_master_info);
2703
2596
 
2704
2597
  if ( $opt_gdb || $opt_manual_gdb)
2705
2598
  {
2720
2613
  elsif ( $opt_manual_debug )
2721
2614
  {
2722
2615
     print "\nStart $type in your debugger\n" .
2723
 
           "dir: $glob_drizzle_test_dir\n" .
 
2616
           "dir: $glob_mysql_test_dir\n" .
2724
2617
           "exe: $exe\n" .
2725
2618
           "args:  " . join(" ", @$args)  . "\n\n" .
2726
2619
           "Waiting ....\n";
2735
2628
  }
2736
2629
 
2737
2630
  # Remove the pidfile
2738
 
  unlink($drizzled->{'path_pid'});
 
2631
  unlink($mysqld->{'path_pid'});
2739
2632
 
2740
2633
  if ( defined $exe )
2741
2634
  {
2742
 
    dtr_verbose("running Drizzle with: $exe @$args");
2743
 
    $pid= dtr_spawn($exe, $args, "",
2744
 
                    $drizzled->{'path_myerr'},
2745
 
                    $drizzled->{'path_myerr'},
 
2635
    $pid= mtr_spawn($exe, $args, "",
 
2636
                    $mysqld->{'path_myerr'},
 
2637
                    $mysqld->{'path_myerr'},
2746
2638
                    "",
2747
2639
                    { append_log_file => 1 });
2748
2640
  }
2749
2641
 
2750
2642
 
2751
 
  if ( $wait_for_pid_file && !sleep_until_file_created($drizzled->{'path_pid'},
2752
 
                                                       $drizzled->{'start_timeout'},
 
2643
  if ( $wait_for_pid_file && !sleep_until_file_created($mysqld->{'path_pid'},
 
2644
                                                       $mysqld->{'start_timeout'},
2753
2645
                                                       $pid))
2754
2646
  {
2755
2647
 
2756
 
    dtr_error("Failed to start drizzled $drizzled->{'type'}");
 
2648
    mtr_error("Failed to start mysqld $mysqld->{'type'}");
2757
2649
  }
2758
2650
 
2759
2651
 
2760
2652
  # Remember pid of the started process
2761
 
  $drizzled->{'pid'}= $pid;
 
2653
  $mysqld->{'pid'}= $pid;
2762
2654
 
2763
2655
  # Remember options used when starting
2764
 
  $drizzled->{'start_opts'}= $extra_opt;
2765
 
  $drizzled->{'start_slave_master_info'}= $slave_master_info;
 
2656
  $mysqld->{'start_opts'}= $extra_opt;
 
2657
  $mysqld->{'start_slave_master_info'}= $slave_master_info;
2766
2658
 
2767
 
  dtr_verbose("drizzled pid: $pid");
 
2659
  mtr_verbose("mysqld pid: $pid");
2768
2660
  return $pid;
2769
2661
}
2770
2662
 
2771
2663
 
2772
2664
sub stop_all_servers () {
2773
2665
 
2774
 
  dtr_report("Stopping All Servers");
 
2666
  mtr_report("Stopping All Servers");
2775
2667
 
2776
2668
  my %admin_pids; # hash of admin processes that requests shutdown
2777
2669
  my @kill_pids;  # list of processes to shutdown/kill
2778
2670
  my $pid;
2779
2671
 
2780
2672
  # Start shutdown of all started masters
2781
 
  foreach my $drizzled (@{$slave}, @{$master})
 
2673
  foreach my $mysqld (@{$slave}, @{$master})
2782
2674
  {
2783
 
    if ( $drizzled->{'pid'} )
 
2675
    if ( $mysqld->{'pid'} )
2784
2676
    {
2785
 
      $pid= dtr_server_shutdown($drizzled);
 
2677
      $pid= mtr_server_shutdown($mysqld);
2786
2678
      $admin_pids{$pid}= 1;
2787
2679
 
2788
2680
      push(@kill_pids,{
2789
 
                       pid      => $drizzled->{'pid'},
2790
 
                       real_pid => $drizzled->{'real_pid'},
2791
 
                       pidfile  => $drizzled->{'path_pid'},
2792
 
                       sockfile => $drizzled->{'path_sock'},
2793
 
                       port     => $drizzled->{'port'},
2794
 
                       errfile  => $drizzled->{'path_myerr'},
 
2681
                       pid      => $mysqld->{'pid'},
 
2682
                       real_pid => $mysqld->{'real_pid'},
 
2683
                       pidfile  => $mysqld->{'path_pid'},
 
2684
                       sockfile => $mysqld->{'path_sock'},
 
2685
                       port     => $mysqld->{'port'},
 
2686
                       errfile  => $mysqld->{'path_myerr'},
2795
2687
                      });
2796
2688
 
2797
 
      $drizzled->{'pid'}= 0; # Assume we are done with it
 
2689
      $mysqld->{'pid'}= 0; # Assume we are done with it
2798
2690
    }
2799
2691
  }
2800
2692
 
2801
2693
  # Wait blocking until all shutdown processes has completed
2802
 
  dtr_wait_blocking(\%admin_pids);
 
2694
  mtr_wait_blocking(\%admin_pids);
2803
2695
 
2804
2696
  # Make sure that process has shutdown else try to kill them
2805
 
  dtr_check_stop_servers(\@kill_pids);
 
2697
  mtr_check_stop_servers(\@kill_pids);
2806
2698
}
2807
2699
 
2808
2700
 
2816
2708
  if ( $tinfo->{'master_sh'} )
2817
2709
  {
2818
2710
    $do_restart= 1;           # Always restart if script to run
2819
 
    dtr_verbose("Restart master: Always restart if script to run");
 
2711
    mtr_verbose("Restart master: Always restart if script to run");
2820
2712
  }
2821
2713
  if ( $tinfo->{'force_restart'} )
2822
2714
  {
2823
2715
    $do_restart= 1; # Always restart if --force-restart in -opt file
2824
 
    dtr_verbose("Restart master: Restart forced with --force-restart");
 
2716
    mtr_verbose("Restart master: Restart forced with --force-restart");
2825
2717
  }
2826
2718
  elsif( $tinfo->{'component_id'} eq 'im' )
2827
2719
  {
2828
2720
    $do_restart= 1;
2829
 
    dtr_verbose("Restart master: Always restart for im tests");
 
2721
    mtr_verbose("Restart master: Always restart for im tests");
2830
2722
  }
2831
2723
  elsif ( $master->[0]->{'running_master_options'} and
2832
2724
          $master->[0]->{'running_master_options'}->{'timezone'} ne
2833
2725
          $tinfo->{'timezone'})
2834
2726
  {
2835
2727
    $do_restart= 1;
2836
 
    dtr_verbose("Restart master: Different timezone");
 
2728
    mtr_verbose("Restart master: Different timezone");
2837
2729
  }
2838
2730
  # Check that running master was started with same options
2839
2731
  # as the current test requires
2840
 
  elsif (! dtr_same_opts($master->[0]->{'start_opts'},
 
2732
  elsif (! mtr_same_opts($master->[0]->{'start_opts'},
2841
2733
                         $tinfo->{'master_opt'}) )
2842
2734
  {
2843
2735
    # Chech that diff is binlog format only
2844
 
    my $diff_opts= dtr_diff_opts($master->[0]->{'start_opts'},$tinfo->{'master_opt'});
 
2736
    my $diff_opts= mtr_diff_opts($master->[0]->{'start_opts'},$tinfo->{'master_opt'});
2845
2737
    if (scalar(@$diff_opts) eq 2) 
2846
2738
    {
2847
2739
      $do_restart= 1;
2849
2741
    else
2850
2742
    {
2851
2743
      $do_restart= 1;
2852
 
      dtr_verbose("Restart master: running with different options '" .
 
2744
      mtr_verbose("Restart master: running with different options '" .
2853
2745
                 join(" ", @{$tinfo->{'master_opt'}}) . "' != '" .
2854
2746
                join(" ", @{$master->[0]->{'start_opts'}}) . "'" );
2855
2747
    }
2859
2751
    if ( $opt_extern )
2860
2752
    {
2861
2753
      $do_restart= 0;
2862
 
      dtr_verbose("No restart: using extern master");
 
2754
      mtr_verbose("No restart: using extern master");
2863
2755
    }
2864
2756
    else
2865
2757
    {
2866
2758
      $do_restart= 1;
2867
 
      dtr_verbose("Restart master: master is not started");
 
2759
      mtr_verbose("Restart master: master is not started");
2868
2760
    }
2869
2761
  }
2870
2762
  return $do_restart;
2879
2771
 
2880
2772
  if ( $max_slave_num == 0)
2881
2773
  {
2882
 
    dtr_verbose("Skip slave restart: No testcase use slaves");
 
2774
    mtr_verbose("Skip slave restart: No testcase use slaves");
2883
2775
  }
2884
2776
  else
2885
2777
  {
2886
2778
 
2887
2779
    # Check if any slave is currently started
2888
2780
    my $any_slave_started= 0;
2889
 
    foreach my $drizzled (@{$slave})
 
2781
    foreach my $mysqld (@{$slave})
2890
2782
    {
2891
 
      if ( $drizzled->{'pid'} )
 
2783
      if ( $mysqld->{'pid'} )
2892
2784
      {
2893
2785
        $any_slave_started= 1;
2894
2786
        last;
2897
2789
 
2898
2790
    if ($any_slave_started)
2899
2791
    {
2900
 
      dtr_verbose("Restart slave: Slave is started, always restart");
 
2792
      mtr_verbose("Restart slave: Slave is started, always restart");
2901
2793
      $do_slave_restart= 1;
2902
2794
    }
2903
2795
    elsif ( $tinfo->{'slave_num'} )
2904
2796
    {
2905
 
      dtr_verbose("Restart slave: Test need slave");
 
2797
      mtr_verbose("Restart slave: Test need slave");
2906
2798
      $do_slave_restart= 1;
2907
2799
    }
2908
2800
  }
2936
2828
    delete $master->[0]->{'running_master_options'}; # Forget history
2937
2829
 
2938
2830
    # Start shutdown of all started masters
2939
 
    foreach my $drizzled (@{$master})
 
2831
    foreach my $mysqld (@{$master})
2940
2832
    {
2941
 
      if ( $drizzled->{'pid'} )
 
2833
      if ( $mysqld->{'pid'} )
2942
2834
      {
2943
 
        $pid= dtr_server_shutdown($drizzled);
 
2835
        $pid= mtr_server_shutdown($mysqld);
2944
2836
 
2945
2837
        $admin_pids{$pid}= 1;
2946
2838
 
2947
2839
        push(@kill_pids,{
2948
 
              pid      => $drizzled->{'pid'},
2949
 
              real_pid => $drizzled->{'real_pid'},
2950
 
              pidfile  => $drizzled->{'path_pid'},
2951
 
              sockfile => $drizzled->{'path_sock'},
2952
 
              port     => $drizzled->{'port'},
2953
 
              errfile   => $drizzled->{'path_myerr'},
 
2840
              pid      => $mysqld->{'pid'},
 
2841
              real_pid => $mysqld->{'real_pid'},
 
2842
              pidfile  => $mysqld->{'path_pid'},
 
2843
              sockfile => $mysqld->{'path_sock'},
 
2844
              port     => $mysqld->{'port'},
 
2845
              errfile   => $mysqld->{'path_myerr'},
2954
2846
        });
2955
2847
 
2956
 
        $drizzled->{'pid'}= 0; # Assume we are done with it
 
2848
        $mysqld->{'pid'}= 0; # Assume we are done with it
2957
2849
      }
2958
2850
    }
2959
2851
  }
2964
2856
    delete $slave->[0]->{'running_slave_options'}; # Forget history
2965
2857
 
2966
2858
    # Start shutdown of all started slaves
2967
 
    foreach my $drizzled (@{$slave})
 
2859
    foreach my $mysqld (@{$slave})
2968
2860
    {
2969
 
      if ( $drizzled->{'pid'} )
 
2861
      if ( $mysqld->{'pid'} )
2970
2862
      {
2971
 
        $pid= dtr_server_shutdown($drizzled);
 
2863
        $pid= mtr_server_shutdown($mysqld);
2972
2864
 
2973
2865
        $admin_pids{$pid}= 1;
2974
2866
 
2975
2867
        push(@kill_pids,{
2976
 
              pid      => $drizzled->{'pid'},
2977
 
              real_pid => $drizzled->{'real_pid'},
2978
 
              pidfile  => $drizzled->{'path_pid'},
2979
 
              sockfile => $drizzled->{'path_sock'},
2980
 
              port     => $drizzled->{'port'},
2981
 
              errfile  => $drizzled->{'path_myerr'},
 
2868
              pid      => $mysqld->{'pid'},
 
2869
              real_pid => $mysqld->{'real_pid'},
 
2870
              pidfile  => $mysqld->{'path_pid'},
 
2871
              sockfile => $mysqld->{'path_sock'},
 
2872
              port     => $mysqld->{'port'},
 
2873
              errfile  => $mysqld->{'path_myerr'},
2982
2874
        });
2983
2875
 
2984
 
        $drizzled->{'pid'}= 0; # Assume we are done with it
 
2876
        $mysqld->{'pid'}= 0; # Assume we are done with it
2985
2877
      }
2986
2878
    }
2987
2879
  }
2992
2884
  # ----------------------------------------------------------------------
2993
2885
 
2994
2886
  # Wait blocking until all shutdown processes has completed
2995
 
  dtr_wait_blocking(\%admin_pids);
 
2887
  mtr_wait_blocking(\%admin_pids);
2996
2888
 
2997
2889
 
2998
2890
  # Make sure that process has shutdown else try to kill them
2999
 
  dtr_check_stop_servers(\@kill_pids);
 
2891
  mtr_check_stop_servers(\@kill_pids);
3000
2892
}
3001
2893
 
3002
2894
 
3014
2906
  my $tinfo= shift;
3015
2907
  my $tname= $tinfo->{'name'};
3016
2908
 
3017
 
  if ( $tinfo->{'component_id'} eq 'drizzled' )
 
2909
  if ( $tinfo->{'component_id'} eq 'mysqld' )
3018
2910
  {
3019
2911
    if ( !$master->[0]->{'pid'} )
3020
2912
    {
3021
 
      # Master drizzled is not started
 
2913
      # Master mysqld is not started
3022
2914
      do_before_start_master($tinfo);
3023
2915
 
3024
 
      drizzled_start($master->[0],$tinfo->{'master_opt'},[]);
 
2916
      mysqld_start($master->[0],$tinfo->{'master_opt'},[]);
3025
2917
 
3026
2918
    }
3027
2919
 
3042
2934
    {
3043
2935
      if ( ! $slave->[$idx]->{'pid'} )
3044
2936
      {
3045
 
        drizzled_start($slave->[$idx],$tinfo->{'slave_opt'},
 
2937
        mysqld_start($slave->[$idx],$tinfo->{'slave_opt'},
3046
2938
                     $tinfo->{'slave_mi'});
3047
2939
 
3048
2940
      }
3052
2944
    $slave->[0]->{'running_slave_options'}= $tinfo;
3053
2945
  }
3054
2946
 
3055
 
  # Wait for drizzled's to start
3056
 
  foreach my $drizzled (@{$master},@{$slave})
 
2947
  # Wait for mysqld's to start
 
2948
  foreach my $mysqld (@{$master},@{$slave})
3057
2949
  {
3058
2950
 
3059
 
    next if !$drizzled->{'pid'};
 
2951
    next if !$mysqld->{'pid'};
3060
2952
 
3061
 
    if (drizzled_wait_started($drizzled))
 
2953
    if (mysqld_wait_started($mysqld))
3062
2954
    {
3063
2955
      # failed to start
3064
2956
      $tinfo->{'comment'}=
3065
 
        "Failed to start $drizzled->{'type'} drizzled $drizzled->{'idx'}";
 
2957
        "Failed to start $mysqld->{'type'} mysqld $mysqld->{'idx'}";
3066
2958
      return 1;
3067
2959
    }
3068
2960
  }
3081
2973
sub run_check_testcase ($$) {
3082
2974
 
3083
2975
  my $mode=     shift;
3084
 
  my $drizzled=   shift;
 
2976
  my $mysqld=   shift;
3085
2977
 
3086
 
  my $name= "check-" . $drizzled->{'type'} . $drizzled->{'idx'};
 
2978
  my $name= "check-" . $mysqld->{'type'} . $mysqld->{'idx'};
3087
2979
 
3088
2980
  my $args;
3089
 
  dtr_init_args(\$args);
3090
 
 
3091
 
  dtr_add_arg($args, "--no-defaults");
3092
 
  dtr_add_arg($args, "--silent");
3093
 
  dtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
3094
 
 
3095
 
  dtr_add_arg($args, "--port=%d", $drizzled->{'port'});
3096
 
  dtr_add_arg($args, "--database=test");
3097
 
  dtr_add_arg($args, "--user=%s", $opt_user);
3098
 
  dtr_add_arg($args, "--password=");
3099
 
 
3100
 
  dtr_add_arg($args, "-R");
3101
 
  dtr_add_arg($args, "$opt_vardir/tmp/$name.result");
 
2981
  mtr_init_args(\$args);
 
2982
 
 
2983
  mtr_add_arg($args, "--no-defaults");
 
2984
  mtr_add_arg($args, "--silent");
 
2985
  mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
 
2986
 
 
2987
  mtr_add_arg($args, "--port=%d", $mysqld->{'port'});
 
2988
  mtr_add_arg($args, "--database=test");
 
2989
  mtr_add_arg($args, "--user=%s", $opt_user);
 
2990
  mtr_add_arg($args, "--password=");
 
2991
 
 
2992
  mtr_add_arg($args, "-R");
 
2993
  mtr_add_arg($args, "$opt_vardir/tmp/$name.result");
3102
2994
 
3103
2995
  if ( $mode eq "before" )
3104
2996
  {
3105
 
    dtr_add_arg($args, "--record");
 
2997
    mtr_add_arg($args, "--record");
3106
2998
  }
3107
2999
 
3108
3000
  if ( $opt_testdir )
3109
3001
  {
3110
 
    dtr_add_arg($args, "--testdir=%s", $opt_testdir);
 
3002
    mtr_add_arg($args, "--testdir=%s", $opt_testdir);
3111
3003
  }
3112
3004
 
3113
 
  my $res = dtr_run_test($exe_drizzletest,$args,
 
3005
  my $res = mtr_run_test($exe_drizzletest,$args,
3114
3006
                "include/check-testcase.test", "", "", "");
3115
3007
 
3116
3008
  if ( $res == 1  and $mode eq "after")
3117
3009
  {
3118
 
    dtr_run("diff",["-u",
 
3010
    mtr_run("diff",["-u",
3119
3011
                    "$opt_vardir/tmp/$name.result",
3120
3012
                    "$opt_vardir/tmp/$name.reject"],
3121
3013
            "", "", "", "");
3122
3014
  }
3123
3015
  elsif ( $res )
3124
3016
  {
3125
 
    dtr_error("Could not execute 'check-testcase' $mode testcase");
 
3017
    mtr_error("Could not execute 'check-testcase' $mode testcase");
3126
3018
  }
3127
3019
  return $res;
3128
3020
}
3137
3029
  my $args;
3138
3030
 
3139
3031
  {
3140
 
    drizzled_start($master->[0],[],[]);
 
3032
    mysqld_start($master->[0],[],[]);
3141
3033
    if ( ! $master->[0]->{'pid'} )
3142
3034
    {
3143
 
      dtr_error("Can't start the drizzled server");
 
3035
      mtr_error("Can't start the mysqld server");
3144
3036
    }
3145
 
    drizzled_wait_started($master->[0]);
 
3037
    mysqld_wait_started($master->[0]);
3146
3038
  }
3147
3039
 
3148
3040
  my $tinfo = {};
3149
3041
  $tinfo->{'name'} = 'report features';
3150
3042
  $tinfo->{'result_file'} = undef;
3151
 
  $tinfo->{'component_id'} = 'drizzled';
 
3043
  $tinfo->{'component_id'} = 'mysqld';
3152
3044
  $tinfo->{'path'} = 'include/report-features.test';
3153
3045
  $tinfo->{'timezone'}=  "GMT-3";
3154
3046
  $tinfo->{'slave_num'} = 0;
3169
3061
  my $exe= $exe_drizzletest;
3170
3062
  my $args;
3171
3063
 
3172
 
  dtr_init_args(\$args);
 
3064
  mtr_init_args(\$args);
3173
3065
 
3174
 
  dtr_add_arg($args, "--no-defaults");
3175
 
  dtr_add_arg($args, "--silent");
3176
 
  dtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
3177
 
  dtr_add_arg($args, "--logdir=%s/log", $opt_vardir);
 
3066
  mtr_add_arg($args, "--no-defaults");
 
3067
  mtr_add_arg($args, "--silent");
 
3068
  mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
 
3069
  mtr_add_arg($args, "--logdir=%s/log", $opt_vardir);
3178
3070
 
3179
3071
  # Log line number and time  for each line in .test file
3180
 
  dtr_add_arg($args, "--mark-progress")
 
3072
  mtr_add_arg($args, "--mark-progress")
3181
3073
    if $opt_mark_progress;
3182
3074
 
3183
3075
  {
3184
 
    dtr_add_arg($args, "--port=%d", $master->[0]->{'port'});
3185
 
    dtr_add_arg($args, "--database=test");
3186
 
    dtr_add_arg($args, "--user=%s", $opt_user);
3187
 
    dtr_add_arg($args, "--password=");
 
3076
    mtr_add_arg($args, "--port=%d", $master->[0]->{'port'});
 
3077
    mtr_add_arg($args, "--database=test");
 
3078
    mtr_add_arg($args, "--user=%s", $opt_user);
 
3079
    mtr_add_arg($args, "--password=");
3188
3080
  }
3189
3081
 
3190
3082
  if ( $opt_strace_client )
3191
3083
  {
3192
3084
    $exe=  "strace";            # FIXME there are ktrace, ....
3193
 
    dtr_add_arg($args, "-o");
3194
 
    dtr_add_arg($args, "%s/log/drizzletest.strace", $opt_vardir);
3195
 
    dtr_add_arg($args, "$exe_drizzletest");
 
3085
    mtr_add_arg($args, "-o");
 
3086
    mtr_add_arg($args, "%s/log/drizzletest.strace", $opt_vardir);
 
3087
    mtr_add_arg($args, "$exe_drizzletest");
3196
3088
  }
3197
3089
 
3198
3090
  if ( $opt_timer )
3199
3091
  {
3200
 
    dtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir);
 
3092
    mtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir);
3201
3093
  }
3202
3094
 
3203
3095
  if ( $opt_compress )
3204
3096
  {
3205
 
    dtr_add_arg($args, "--compress");
 
3097
    mtr_add_arg($args, "--compress");
3206
3098
  }
3207
3099
 
3208
3100
  if ( $opt_sleep )
3209
3101
  {
3210
 
    dtr_add_arg($args, "--sleep=%d", $opt_sleep);
 
3102
    mtr_add_arg($args, "--sleep=%d", $opt_sleep);
3211
3103
  }
3212
3104
 
3213
3105
  if ( $opt_debug )
3214
3106
  {
3215
 
    dtr_add_arg($args, "--debug=d:t:A,%s/log/drizzletest.trace",
 
3107
    mtr_add_arg($args, "--debug=d:t:A,%s/log/drizzletest.trace",
3216
3108
                $path_vardir_trace);
3217
3109
  }
3218
3110
 
3219
3111
  if ( $opt_testdir )
3220
3112
  {
3221
 
    dtr_add_arg($args, "--testdir=%s", $opt_testdir);
 
3113
    mtr_add_arg($args, "--testdir=%s", $opt_testdir);
3222
3114
  }
3223
3115
 
3224
3116
 
3226
3118
  # export DRIZZLE_TEST variable containing <path>/drizzletest <args>
3227
3119
  # ----------------------------------------------------------------------
3228
3120
  $ENV{'DRIZZLE_TEST'}=
3229
 
    dtr_native_path($exe_drizzletest) . " " . join(" ", @$args);
 
3121
    mtr_native_path($exe_drizzletest) . " " . join(" ", @$args);
3230
3122
 
3231
3123
  # ----------------------------------------------------------------------
3232
3124
  # Add arguments that should not go into the DRIZZLE_TEST env var
3238
3130
    # We do this here, since we do not want to Valgrind the nested invocations
3239
3131
    # of drizzletest; that would mess up the stderr output causing test failure.
3240
3132
    my @args_saved = @$args;
3241
 
    dtr_init_args(\$args);
 
3133
    mtr_init_args(\$args);
3242
3134
    valgrind_arguments($args, \$exe);
3243
 
    dtr_add_arg($args, "%s", $_) for @args_saved;
 
3135
    mtr_add_arg($args, "%s", $_) for @args_saved;
3244
3136
  }
3245
3137
 
3246
 
  dtr_add_arg($args, "--test-file=%s", $tinfo->{'path'});
 
3138
  mtr_add_arg($args, "--test-file=%s", $tinfo->{'path'});
3247
3139
 
3248
3140
  # Number of lines of resut to include in failure report
3249
 
  dtr_add_arg($args, "--tail-lines=20");
 
3141
  mtr_add_arg($args, "--tail-lines=20");
3250
3142
 
3251
3143
  if ( defined $tinfo->{'result_file'} ) {
3252
 
    dtr_add_arg($args, "--result-file=%s", $tinfo->{'result_file'});
 
3144
    mtr_add_arg($args, "--result-file=%s", $tinfo->{'result_file'});
3253
3145
  }
3254
3146
 
3255
3147
  if ( $opt_record )
3256
3148
  {
3257
 
    dtr_add_arg($args, "--record");
 
3149
    mtr_add_arg($args, "--record");
3258
3150
  }
3259
3151
 
3260
3152
  if ( $opt_client_gdb )
3272
3164
 
3273
3165
  if ( $opt_check_testcases )
3274
3166
  {
3275
 
    foreach my $drizzled (@{$master}, @{$slave})
 
3167
    foreach my $mysqld (@{$master}, @{$slave})
3276
3168
    {
3277
 
      if ($drizzled->{'pid'})
 
3169
      if ($mysqld->{'pid'})
3278
3170
      {
3279
 
        run_check_testcase("before", $drizzled);
 
3171
        run_check_testcase("before", $mysqld);
3280
3172
      }
3281
3173
    }
3282
3174
  }
3283
3175
 
3284
 
  my $res = dtr_run_test($exe,$args,"","",$path_timefile,"");
 
3176
  my $res = mtr_run_test($exe,$args,"","",$path_timefile,"");
3285
3177
 
3286
3178
  if ( $opt_check_testcases )
3287
3179
  {
3288
 
    foreach my $drizzled (@{$master}, @{$slave})
 
3180
    foreach my $mysqld (@{$master}, @{$slave})
3289
3181
    {
3290
 
      if ($drizzled->{'pid'})
 
3182
      if ($mysqld->{'pid'})
3291
3183
      {
3292
 
        if (run_check_testcase("after", $drizzled))
 
3184
        if (run_check_testcase("after", $mysqld))
3293
3185
        {
3294
3186
          # Check failed, mark the test case with that info
3295
3187
          $tinfo->{'check_testcase_failed'}= 1;
3319
3211
  if ( $type eq "client" )
3320
3212
  {
3321
3213
    # write init file for client
3322
 
    dtr_tofile($dbx_init_file,
 
3214
    mtr_tofile($dbx_init_file,
3323
3215
               "runargs $str\n" .
3324
3216
               "run\n");
3325
3217
  }
3326
3218
  else
3327
3219
  {
3328
3220
    # write init file for drizzled
3329
 
    dtr_tofile($dbx_init_file,
3330
 
               "stop in __1cIdrizzledLparse6Fpn0AHSession_pkcI_v_\n" .
 
3221
    mtr_tofile($dbx_init_file,
 
3222
               "stop in mysql_parse\n" .
3331
3223
               "runargs $str\n" .
3332
3224
               "run\n" .
3333
3225
               "\n");
3344
3236
  }
3345
3237
 
3346
3238
  $$args= [];
3347
 
  dtr_add_arg($$args, "-title");
3348
 
  dtr_add_arg($$args, "$type");
3349
 
  dtr_add_arg($$args, "-e");
 
3239
  mtr_add_arg($$args, "-title");
 
3240
  mtr_add_arg($$args, "$type");
 
3241
  mtr_add_arg($$args, "-e");
3350
3242
 
3351
 
  dtr_add_arg($$args, "dbx");
3352
 
  dtr_add_arg($$args, "-c");
3353
 
  dtr_add_arg($$args, "source $dbx_init_file");
3354
 
  dtr_add_arg($$args, "$$exe");
 
3243
  mtr_add_arg($$args, "dbx");
 
3244
  mtr_add_arg($$args, "-c");
 
3245
  mtr_add_arg($$args, "source $dbx_init_file");
 
3246
  mtr_add_arg($$args, "$$exe");
3355
3247
 
3356
3248
  $$exe= "xterm";
3357
3249
}
3363
3255
  my $args= shift;
3364
3256
  my $exe=  shift;
3365
3257
  my $type= shift;
3366
 
  # We add needed, extra lines to gdbinit on OS X
3367
 
  my $extra_gdb_init = '' ;
3368
 
  if ($^O eq 'darwin')
3369
 
  {
3370
 
    $extra_gdb_init= "set env DYLD_INSERT_LIBRARIES /usr/lib/libgmalloc.dylib\n".
3371
 
                 "set env MallocStackLogging 1\n".
3372
 
                 "set env MallocScribble 1\n".
3373
 
                 "set env MallocPreScribble 1\n".
3374
 
                 "set env MallocStackLogging 1\n".
3375
 
                 "set env MallocStackLoggingNoCompact 1\n".
3376
 
                 "set env MallocGuardEdges 1\n" ;
3377
 
  }
3378
3258
 
3379
3259
  # Write $args to gdb init file
3380
3260
  my $str= join(" ", @$$args);
3386
3266
  if ( $type eq "client" )
3387
3267
  {
3388
3268
    # write init file for client
3389
 
    dtr_tofile($gdb_init_file,
 
3269
    mtr_tofile($gdb_init_file,
3390
3270
               "set args $str\n" .
3391
 
               "$extra_gdb_init" .
3392
3271
               "break main\n");
3393
3272
  }
3394
3273
  else
3395
3274
  {
3396
 
    # write init file for drizzled
3397
 
    dtr_tofile($gdb_init_file,
 
3275
    # write init file for mysqld
 
3276
    mtr_tofile($gdb_init_file,
3398
3277
               "set args $str\n" .
3399
 
               "$extra_gdb_init" .
3400
 
               "set breakpoint pending on\n" .
3401
 
               "break drizzled::parse\n" .
 
3278
               "break mysql_parse\n" .
3402
3279
               "commands 1\n" .
3403
3280
               "disable 1\n" .
3404
3281
               "end\n" .
3405
 
               "set breakpoint pending off\n" .
3406
3282
               "run");
3407
3283
  }
3408
3284
 
3409
3285
  if ( $opt_manual_gdb )
3410
3286
  {
3411
3287
     print "\nTo start gdb for $type, type in another window:\n";
3412
 
     print "$glob_drizzle_test_dir/../libtool --mode=execute gdb -cd $glob_drizzle_test_dir -x $gdb_init_file $$exe\n";
 
3288
     print "gdb -cd $glob_mysql_test_dir -x $gdb_init_file $$exe\n";
3413
3289
 
3414
3290
     # Indicate the exe should not be started
3415
3291
     $$exe= undef;
3417
3293
  }
3418
3294
 
3419
3295
  $$args= [];
3420
 
  dtr_add_arg($$args, "-title");
3421
 
  dtr_add_arg($$args, "$type");
3422
 
  dtr_add_arg($$args, "-e");
 
3296
  mtr_add_arg($$args, "-title");
 
3297
  mtr_add_arg($$args, "$type");
 
3298
  mtr_add_arg($$args, "-e");
3423
3299
 
3424
3300
  if ( $exe_libtool )
3425
3301
  {
3426
 
    dtr_add_arg($$args, $exe_libtool);
3427
 
    dtr_add_arg($$args, "--mode=execute");
 
3302
    mtr_add_arg($$args, $exe_libtool);
 
3303
    mtr_add_arg($$args, "--mode=execute");
3428
3304
  }
3429
3305
 
3430
 
  dtr_add_arg($$args, "gdb");
3431
 
  dtr_add_arg($$args, "-x");
3432
 
  dtr_add_arg($$args, "$gdb_init_file");
3433
 
  dtr_add_arg($$args, "$$exe");
 
3306
  mtr_add_arg($$args, "gdb");
 
3307
  mtr_add_arg($$args, "-x");
 
3308
  mtr_add_arg($$args, "$gdb_init_file");
 
3309
  mtr_add_arg($$args, "$$exe");
3434
3310
 
3435
3311
  $$exe= "xterm";
3436
3312
}
3454
3330
  if ( $type eq "client" )
3455
3331
  {
3456
3332
    # write init file for client
3457
 
    dtr_tofile($gdb_init_file,
 
3333
    mtr_tofile($gdb_init_file,
3458
3334
               "set args $str\n" .
3459
3335
               "break main\n");
3460
3336
  }
3461
3337
  else
3462
3338
  {
3463
 
    # write init file for drizzled
3464
 
    dtr_tofile($gdb_init_file,
 
3339
    # write init file for mysqld
 
3340
    mtr_tofile($gdb_init_file,
3465
3341
               "file $$exe\n" .
3466
3342
               "set args $str\n" .
3467
 
               "break drizzled::parse\n" .
 
3343
               "break mysql_parse\n" .
3468
3344
               "commands 1\n" .
3469
3345
               "disable 1\n" .
3470
3346
               "end");
3473
3349
  if ( $opt_manual_ddd )
3474
3350
  {
3475
3351
     print "\nTo start ddd for $type, type in another window:\n";
3476
 
     print "ddd -cd $glob_drizzle_test_dir -x $gdb_init_file $$exe\n";
 
3352
     print "ddd -cd $glob_mysql_test_dir -x $gdb_init_file $$exe\n";
3477
3353
 
3478
3354
     # Indicate the exe should not be started
3479
3355
     $$exe= undef;
3485
3361
  if ( $exe_libtool )
3486
3362
  {
3487
3363
    $$exe= $exe_libtool;
3488
 
    dtr_add_arg($$args, "--mode=execute");
3489
 
    dtr_add_arg($$args, "ddd");
 
3364
    mtr_add_arg($$args, "--mode=execute");
 
3365
    mtr_add_arg($$args, "ddd");
3490
3366
  }
3491
3367
  else
3492
3368
  {
3493
3369
    $$exe= "ddd";
3494
3370
  }
3495
 
  dtr_add_arg($$args, "--command=$gdb_init_file");
3496
 
  dtr_add_arg($$args, "$save_exe");
 
3371
  mtr_add_arg($$args, "--command=$gdb_init_file");
 
3372
  mtr_add_arg($$args, "$save_exe");
3497
3373
}
3498
3374
 
3499
3375
 
3531
3407
#  }
3532
3408
  else
3533
3409
  {
3534
 
    dtr_error("Unknown argument \"$debugger\" passed to --debugger");
 
3410
    mtr_error("Unknown argument \"$debugger\" passed to --debugger");
3535
3411
  }
3536
3412
}
3537
3413
 
3545
3421
 
3546
3422
  if ( $opt_callgrind)
3547
3423
  {
3548
 
    dtr_add_arg($args, "--tool=callgrind");
3549
 
  }
3550
 
  elsif ($opt_massif)
3551
 
  {
3552
 
    dtr_add_arg($args, "--tool=massif");
 
3424
    mtr_add_arg($args, "--tool=callgrind");
 
3425
    mtr_add_arg($args, "--base=$opt_vardir/log");
3553
3426
  }
3554
3427
  else
3555
3428
  {
3556
 
    dtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
3557
 
    dtr_add_arg($args, "--leak-check=yes");
3558
 
    dtr_add_arg($args, "--num-callers=16");
3559
 
    dtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_drizzle_test_dir)
3560
 
      if -f "$glob_drizzle_test_dir/valgrind.supp";
 
3429
    mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
 
3430
    mtr_add_arg($args, "--leak-check=yes");
 
3431
    mtr_add_arg($args, "--num-callers=16");
 
3432
    mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir)
 
3433
      if -f "$glob_mysql_test_dir/valgrind.supp";
3561
3434
  }
3562
3435
 
3563
3436
  # Add valgrind options, can be overriden by user
3564
 
  dtr_add_arg($args, '%s', $_) for (@valgrind_args);
 
3437
  mtr_add_arg($args, '%s', $_) for (@valgrind_args);
3565
3438
 
3566
 
  dtr_add_arg($args, $$exe);
 
3439
  mtr_add_arg($args, $$exe);
3567
3440
 
3568
3441
  $$exe= $opt_valgrind_path || "valgrind";
3569
3442
 
3577
3450
}
3578
3451
 
3579
3452
 
3580
 
sub drizzled_wait_started($){
3581
 
  my $drizzled= shift;
 
3453
sub mysqld_wait_started($){
 
3454
  my $mysqld= shift;
3582
3455
 
3583
 
  if (sleep_until_file_created($drizzled->{'path_pid'},
3584
 
            $drizzled->{'start_timeout'},
3585
 
            $drizzled->{'pid'}) == 0)
 
3456
  if (sleep_until_file_created($mysqld->{'path_pid'},
 
3457
            $mysqld->{'start_timeout'},
 
3458
            $mysqld->{'pid'}) == 0)
3586
3459
  {
3587
3460
    # Failed to wait for pid file
3588
3461
    return 1;
3590
3463
 
3591
3464
  # Get the "real pid" of the process, it will be used for killing
3592
3465
  # the process in ActiveState's perl on windows
3593
 
  $drizzled->{'real_pid'}= dtr_get_pid_from_file($drizzled->{'path_pid'});
 
3466
  $mysqld->{'real_pid'}= mtr_get_pid_from_file($mysqld->{'path_pid'});
3594
3467
 
3595
3468
  return 0;
3596
3469
}
3660
3533
                        using a builtin list of standard locations
3661
3534
                        for tmpfs (/dev/shm)
3662
3535
                        The option can also be set using environment
3663
 
                        variable DTR_MEM=[DIR]
 
3536
                        variable MTR_MEM=[DIR]
3664
3537
 
3665
3538
Options to control what test suites or cases to run
3666
3539
 
3676
3549
                        list of suite names.
3677
3550
                        The default is: "$opt_suites_default"
3678
3551
  skip-rpl              Skip the replication test cases.
3679
 
  combination="ARG1 .. ARG2" Specify a set of "drizzled" arguments for one
 
3552
  combination="ARG1 .. ARG2" Specify a set of "mysqld" arguments for one
3680
3553
                        combination.
3681
3554
  skip-combination      Skip any combination options and combinations files
3682
3555
  repeat-test=n         How many times to repeat each test (default: 1)
3685
3558
 
3686
3559
  master_port=PORT      Specify the port number used by the first master
3687
3560
  slave_port=PORT       Specify the port number used by the first slave
3688
 
  dtr-build-thread=#    Specify unique collection of ports. Can also be set by
3689
 
                        setting the environment variable DTR_BUILD_THREAD.
 
3561
  mtr-build-thread=#    Specify unique collection of ports. Can also be set by
 
3562
                        setting the environment variable MTR_BUILD_THREAD.
3690
3563
 
3691
3564
Options for test case authoring
3692
3565
 
3696
3569
 
3697
3570
Options that pass on options
3698
3571
 
3699
 
  drizzled=ARGS           Specify additional arguments to "drizzled"
 
3572
  mysqld=ARGS           Specify additional arguments to "mysqld"
3700
3573
 
3701
3574
Options to run test on running server
3702
3575
 
3708
3581
  client-ddd            Start drizzletest client in ddd
3709
3582
  client-debugger=NAME  Start drizzletest in the selected debugger
3710
3583
  client-gdb            Start drizzletest client in gdb
3711
 
  ddd                   Start drizzled in ddd
 
3584
  ddd                   Start mysqld in ddd
3712
3585
  debug                 Dump trace output for all servers and client programs
3713
 
  debugger=NAME         Start drizzled in the selected debugger
3714
 
  gdb                   Start the drizzled(s) in gdb
3715
 
  manual-debug          Let user manually start drizzled in debugger, before
 
3586
  debugger=NAME         Start mysqld in the selected debugger
 
3587
  gdb                   Start the mysqld(s) in gdb
 
3588
  manual-debug          Let user manually start mysqld in debugger, before
3716
3589
                        running test(s)
3717
 
  manual-gdb            Let user manually start drizzled in gdb, before running
3718
 
                        test(s)
3719
 
  manual-ddd            Let user manually start drizzled in ddd, before running
3720
 
                        test(s)
3721
 
  master-binary=PATH    Specify the master "drizzled" to use
3722
 
  slave-binary=PATH     Specify the slave "drizzled" to use
 
3590
  manual-gdb            Let user manually start mysqld in gdb, before running
 
3591
                        test(s)
 
3592
  manual-ddd            Let user manually start mysqld in ddd, before running
 
3593
                        test(s)
 
3594
  master-binary=PATH    Specify the master "mysqld" to use
 
3595
  slave-binary=PATH     Specify the slave "mysqld" to use
3723
3596
  strace-client         Create strace output for drizzletest client
3724
3597
  max-save-core         Limit the number of core files saved (to avoid filling
3725
3598
                        up disks for heavily crashing server). Defaults to
3729
3602
 
3730
3603
  gcov                  FIXME
3731
3604
  gprof                 See online documentation on how to use it.
3732
 
  valgrind              Run the "drizzletest" and "drizzled" executables using
 
3605
  valgrind              Run the "drizzletest" and "mysqld" executables using
3733
3606
                        valgrind with default options
3734
3607
  valgrind-all          Synonym for --valgrind
3735
 
  valgrind-drizzleslap  Run "drizzleslap" with valgrind.
3736
 
  valgrind-drizzletest  Run the "drizzletest" and "drizzle_client_test" executable
 
3608
  valgrind-drizzletest    Run the "drizzletest" and "drizzle_client_test" executable
3737
3609
                        with valgrind
3738
 
  valgrind-drizzled       Run the "drizzled" executable with valgrind
 
3610
  valgrind-mysqld       Run the "mysqld" executable with valgrind
3739
3611
  valgrind-options=ARGS Deprecated, use --valgrind-option
3740
3612
  valgrind-option=ARGS  Option to give valgrind, replaces default option(s),
3741
3613
                        can be specified more then once
3742
3614
  valgrind-path=[EXE]   Path to the valgrind executable
3743
3615
  callgrind             Instruct valgrind to use callgrind
3744
 
  massif                Instruct valgrind to use massif
3745
3616
 
3746
3617
Misc options
3747
3618
 
3759
3630
 
3760
3631
  testcase-timeout=MINUTES Max test case run time (default $default_testcase_timeout)
3761
3632
  suite-timeout=MINUTES Max test suite run time (default $default_suite_timeout)
3762
 
  warnings | log-warnings Pass --log-warnings to drizzled
 
3633
  warnings | log-warnings Pass --log-warnings to mysqld
3763
3634
 
3764
3635
  sleep=SECONDS         Passed to drizzletest, will be used as fixed sleep time
3765
3636
 
3766
3637
HERE
3767
 
  dtr_exit(1);
 
3638
  mtr_exit(1);
3768
3639
 
3769
3640
}