~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/test-run.pl

  • Committer: Lee Bieber
  • Date: 2009-10-20 20:39:01 UTC
  • mto: This revision was merged to the branch mainline in revision 1191.
  • Revision ID: lbieber@dhcp-umpk18-111-94.sfbay.sun.com-20091020203901-wmeq850fgv7iiqff
Add test case for MySQL BUG #42742: crash in setup_sj_materialization, Copy_field::set
If a semi-join strategy covers certain [first_table; last_table] range in join order, do reset the sj_strategy member for all tables within the range, except the first one.  Failure to do so caused EXPLAIN/execution code to try applying two strategies at once which would cause all kinds of undesired effects. 

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