~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/test-run.pl

  • Committer: Stewart Smith
  • Date: 2009-06-16 03:43:00 UTC
  • mto: This revision was merged to the branch mainline in revision 1094.
  • Revision ID: stewart@flamingspork.com-20090616034300-bamg5dsfaknwi05b
fix join_outer for MyISAM as temp only: 1x open table twice, 1x CREATE TEMP

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