~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#!/usr/bin/perl
2
# -*- cperl -*-
3
608 by Brian Aker
Adding snowman test (plus a dead variable removal).
4
use utf8;
5
1 by brian
clean slate
6
#
7
##############################################################################
8
#
77.1.40 by Monty Taylor
More naming changes.
9
#  drizzle-test-run.pl
1 by brian
clean slate
10
#
11
#  Tool used for executing a suite of .test file
12
#
370.1.1 by arjen at com
Initial mods for making all tests work again. Some tests adapted+added.
13
#  For now, see the "MySQL Test framework manual" for more information
14
#  http://dev.mysql.com/doc/mysqltest/en/index.html
15
#  (as the Drizzle test environment is currently still fairly similar)
1 by brian
clean slate
16
#
17
#  Please keep the test framework tools identical in all versions!
18
#
19
##############################################################################
20
#
21
# Coding style directions for this perl script
22
#
23
#   - To make this Perl script easy to alter even for those that not
24
#     code Perl that often, keeep the coding style as close as possible to
25
#     the C/C++ MySQL coding standard.
26
#
27
#   - All lists of arguments to send to commands are Perl lists/arrays,
28
#     not strings we append args to. Within reason, most string
29
#     concatenation for arguments should be avoided.
30
#
31
#   - Functions defined in the main program are not to be prefixed,
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
34
#     the main program, but are put into separate files to avoid
35
#     clutter, may be without prefix.
36
#
37
#   - All stat/opendir/-f/ is to be kept in collect_test_cases(). It
38
#     will create a struct that the rest of the program can use to get
39
#     the information. This separates the "find information" from the
40
#     "do the work" and makes the program more easy to maintain.
41
#
42
#   - The rule when it comes to the logic of this program is
43
#
44
#       command_line_setup() - is to handle the logic between flags
45
#       collect_test_cases() - is to do its best to select what tests
46
#                              to run, dig out options, if needs restart etc.
47
#       run_testcase()       - is to run a single testcase, and follow the
48
#                              logic set in both above. No, or rare file
49
#                              system operations. If a test seems complex,
50
#                              it should probably not be here.
51
#
52
# A nice way to trace the execution of this script while debugging
53
# is to use the Devel::Trace package found at
54
# "http://www.plover.com/~mjd/perl/Trace/" and run this script like
77.1.40 by Monty Taylor
More naming changes.
55
# "perl -d:Trace drizzle-test-run.pl"
1 by brian
clean slate
56
#
57
58
59
use lib "lib/";
60
61
$Devel::Trace::TRACE= 0;       # Don't trace boring init stuff
62
63
#require 5.6.1;
64
use File::Path;
65
use File::Basename;
66
use File::Copy;
67
use File::Temp qw /tempdir/;
685.1.25 by Monty Taylor
Fixed absolute path generation for real. Sigh.
68
use File::Spec::Functions qw /splitdir catpath catdir
69
                              updir curdir splitpath rel2abs/;
1 by brian
clean slate
70
use Cwd;
71
use Getopt::Long;
72
use IO::Socket;
73
use IO::Socket::INET;
74
use strict;
75
use warnings;
76
77
select(STDOUT);
78
$| = 1; # Automatically flush STDOUT
79
236.1.22 by Monty Taylor
A couple of changes to move the actual test code to the tests dir and attempt
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";
1 by brian
clean slate
91
92
$Devel::Trace::TRACE= 1;
93
94
##############################################################################
95
#
96
#  Default settings
97
#
98
##############################################################################
99
100
# Misc global variables
101
our $mysql_version_id;
102
our $glob_mysql_test_dir=         undef;
103
our $glob_mysql_bench_dir=        undef;
104
our $glob_scriptname=             undef;
105
our $glob_timers=                 undef;
106
our @glob_test_mode;
107
685.1.17 by Monty Taylor
Makde mtr work in VPATH.
108
our $glob_builddir;
109
1 by brian
clean slate
110
our $glob_basedir;
111
112
our $path_client_bindir;
113
our $path_timefile;
114
our $path_snapshot;
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
115
our $path_drizzletest_log;
1 by brian
clean slate
116
our $path_current_test_log;
117
our $path_my_basedir;
118
119
our $opt_vardir;                 # A path but set directly on cmd line
120
our $path_vardir_trace;          # unix formatted opt_vardir for trace files
121
our $opt_tmpdir;                 # A path but set directly on cmd line
685.1.13 by Monty Taylor
Attempt at some VPATH support for test suite.
122
our $opt_testdir;
1 by brian
clean slate
123
1101.1.34 by Monty Taylor
Made subunit output optional.
124
our $opt_subunit;
1 by brian
clean slate
125
126
our $default_vardir;
127
128
our $opt_usage;
129
our $opt_suites;
798.2.11 by Brian Aker
Factor test-run for binlog removal
130
our $opt_suites_default= "main"; # Default suites to run
1 by brian
clean slate
131
our $opt_script_debug= 0;  # Script debugging, enable with --script-debug
132
our $opt_verbose= 0;  # Verbose output, enable with --verbose
133
974.1.1 by Stewart Smith
add repeat-test=n option to test-run.pl to repeat a test n times
134
our $opt_repeat_test= 1;
135
1 by brian
clean slate
136
our $exe_master_mysqld;
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
137
our $exe_drizzle;
138
our $exe_drizzle_client_test;
1 by brian
clean slate
139
our $exe_bug25714;
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
140
our $exe_drizzled;
141
our $exe_drizzledump;
373.1.9 by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING.
142
our $exe_drizzleslap;
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
143
our $exe_drizzleimport;
144
our $exe_drizzle_fix_system_tables;
145
our $exe_drizzletest;
1 by brian
clean slate
146
our $exe_slave_mysqld;
147
our $exe_my_print_defaults;
148
our $exe_perror;
149
our $lib_udf_example;
150
our $lib_example_plugin;
151
our $exe_libtool;
152
153
our $opt_bench= 0;
154
our $opt_small_bench= 0;
155
156
our @opt_combinations;
157
our $opt_skip_combination;
158
159
our @opt_extra_mysqld_opt;
160
161
our $opt_compress;
162
163
our $opt_debug;
164
our $opt_do_test;
165
our @opt_cases;                  # The test cases names in argv
496.1.1 by Paul McCullagh
Added --engine option to drizzle-test-run (default innodb)
166
our $opt_engine;
1 by brian
clean slate
167
168
our $opt_extern= 0;
169
our $opt_socket;
170
171
our $opt_fast;
172
our $opt_force;
173
our $opt_reorder= 0;
174
our $opt_enable_disabled;
175
our $opt_mem= $ENV{'MTR_MEM'};
176
177
our $opt_gcov;
178
our $opt_gcov_err;
179
our $opt_gcov_msg;
180
181
our $glob_debugger= 0;
182
our $opt_gdb;
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
183
our $opt_dbx;
1 by brian
clean slate
184
our $opt_client_gdb;
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
185
our $opt_client_dbx;
186
our $opt_dbx_gdb;
1 by brian
clean slate
187
our $opt_ddd;
188
our $opt_client_ddd;
189
our $opt_manual_gdb;
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
190
our $opt_manual_dbx;
1 by brian
clean slate
191
our $opt_manual_ddd;
192
our $opt_manual_debug;
713.1.10 by Monty Taylor
Fixed default port range in test-run.pl.
193
# Magic number -69.4 results in traditional test ports starting from 9306.
194
our $opt_mtr_build_thread=-69.4;
1 by brian
clean slate
195
our $opt_debugger;
196
our $opt_client_debugger;
197
198
our $opt_gprof;
199
our $opt_gprof_dir;
200
our $opt_gprof_master;
201
our $opt_gprof_slave;
202
203
our $master;
204
our $slave;
205
our $clusters;
206
207
our $opt_master_myport;
208
our $opt_slave_myport;
1166.6.3 by Monty Taylor
Made the memcached_functions run in distcheck and VPATH builds. Also made it so that the ports don't step on each other.
209
our $opt_memc_myport;
1 by brian
clean slate
210
our $opt_record;
211
my $opt_report_features;
212
our $opt_check_testcases;
213
our $opt_mark_progress;
214
798.2.11 by Brian Aker
Factor test-run for binlog removal
215
our $opt_skip_rpl= 1;
1 by brian
clean slate
216
our $max_slave_num= 0;
217
our $max_master_num= 1;
218
our $use_innodb;
219
our $opt_skip_test;
220
221
our $opt_sleep;
222
223
our $opt_testcase_timeout;
224
our $opt_suite_timeout;
225
my  $default_testcase_timeout=     15; # 15 min max
226
my  $default_suite_timeout=       180; # 3 hours max
227
228
our $opt_start_and_exit;
229
our $opt_start_dirty;
230
our $opt_start_from;
231
232
our $opt_strace_client;
233
234
our $opt_timer= 1;
235
236
our $opt_user;
237
238
my $opt_valgrind= 0;
239
my $opt_valgrind_mysqld= 0;
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
240
my $opt_valgrind_drizzletest= 0;
1 by brian
clean slate
241
my @default_valgrind_args= ("--show-reachable=yes");
242
my @valgrind_args;
243
my $opt_valgrind_path;
244
my $opt_callgrind;
245
246
our $opt_stress=               "";
247
our $opt_stress_suite=     "main";
248
our $opt_stress_mode=    "random";
249
our $opt_stress_threads=        5;
250
our $opt_stress_test_count=     0;
251
our $opt_stress_loop_count=     0;
252
our $opt_stress_test_duration=  0;
253
our $opt_stress_init_file=     "";
254
our $opt_stress_test_file=     "";
255
256
our $opt_warnings;
257
258
our $path_sql_dir;
259
260
our @data_dir_lst;
261
262
our $used_default_engine;
263
our $debug_compiled_binaries;
264
265
our %mysqld_variables;
266
267
my $source_dist= 0;
268
269
our $opt_max_save_core= 5;
270
my $num_saved_cores= 0;  # Number of core files saved in vardir/log/ so far.
271
272
######################################################################
273
#
274
#  Function declarations
275
#
276
######################################################################
277
278
sub main ();
279
sub initial_setup ();
280
sub command_line_setup ();
281
sub set_mtr_build_thread_ports($);
282
sub datadir_list_setup ();
283
sub executable_setup ();
284
sub environment_setup ();
285
sub kill_running_servers ();
286
sub remove_stale_vardir ();
287
sub setup_vardir ();
288
sub check_running_as_root();
289
sub mysqld_wait_started($);
290
sub run_benchmarks ($);
291
sub initialize_servers ();
292
sub mysql_install_db ();
293
sub copy_install_db ($$);
294
sub run_testcase ($);
295
sub run_testcase_stop_servers ($$$);
296
sub run_testcase_start_servers ($);
297
sub run_testcase_check_skip_test($);
298
sub report_failure_and_restart ($);
299
sub do_before_start_master ($);
300
sub do_before_start_slave ($);
301
sub mysqld_start ($$$);
302
sub mysqld_arguments ($$$$);
303
sub stop_all_servers ();
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
304
sub run_drizzletest ($);
685.1.25 by Monty Taylor
Fixed absolute path generation for real. Sigh.
305
sub collapse_path ($);
1 by brian
clean slate
306
sub usage ($);
307
308
309
######################################################################
310
#
311
#  Main program
312
#
313
######################################################################
314
315
main();
316
317
sub main () {
318
319
  command_line_setup();
320
321
  check_debug_support(\%mysqld_variables);
322
323
  executable_setup();
324
325
  environment_setup();
326
  signal_setup();
327
328
  if ( $opt_gcov )
329
  {
330
    gcov_prepare();
331
  }
332
333
  if ( $opt_gprof )
334
  {
335
    gprof_prepare();
336
  }
337
338
  if ( $opt_bench )
339
  {
340
    initialize_servers();
341
    run_benchmarks(shift);      # Shift what? Extra arguments?!
342
  }
343
  elsif ( $opt_stress )
344
  {
345
    initialize_servers();
346
    run_stress_test()
347
  }
348
  else
349
  {
350
    # Figure out which tests we are going to run
351
    if (!$opt_suites)
352
    {
353
      $opt_suites= $opt_suites_default;
354
355
      # Check for any extra suites to enable based on the path name
88 by Brian Aker
More cleanup in mysql-test-run
356
      my %extra_suites= ();
1 by brian
clean slate
357
358
      foreach my $dir ( reverse splitdir($glob_basedir) )
359
      {
360
	my $extra_suite= $extra_suites{$dir};
361
	if (defined $extra_suite){
362
	  mtr_report("Found extra suite: $extra_suite");
363
	  $opt_suites= "$extra_suite,$opt_suites";
364
	  last;
365
	}
366
      }
367
    }
368
369
    my $tests= collect_test_cases($opt_suites);
370
371
    # Turn off NDB and other similar options if no tests use it
372
    foreach my $test (@$tests)
373
    {
374
      next if $test->{skip};
375
376
      if (!$opt_extern)
377
      {
378
	# Count max number of slaves used by a test case
379
	if ( $test->{slave_num} > $max_slave_num) {
380
	  $max_slave_num= $test->{slave_num};
381
	  mtr_error("Too many slaves") if $max_slave_num > 3;
382
	}
383
384
	# Count max number of masters used by a test case
385
	if ( $test->{master_num} > $max_master_num) {
386
	  $max_master_num= $test->{master_num};
387
	  mtr_error("Too many masters") if $max_master_num > 2;
388
	  mtr_error("Too few masters") if $max_master_num < 1;
389
	}
390
      }
391
      $use_innodb||= $test->{'innodb_test'};
392
    }
393
394
    initialize_servers();
395
396
    if ( $opt_report_features ) {
397
      run_report_features();
398
    }
399
400
    run_tests($tests);
401
  }
402
403
  mtr_exit(0);
404
}
405
406
##############################################################################
407
#
408
#  Default settings
409
#
410
##############################################################################
411
412
#
413
# When an option is no longer used by this program, it must be explicitly
414
# ignored or else it will be passed through to mysqld.  GetOptions will call
415
# this subroutine once for each such option on the command line.  See
416
# Getopt::Long documentation.
417
#
418
419
sub warn_about_removed_option {
420
  my ($option, $value, $hash_value) = @_;
421
422
  warn "WARNING: This option is no longer used, and is ignored: --$option\n";
423
}
424
425
sub command_line_setup () {
426
427
  # These are defaults for things that are set on the command line
428
429
  my $opt_comment;
430
431
  # If so requested, we try to avail ourselves of a unique build thread number.
432
  if ( $ENV{'MTR_BUILD_THREAD'} ) {
433
    if ( lc($ENV{'MTR_BUILD_THREAD'}) eq 'auto' ) {
434
      print "Requesting build thread... ";
435
      $ENV{'MTR_BUILD_THREAD'} = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299);
436
      print "got ".$ENV{'MTR_BUILD_THREAD'}."\n";
437
    }
438
  }
439
440
  if ( $ENV{'MTR_BUILD_THREAD'} )
441
  {
442
    set_mtr_build_thread_ports($ENV{'MTR_BUILD_THREAD'});
443
  }
444
445
  # This is needed for test log evaluation in "gen-build-status-page"
446
  # in all cases where the calling tool does not log the commands
447
  # directly before it executes them, like "make test-force-pl" in RPM builds.
448
  print "Logging: $0 ", join(" ", @ARGV), "\n";
449
450
  # Read the command line
451
  # Note: Keep list, and the order, in sync with usage at end of this file
452
453
  # Options that are no longer used must still be processed, because all
454
  # unprocessed options are passed directly to mysqld.  The user will be
455
  # warned that the option is being ignored.
456
  #
457
  # Put the complete option string here.  For example, to remove the --suite
458
  # option, remove it from GetOptions() below and put 'suite|suites=s' here.
459
  my @removed_options = (
460
    'skip-im',  # WL#4085 "Discontinue the instance manager"
461
  );
462
463
  Getopt::Long::Configure("pass_through");
464
  GetOptions(
465
             # Control what engine/variation to run
466
             'compress'                 => \$opt_compress,
467
             'bench'                    => \$opt_bench,
468
             'small-bench'              => \$opt_small_bench,
469
470
             # Control what test suites or cases to run
471
             'force'                    => \$opt_force,
472
             'do-test=s'                => \$opt_do_test,
473
             'start-from=s'             => \$opt_start_from,
474
             'suite|suites=s'           => \$opt_suites,
475
             'skip-rpl'                 => \$opt_skip_rpl,
476
             'skip-test=s'              => \$opt_skip_test,
477
             'combination=s'            => \@opt_combinations,
478
             'skip-combination'         => \$opt_skip_combination,
479
480
             # Specify ports
481
             'master_port=i'            => \$opt_master_myport,
482
             'slave_port=i'             => \$opt_slave_myport,
1166.6.3 by Monty Taylor
Made the memcached_functions run in distcheck and VPATH builds. Also made it so that the ports don't step on each other.
483
             'memc_port=i'              => \$opt_memc_myport,
1 by brian
clean slate
484
	     'mtr-build-thread=i'       => \$opt_mtr_build_thread,
485
486
             # Test case authoring
487
             'record'                   => \$opt_record,
488
             'check-testcases'          => \$opt_check_testcases,
489
             'mark-progress'            => \$opt_mark_progress,
490
491
             # Extra options used when starting mysqld
492
             'mysqld=s'                 => \@opt_extra_mysqld_opt,
496.1.1 by Paul McCullagh
Added --engine option to drizzle-test-run (default innodb)
493
             'engine=s'                 => \$opt_engine,
1 by brian
clean slate
494
495
             # Run test on running server
496
             'extern'                   => \$opt_extern,
497
1101.1.34 by Monty Taylor
Made subunit output optional.
498
             # Output format
499
             'subunit'                  => \$opt_subunit,
500
1 by brian
clean slate
501
             # Debugging
502
             'gdb'                      => \$opt_gdb,
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
503
             'dbx'                      => \$opt_dbx,
1 by brian
clean slate
504
             'client-gdb'               => \$opt_client_gdb,
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
505
             'client-dbx'               => \$opt_client_dbx,
1 by brian
clean slate
506
             'manual-gdb'               => \$opt_manual_gdb,
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
507
             'manual-dbx'               => \$opt_manual_dbx,
1 by brian
clean slate
508
             'manual-debug'             => \$opt_manual_debug,
509
             'ddd'                      => \$opt_ddd,
510
             'client-ddd'               => \$opt_client_ddd,
511
             'manual-ddd'               => \$opt_manual_ddd,
512
	     'debugger=s'               => \$opt_debugger,
513
	     'client-debugger=s'        => \$opt_client_debugger,
514
             'strace-client'            => \$opt_strace_client,
515
             'master-binary=s'          => \$exe_master_mysqld,
516
             'slave-binary=s'           => \$exe_slave_mysqld,
517
             'max-save-core=i'          => \$opt_max_save_core,
518
519
             # Coverage, profiling etc
520
             'gcov'                     => \$opt_gcov,
521
             'gprof'                    => \$opt_gprof,
522
             'valgrind|valgrind-all'    => \$opt_valgrind,
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
523
             'valgrind-drizzletest'       => \$opt_valgrind_drizzletest,
1 by brian
clean slate
524
             'valgrind-mysqld'          => \$opt_valgrind_mysqld,
525
             'valgrind-options=s'       => sub {
526
	       my ($opt, $value)= @_;
527
	       # Deprecated option unless it's what we know pushbuild uses
528
	       if ($value eq "--gen-suppressions=all --show-reachable=yes") {
529
		 push(@valgrind_args, $_) for (split(' ', $value));
530
		 return;
531
	       }
532
	       die("--valgrind-options=s is deprecated. Use ",
533
		   "--valgrind-option=s, to be specified several",
534
		   " times if necessary");
535
	     },
536
             'valgrind-option=s'        => \@valgrind_args,
537
             'valgrind-path=s'          => \$opt_valgrind_path,
538
	     'callgrind'                => \$opt_callgrind,
539
540
             # Stress testing 
541
             'stress'                   => \$opt_stress,
542
             'stress-suite=s'           => \$opt_stress_suite,
543
             'stress-threads=i'         => \$opt_stress_threads,
544
             'stress-test-file=s'       => \$opt_stress_test_file,
545
             'stress-init-file=s'       => \$opt_stress_init_file,
546
             'stress-mode=s'            => \$opt_stress_mode,
547
             'stress-loop-count=i'      => \$opt_stress_loop_count,
548
             'stress-test-count=i'      => \$opt_stress_test_count,
549
             'stress-test-duration=i'   => \$opt_stress_test_duration,
550
551
	     # Directories
552
             'tmpdir=s'                 => \$opt_tmpdir,
553
             'vardir=s'                 => \$opt_vardir,
685.1.13 by Monty Taylor
Attempt at some VPATH support for test suite.
554
	     'testdir=s'		=> \$opt_testdir,
1 by brian
clean slate
555
             'benchdir=s'               => \$glob_mysql_bench_dir,
556
             'mem'                      => \$opt_mem,
557
558
             # Misc
559
             'report-features'          => \$opt_report_features,
560
             'comment=s'                => \$opt_comment,
561
             'debug'                    => \$opt_debug,
562
             'fast'                     => \$opt_fast,
563
             'reorder'                  => \$opt_reorder,
564
             'enable-disabled'          => \$opt_enable_disabled,
565
             'script-debug'             => \$opt_script_debug,
566
             'verbose'                  => \$opt_verbose,
567
             'sleep=i'                  => \$opt_sleep,
568
             'socket=s'                 => \$opt_socket,
569
             'start-dirty'              => \$opt_start_dirty,
570
             'start-and-exit'           => \$opt_start_and_exit,
571
             'timer!'                   => \$opt_timer,
572
             'user=s'                   => \$opt_user,
573
             'testcase-timeout=i'       => \$opt_testcase_timeout,
574
             'suite-timeout=i'          => \$opt_suite_timeout,
575
             'warnings|log-warnings'    => \$opt_warnings,
974.1.1 by Stewart Smith
add repeat-test=n option to test-run.pl to repeat a test n times
576
	     'repeat-test=i'            => \$opt_repeat_test,
1 by brian
clean slate
577
578
             # Options which are no longer used
579
             (map { $_ => \&warn_about_removed_option } @removed_options),
580
581
             'help|h'                   => \$opt_usage,
582
            ) or usage("Can't read options");
583
584
  usage("") if $opt_usage;
585
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
586
  usage("you cannot specify --gdb and --dbx both!") if 
587
	($opt_gdb && $opt_dbx) ||
588
	($opt_manual_gdb && $opt_manual_dbx);
589
1 by brian
clean slate
590
  $glob_scriptname=  basename($0);
591
592
  if ($opt_mtr_build_thread != 0)
593
  {
594
    set_mtr_build_thread_ports($opt_mtr_build_thread)
595
  }
596
  elsif ($ENV{'MTR_BUILD_THREAD'})
597
  {
598
    $opt_mtr_build_thread= $ENV{'MTR_BUILD_THREAD'};
599
  }
600
214 by Brian Aker
Rename of fields (fix issue with string and decimal .h clashing).
601
  if ( -d "../drizzled" )
1 by brian
clean slate
602
  {
603
    $source_dist=  1;
604
  }
605
606
  # Find the absolute path to the test directory
685.1.13 by Monty Taylor
Attempt at some VPATH support for test suite.
607
  if ( ! $opt_testdir )
608
  {
609
    $glob_mysql_test_dir=  cwd();
610
  } 
611
  else
612
  {
613
    $glob_mysql_test_dir= $opt_testdir;
614
  }
1 by brian
clean slate
615
  $default_vardir= "$glob_mysql_test_dir/var";
616
617
  # In most cases, the base directory we find everything relative to,
618
  # is the parent directory of the "mysql-test" directory. For source
619
  # distributions, TAR binary distributions and some other packages.
620
  $glob_basedir= dirname($glob_mysql_test_dir);
621
622
  # In the RPM case, binaries and libraries are installed in the
623
  # default system locations, instead of having our own private base
624
  # directory. And we install "/usr/share/mysql-test". Moving up one
625
  # more directory relative to "mysql-test" gives us a usable base
626
  # directory for RPM installs.
627
  if ( ! $source_dist and ! -d "$glob_basedir/bin" )
628
  {
629
    $glob_basedir= dirname($glob_basedir);
630
  }
631
713.1.10 by Monty Taylor
Fixed default port range in test-run.pl.
632
  if ( $opt_testdir and -d $opt_testdir and $opt_vardir and -d $opt_vardir
685.1.17 by Monty Taylor
Makde mtr work in VPATH.
633
         and -f "$opt_vardir/../../drizzled/drizzled")
634
  {
635
    # probably in a VPATH build
636
    $glob_builddir= "$opt_vardir/../..";
637
  }
685.1.21 by Monty Taylor
Removed some prints. Also fixed some bad.
638
  else
639
  {
640
    $glob_builddir="..";
641
  }
685.1.17 by Monty Taylor
Makde mtr work in VPATH.
642
1 by brian
clean slate
643
  # Expect mysql-bench to be located adjacent to the source tree, by default
644
  $glob_mysql_bench_dir= "$glob_basedir/../mysql-bench"
645
    unless defined $glob_mysql_bench_dir;
646
  $glob_mysql_bench_dir= undef
647
    unless -d $glob_mysql_bench_dir;
648
649
  $path_my_basedir=
650
    $source_dist ? $glob_mysql_test_dir : $glob_basedir;
651
652
  $glob_timers= mtr_init_timers();
653
654
  #
655
  # Find the mysqld executable to be able to find the mysqld version
656
  # number as early as possible
657
  #
658
659
  # Look for the client binaries directory
685.1.17 by Monty Taylor
Makde mtr work in VPATH.
660
  $path_client_bindir= mtr_path_exists("$glob_builddir/client",
661
                                       "$glob_basedir/client",
1 by brian
clean slate
662
				       "$glob_basedir/bin");
663
664
  if (!$opt_extern)
665
  {
214 by Brian Aker
Rename of fields (fix issue with string and decimal .h clashing).
666
    $exe_drizzled=       mtr_exe_exists ("$glob_basedir/drizzled/drizzled",
91 by Brian Aker
Main binary now named drizzled
667
				       "$path_client_bindir/drizzled",
668
				       "$glob_basedir/libexec/drizzled",
669
				       "$glob_basedir/bin/drizzled",
685.1.17 by Monty Taylor
Makde mtr work in VPATH.
670
				       "$glob_basedir/sbin/drizzled",
671
                                       "$glob_builddir/drizzled/drizzled");
1 by brian
clean slate
672
673
    # Use the mysqld found above to find out what features are available
674
    collect_mysqld_features();
675
  }
676
  else
677
  {
165.1.1 by Elliot Murphy
new port number from IANA
678
    $mysqld_variables{'port'}= 4427;
1 by brian
clean slate
679
  }
680
496.1.1 by Paul McCullagh
Added --engine option to drizzle-test-run (default innodb)
681
  if (!$opt_engine)
682
  {
496.1.3 by Paul McCullagh
Set default to InnoDB
683
    $opt_engine= "innodb";
496.1.1 by Paul McCullagh
Added --engine option to drizzle-test-run (default innodb)
684
  }
685
1 by brian
clean slate
686
  if ( $opt_comment )
687
  {
688
    print "\n";
689
    print '#' x 78, "\n";
690
    print "# $opt_comment\n";
691
    print '#' x 78, "\n\n";
692
  }
693
694
  foreach my $arg ( @ARGV )
695
  {
696
    if ( $arg =~ /^--skip-/ )
697
    {
698
      push(@opt_extra_mysqld_opt, $arg);
699
    }
700
    elsif ( $arg =~ /^--$/ )
701
    {
702
      # It is an effect of setting 'pass_through' in option processing
703
      # that the lone '--' separating options from arguments survives,
704
      # simply ignore it.
705
    }
706
    elsif ( $arg =~ /^-/ )
707
    {
708
      usage("Invalid option \"$arg\"");
709
    }
710
    else
711
    {
712
      push(@opt_cases, $arg);
713
    }
714
  }
715
716
  # --------------------------------------------------------------------------
717
  # Find out default storage engine being used(if any)
718
  # --------------------------------------------------------------------------
719
  foreach my $arg ( @opt_extra_mysqld_opt )
720
  {
721
    if ( $arg =~ /default-storage-engine=(\S+)/ )
722
    {
723
      $used_default_engine= $1;
724
    }
725
  }
726
  mtr_report("Using default engine '$used_default_engine'")
727
    if defined $used_default_engine;
728
729
  # --------------------------------------------------------------------------
730
  # Check if we should speed up tests by trying to run on tmpfs
731
  # --------------------------------------------------------------------------
732
  if ( defined $opt_mem )
733
  {
734
    mtr_error("Can't use --mem and --vardir at the same time ")
735
      if $opt_vardir;
736
    mtr_error("Can't use --mem and --tmpdir at the same time ")
737
      if $opt_tmpdir;
738
739
    # Search through list of locations that are known
740
    # to be "fast disks" to list to find a suitable location
741
    # Use --mem=<dir> as first location to look.
742
    my @tmpfs_locations= ($opt_mem, "/dev/shm", "/tmp");
743
744
    foreach my $fs (@tmpfs_locations)
745
    {
746
      if ( -d $fs )
747
      {
748
	mtr_report("Using tmpfs in $fs");
749
	$opt_mem= "$fs/var";
750
	$opt_mem .= $opt_mtr_build_thread if $opt_mtr_build_thread;
751
	last;
752
      }
753
    }
754
  }
755
756
  # --------------------------------------------------------------------------
757
  # Set the "var/" directory, as it is the base for everything else
758
  # --------------------------------------------------------------------------
685.1.29 by Monty Taylor
Some more cleanups to mtr.
759
  if ( ! $opt_vardir )
1 by brian
clean slate
760
  {
761
    $opt_vardir= $default_vardir;
762
  }
763
764
  $path_vardir_trace= $opt_vardir;
765
  # Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/...
766
  $path_vardir_trace=~ s/^\w://;
767
685.1.29 by Monty Taylor
Some more cleanups to mtr.
768
  $opt_vardir= collapse_path($opt_vardir);
1 by brian
clean slate
769
770
  # --------------------------------------------------------------------------
771
  # Set tmpdir
772
  # --------------------------------------------------------------------------
773
  $opt_tmpdir=       "$opt_vardir/tmp" unless $opt_tmpdir;
774
  $opt_tmpdir =~ s,/+$,,;       # Remove ending slash if any
775
776
# --------------------------------------------------------------------------
777
# Record flag
778
# --------------------------------------------------------------------------
779
  if ( $opt_record and ! @opt_cases )
780
  {
781
    mtr_error("Will not run in record mode without a specific test case");
782
  }
783
784
  if ( $opt_record )
785
  {
786
    $opt_skip_combination = 1;
787
  }
788
789
  # --------------------------------------------------------------------------
790
  # Bench flags
791
  # --------------------------------------------------------------------------
792
  if ( $opt_small_bench )
793
  {
794
    $opt_bench=  1;
795
  }
796
797
  # --------------------------------------------------------------------------
798
  # Gcov flag
799
  # --------------------------------------------------------------------------
800
  if ( $opt_gcov and ! $source_dist )
801
  {
802
    mtr_error("Coverage test needs the source - please use source dist");
803
  }
804
805
  # --------------------------------------------------------------------------
806
  # Check debug related options
807
  # --------------------------------------------------------------------------
808
  if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd ||
809
       $opt_manual_gdb || $opt_manual_ddd || $opt_manual_debug ||
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
810
       $opt_debugger || $opt_client_debugger || $opt_gdb || $opt_manual_gdb)
1 by brian
clean slate
811
  {
812
    # Indicate that we are using debugger
813
    $glob_debugger= 1;
814
    if ( $opt_extern )
815
    {
816
      mtr_error("Can't use --extern when using debugger");
817
    }
818
  }
819
820
  # --------------------------------------------------------------------------
821
  # Check if special exe was selected for master or slave
822
  # --------------------------------------------------------------------------
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
823
  $exe_master_mysqld= $exe_master_mysqld || $exe_drizzled;
824
  $exe_slave_mysqld=  $exe_slave_mysqld  || $exe_drizzled;
1 by brian
clean slate
825
826
  # --------------------------------------------------------------------------
827
  # Check valgrind arguments
828
  # --------------------------------------------------------------------------
829
  if ( $opt_valgrind or $opt_valgrind_path or @valgrind_args)
830
  {
831
    mtr_report("Turning on valgrind for all executables");
832
    $opt_valgrind= 1;
833
    $opt_valgrind_mysqld= 1;
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
834
    $opt_valgrind_drizzletest= 1;
1 by brian
clean slate
835
  }
836
  elsif ( $opt_valgrind_mysqld )
837
  {
838
    mtr_report("Turning on valgrind for mysqld(s) only");
839
    $opt_valgrind= 1;
840
  }
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
841
  elsif ( $opt_valgrind_drizzletest )
1 by brian
clean slate
842
  {
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
843
    mtr_report("Turning on valgrind for drizzletest and drizzle_client_test only");
1 by brian
clean slate
844
    $opt_valgrind= 1;
845
  }
846
847
  if ( $opt_callgrind )
848
  {
849
    mtr_report("Turning on valgrind with callgrind for mysqld(s)");
850
    $opt_valgrind= 1;
851
    $opt_valgrind_mysqld= 1;
852
853
    # Set special valgrind options unless options passed on command line
854
    push(@valgrind_args, "--trace-children=yes")
855
      unless @valgrind_args;
856
  }
857
858
  if ( $opt_valgrind )
859
  {
860
    # Set valgrind_options to default unless already defined
861
    push(@valgrind_args, @default_valgrind_args)
862
      unless @valgrind_args;
863
864
    mtr_report("Running valgrind with options \"",
865
	       join(" ", @valgrind_args), "\"");
866
  }
867
868
  if ( ! $opt_testcase_timeout )
869
  {
870
    $opt_testcase_timeout= $default_testcase_timeout;
871
    $opt_testcase_timeout*= 10 if $opt_valgrind;
872
  }
873
874
  if ( ! $opt_suite_timeout )
875
  {
876
    $opt_suite_timeout= $default_suite_timeout;
877
    $opt_suite_timeout*= 6 if $opt_valgrind;
878
  }
879
880
  if ( ! $opt_user )
881
  {
882
    if ( $opt_extern )
883
    {
884
      $opt_user= "test";
885
    }
886
    else
887
    {
888
      $opt_user= "root"; # We want to do FLUSH xxx commands
889
    }
890
  }
891
892
  # On QNX, /tmp/dir/master.sock and /tmp/dir//master.sock seem to be
893
  # considered different, so avoid the extra slash (/) in the socket
894
  # paths.
895
  my $sockdir = $opt_tmpdir;
896
  $sockdir =~ s|/+$||;
897
898
  # On some operating systems, there is a limit to the length of a
899
  # UNIX domain socket's path far below PATH_MAX, so try to avoid long
900
  # socket path names.
901
  $sockdir = tempdir(CLEANUP => 0) if ( length($sockdir) >= 70 );
902
903
  $master->[0]=
904
  {
905
   pid           => 0,
906
   type          => "master",
907
   idx           => 0,
908
   path_myddir   => "$opt_vardir/master-data",
909
   path_myerr    => "$opt_vardir/log/master.err",
910
   path_pid      => "$opt_vardir/run/master.pid",
911
   path_sock     => "$sockdir/master.sock",
912
   port          =>  $opt_master_myport,
913
   start_timeout =>  400, # enough time create innodb tables
914
   cluster       =>  0, # index in clusters list
915
   start_opts    => [],
916
  };
917
918
  $master->[1]=
919
  {
920
   pid           => 0,
921
   type          => "master",
922
   idx           => 1,
923
   path_myddir   => "$opt_vardir/master1-data",
924
   path_myerr    => "$opt_vardir/log/master1.err",
925
   path_pid      => "$opt_vardir/run/master1.pid",
926
   path_sock     => "$sockdir/master1.sock",
927
   port          => $opt_master_myport + 1,
928
   start_timeout => 400, # enough time create innodb tables
929
   cluster       =>  0, # index in clusters list
930
   start_opts    => [],
931
  };
932
933
  $slave->[0]=
934
  {
935
   pid           => 0,
936
   type          => "slave",
937
   idx           => 0,
938
   path_myddir   => "$opt_vardir/slave-data",
939
   path_myerr    => "$opt_vardir/log/slave.err",
940
   path_pid    => "$opt_vardir/run/slave.pid",
941
   path_sock   => "$sockdir/slave.sock",
942
   port   => $opt_slave_myport,
943
   start_timeout => 400,
944
945
   cluster       =>  1, # index in clusters list
946
   start_opts    => [],
947
  };
948
949
  $slave->[1]=
950
  {
951
   pid           => 0,
952
   type          => "slave",
953
   idx           => 1,
954
   path_myddir   => "$opt_vardir/slave1-data",
955
   path_myerr    => "$opt_vardir/log/slave1.err",
956
   path_pid    => "$opt_vardir/run/slave1.pid",
957
   path_sock   => "$sockdir/slave1.sock",
958
   port   => $opt_slave_myport + 1,
959
   start_timeout => 300,
960
   cluster       =>  -1, # index in clusters list
961
   start_opts    => [],
962
  };
963
964
  $slave->[2]=
965
  {
966
   pid           => 0,
967
   type          => "slave",
968
   idx           => 2,
969
   path_myddir   => "$opt_vardir/slave2-data",
970
   path_myerr    => "$opt_vardir/log/slave2.err",
971
   path_pid    => "$opt_vardir/run/slave2.pid",
972
   path_sock   => "$sockdir/slave2.sock",
973
   port   => $opt_slave_myport + 2,
974
   start_timeout => 300,
975
   cluster       =>  -1, # index in clusters list
976
   start_opts    => [],
977
  };
978
979
980
  # --------------------------------------------------------------------------
981
  # extern
982
  # --------------------------------------------------------------------------
983
  if ( $opt_extern )
984
  {
985
    # Turn off features not supported when running with extern server
986
    $opt_skip_rpl= 1;
987
    warn("Currenty broken --extern");
988
989
    # Setup master->[0] with the settings for the extern server
990
    $master->[0]->{'path_sock'}=  $opt_socket ? $opt_socket : "/tmp/mysql.sock";
991
    mtr_report("Using extern server at '$master->[0]->{path_sock}'");
992
  }
993
  else
994
  {
995
    mtr_error("--socket can only be used in combination with --extern")
996
      if $opt_socket;
997
  }
998
999
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1000
  $path_timefile=  "$opt_vardir/log/drizzletest-time";
1001
  $path_drizzletest_log=  "$opt_vardir/log/drizzletest.log";
1 by brian
clean slate
1002
  $path_current_test_log= "$opt_vardir/log/current_test";
1003
1004
  $path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/";
1005
1006
  if ( $opt_valgrind and $opt_debug )
1007
  {
1008
    # When both --valgrind and --debug is selected, send
1009
    # all output to the trace file, making it possible to
1010
    # see the exact location where valgrind complains
1011
    foreach my $mysqld (@{$master}, @{$slave})
1012
    {
1013
      my $sidx= $mysqld->{idx} ? "$mysqld->{idx}" : "";
1014
      $mysqld->{path_myerr}=
1015
	"$opt_vardir/log/" . $mysqld->{type} . "$sidx.trace";
1016
    }
1017
  }
1018
}
1019
1020
#
1021
# To make it easier for different devs to work on the same host,
1022
# an environment variable can be used to control all ports. A small
1023
# number is to be used, 0 - 16 or similar.
1024
#
1025
# Note the MASTER_MYPORT has to be set the same in all 4.x and 5.x
1026
# versions of this script, else a 4.0 test run might conflict with a
1027
# 5.1 test run, even if different MTR_BUILD_THREAD is used. This means
1028
# all port numbers might not be used in this version of the script.
1029
#
1030
# Also note the limitation of ports we are allowed to hand out. This
1031
# differs between operating systems and configuration, see
1032
# http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html
1033
# But a fairly safe range seems to be 5001 - 32767
1034
#
1035
1036
sub set_mtr_build_thread_ports($) {
1037
  my $mtr_build_thread= shift;
1038
1039
  if ( lc($mtr_build_thread) eq 'auto' ) {
1040
    print "Requesting build thread... ";
1041
    $ENV{'MTR_BUILD_THREAD'} = $mtr_build_thread = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299);
1042
    print "got ".$mtr_build_thread."\n";
1043
  }
1044
713.1.10 by Monty Taylor
Fixed default port range in test-run.pl.
1045
  $mtr_build_thread= (($mtr_build_thread * 10) % 2000) - 1000;
1046
1 by brian
clean slate
1047
  # Up to two masters, up to three slaves
1048
  # A magic value in command_line_setup depends on these equations.
713.1.10 by Monty Taylor
Fixed default port range in test-run.pl.
1049
  $opt_master_myport=         $mtr_build_thread + 9000; # and 1
1 by brian
clean slate
1050
  $opt_slave_myport=          $opt_master_myport + 2;  # and 3 4
1166.6.3 by Monty Taylor
Made the memcached_functions run in distcheck and VPATH builds. Also made it so that the ports don't step on each other.
1051
  $opt_memc_myport= $opt_master_myport + 10;
1 by brian
clean slate
1052
1053
  if ( $opt_master_myport < 5001 or $opt_master_myport + 10 >= 32767 )
1054
  {
1055
    mtr_error("MTR_BUILD_THREAD number results in a port",
1056
              "outside 5001 - 32767",
1057
              "($opt_master_myport - $opt_master_myport + 10)");
1058
  }
1059
}
1060
1061
1062
sub datadir_list_setup () {
1063
1064
  # Make a list of all data_dirs
1065
  for (my $idx= 0; $idx < $max_master_num; $idx++)
1066
  {
1067
    push(@data_dir_lst, $master->[$idx]->{'path_myddir'});
1068
  }
1069
1070
  for (my $idx= 0; $idx < $max_slave_num; $idx++)
1071
  {
1072
    push(@data_dir_lst, $slave->[$idx]->{'path_myddir'});
1073
  }
1074
}
1075
1076
1077
##############################################################################
1078
#
1079
#  Set paths to various executable programs
1080
#
1081
##############################################################################
1082
1083
1084
sub collect_mysqld_features () {
1085
  my $found_variable_list_start= 0;
1086
  my $tmpdir= tempdir(CLEANUP => 0); # Directory removed by this function
1087
1088
  #
1089
  # Execute "mysqld --help --verbose" to get a list
1090
  # list of all features and settings
1091
  #
1092
  # --no-defaults and --skip-grant-tables are to avoid loading
1093
  # system-wide configs and plugins
1094
  #
1095
  # --datadir must exist, mysqld will chdir into it
1096
  #
236.1.61 by Monty Taylor
Remove test references to charset dir.
1097
  my $list= `$exe_drizzled --no-defaults --datadir=$tmpdir --skip-grant-tables --verbose --help`;
1 by brian
clean slate
1098
1099
  foreach my $line (split('\n', $list))
1100
  {
1101
    # First look for version
1102
    if ( !$mysql_version_id )
1103
    {
1104
      # Look for version
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1105
      my $exe_name= basename($exe_drizzled);
1 by brian
clean slate
1106
      mtr_verbose("exe_name: $exe_name");
1107
      if ( $line =~ /^\S*$exe_name\s\sVer\s([0-9]*)\.([0-9]*)\.([0-9]*)/ )
1108
      {
1109
	#print "Major: $1 Minor: $2 Build: $3\n";
1110
	$mysql_version_id= $1*10000 + $2*100 + $3;
1111
	#print "mysql_version_id: $mysql_version_id\n";
1112
	mtr_report("MySQL Version $1.$2.$3");
1113
      }
1114
    }
1115
    else
1116
    {
1117
      if (!$found_variable_list_start)
1118
      {
1119
	# Look for start of variables list
1120
	if ( $line =~ /[\-]+\s[\-]+/ )
1121
	{
1122
	  $found_variable_list_start= 1;
1123
	}
1124
      }
1125
      else
1126
      {
1127
	# Put variables into hash
1128
	if ( $line =~ /^([\S]+)[ \t]+(.*?)\r?$/ )
1129
	{
1130
	  # print "$1=\"$2\"\n";
1131
	  $mysqld_variables{$1}= $2;
1132
	}
1133
	else
1134
	{
1135
	  # The variable list is ended with a blank line
1136
	  if ( $line =~ /^[\s]*$/ )
1137
	  {
1138
	    last;
1139
	  }
1140
	  else
1141
	  {
1142
	    # Send out a warning, we should fix the variables that has no
1143
	    # space between variable name and it's value
1144
	    # or should it be fixed width column parsing? It does not
1145
	    # look like that in function my_print_variables in my_getopt.c
1146
	    mtr_warning("Could not parse variable list line : $line");
1147
	  }
1148
	}
1149
      }
1150
    }
1151
  }
1152
  rmtree($tmpdir);
1153
  mtr_error("Could not find version of MySQL") unless $mysql_version_id;
1154
  mtr_error("Could not find variabes list") unless $found_variable_list_start;
1155
1156
}
1157
1158
1159
sub run_query($$) {
1160
  my ($mysqld, $query)= @_;
1161
1162
  my $args;
1163
  mtr_init_args(\$args);
1164
1165
  mtr_add_arg($args, "--no-defaults");
779.7.8 by Monty Taylor
Turn of the "friendly" stack trace in test-run to get a proper core file.
1166
  mtr_add_arg($args, "--skip-stack-trace");
1 by brian
clean slate
1167
  mtr_add_arg($args, "--user=%s", $opt_user);
1168
  mtr_add_arg($args, "--port=%d", $mysqld->{'port'});
1169
  mtr_add_arg($args, "--silent"); # Tab separated output
1170
  mtr_add_arg($args, "-e '%s'", $query);
1171
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1172
  my $cmd= "$exe_drizzle " . join(' ', @$args);
1 by brian
clean slate
1173
  mtr_verbose("cmd: $cmd");
1174
  return `$cmd`;
1175
}
1176
1177
1178
sub collect_mysqld_features_from_running_server ()
1179
{
1180
  my $list= run_query($master->[0], "use mysql; SHOW VARIABLES");
1181
1182
  foreach my $line (split('\n', $list))
1183
  {
1184
    # Put variables into hash
1185
    if ( $line =~ /^([\S]+)[ \t]+(.*?)\r?$/ )
1186
    {
1187
      print "$1=\"$2\"\n";
1188
      $mysqld_variables{$1}= $2;
1189
    }
1190
  }
1191
}
1192
1193
sub executable_setup () {
1194
89 by Brian Aker
Saving changes/removals to test run
1195
#
1196
# Check if libtool is available in this distribution/clone
1197
# we need it when valgrinding or debugging non installed binary
1198
# Otherwise valgrind will valgrind the libtool wrapper or bash
1199
# and gdb will not find the real executable to debug
1200
#
1 by brian
clean slate
1201
  if ( -x "../libtool")
1202
  {
1203
    $exe_libtool= "../libtool";
1204
    if ($opt_valgrind or $glob_debugger)
1205
    {
1206
      mtr_report("Using \"$exe_libtool\" when running valgrind or debugger");
1207
    }
1208
  }
1209
89 by Brian Aker
Saving changes/removals to test run
1210
# Look for my_print_defaults
1 by brian
clean slate
1211
  $exe_my_print_defaults=
54.1.7 by Stewart Smith
fix drizzle-test-run.pl for sql/ => server/ rename and remove some vs_config_dir references
1212
    mtr_exe_exists(
89 by Brian Aker
Saving changes/removals to test run
1213
        "$path_client_bindir/my_print_defaults",
685.1.17 by Monty Taylor
Makde mtr work in VPATH.
1214
        "$glob_basedir/extra/my_print_defaults",
1215
        "$glob_builddir/extra/my_print_defaults");
1 by brian
clean slate
1216
89 by Brian Aker
Saving changes/removals to test run
1217
# Look for perror
3 by Brian Aker
Fix test push for version.
1218
  $exe_perror= "perror";
1 by brian
clean slate
1219
89 by Brian Aker
Saving changes/removals to test run
1220
# Look for the client binaries
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1221
  $exe_drizzledump= mtr_exe_exists("$path_client_bindir/drizzledump");
1222
  $exe_drizzleimport= mtr_exe_exists("$path_client_bindir/drizzleimport");
1223
  $exe_drizzle=          mtr_exe_exists("$path_client_bindir/drizzle");
1 by brian
clean slate
1224
373.1.9 by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING.
1225
  if (!$opt_extern)
1226
  {
1227
# Look for SQL scripts directory
1228
     if ( $mysql_version_id >= 50100 )
1229
     {
1230
         $exe_drizzleslap= mtr_exe_exists("$path_client_bindir/drizzleslap");
1231
     }
1232
  }
1233
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1234
# Look for drizzletest executable
1 by brian
clean slate
1235
  {
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1236
    $exe_drizzletest= mtr_exe_exists("$path_client_bindir/drizzletest");
1 by brian
clean slate
1237
  }
1238
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1239
# Look for drizzle_client_test executable which may _not_ exist in
89 by Brian Aker
Saving changes/removals to test run
1240
# some versions, test using it should be skipped
1 by brian
clean slate
1241
  {
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1242
    $exe_drizzle_client_test=
54.1.7 by Stewart Smith
fix drizzle-test-run.pl for sql/ => server/ rename and remove some vs_config_dir references
1243
      mtr_exe_maybe_exists(
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1244
          "$glob_basedir/tests/drizzle_client_test",
1245
          "$glob_basedir/bin/drizzle_client_test");
1 by brian
clean slate
1246
  }
1247
89 by Brian Aker
Saving changes/removals to test run
1248
# Look for bug25714 executable which may _not_ exist in
1249
# some versions, test using it should be skipped
1 by brian
clean slate
1250
  $exe_bug25714=
54.1.7 by Stewart Smith
fix drizzle-test-run.pl for sql/ => server/ rename and remove some vs_config_dir references
1251
    mtr_exe_maybe_exists(
89 by Brian Aker
Saving changes/removals to test run
1252
        "$glob_basedir/tests/bug25714");
1 by brian
clean slate
1253
}
1254
1255
89 by Brian Aker
Saving changes/removals to test run
1256
1 by brian
clean slate
1257
sub generate_cmdline_mysqldump ($) {
1258
  my($mysqld) = @_;
1259
  return
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1260
    mtr_native_path($exe_drizzledump) .
1 by brian
clean slate
1261
      " --no-defaults -uroot --debug-check " .
1262
      "--port=$mysqld->{'port'} ";
1263
}
1264
1265
1266
##############################################################################
1267
#
1268
#  Set environment to be used by childs of this process for
77.1.40 by Monty Taylor
More naming changes.
1269
#  things that are constant duting the whole lifetime of drizzle-test-run.pl
1 by brian
clean slate
1270
#
1271
##############################################################################
1272
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1273
sub drizzle_client_test_arguments()
1 by brian
clean slate
1274
{
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1275
  my $exe= $exe_drizzle_client_test;
1 by brian
clean slate
1276
1277
  my $args;
1278
  mtr_init_args(\$args);
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1279
  if ( $opt_valgrind_drizzletest )
1 by brian
clean slate
1280
  {
1281
    valgrind_arguments($args, \$exe);
1282
  }
1283
1284
  mtr_add_arg($args, "--no-defaults");
1285
  mtr_add_arg($args, "--testcase");
1286
  mtr_add_arg($args, "--user=root");
1287
  mtr_add_arg($args, "--port=$master->[0]->{'port'}");
1288
1289
  if ( $opt_extern || $mysql_version_id >= 50000 )
1290
  {
1291
    mtr_add_arg($args, "--vardir=$opt_vardir")
1292
  }
1293
1294
  if ( $opt_debug )
1295
  {
1296
    mtr_add_arg($args,
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1297
      "--debug=d:t:A,$path_vardir_trace/log/drizzle_client_test.trace");
1 by brian
clean slate
1298
  }
1299
1300
  return join(" ", $exe, @$args);
1301
}
1302
1303
1304
# Note that some env is setup in spawn/run, in "mtr_process.pl"
1305
1306
sub environment_setup () {
1307
1308
  umask(022);
1309
1310
  my @ld_library_paths;
1311
1312
  # --------------------------------------------------------------------------
1313
  # Setup LD_LIBRARY_PATH so the libraries from this distro/clone
1314
  # are used in favor of the system installed ones
1315
  # --------------------------------------------------------------------------
1316
  if ( $source_dist )
1317
  {
779.3.43 by Monty Taylor
Fixed a couple of distcheck related things.
1318
    push(@ld_library_paths, "$glob_basedir/libdrizzleclient/.libs/",
1319
                            "$glob_basedir/mysys/.libs/",
1320
                            "$glob_basedir/mystrings/.libs/",
779.3.44 by Monty Taylor
Added /usr/local to LD_LIBRARY_PATH in test run - it's the one most likely to not be set with an explicit rpath in the linking stage leading to pain during distcheck.
1321
                            "$glob_basedir/drizzled/.libs/",
1322
			    "/usr/local/lib");
1 by brian
clean slate
1323
  }
1324
  else
1325
  {
1326
    push(@ld_library_paths, "$glob_basedir/lib");
1327
  }
1328
1329
  # --------------------------------------------------------------------------
1330
  # Valgrind need to be run with debug libraries otherwise it's almost
1331
  # impossible to add correct supressions, that means if "/usr/lib/debug"
1332
  # is available, it should be added to
1333
  # LD_LIBRARY_PATH
1334
  #
1335
  # But pthread is broken in libc6-dbg on Debian <= 3.1 (see Debian
1336
  # bug 399035, http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=399035),
1337
  # so don't change LD_LIBRARY_PATH on that platform.
1338
  # --------------------------------------------------------------------------
1339
  my $debug_libraries_path= "/usr/lib/debug";
1340
  my $deb_version;
1341
  if (  $opt_valgrind and -d $debug_libraries_path and
1342
        (! -e '/etc/debian_version' or
1343
	 ($deb_version= mtr_grab_file('/etc/debian_version')) !~ /^[0-9]+\.[0-9]$/ or
1344
         $deb_version > 3.1 ) )
1345
  {
1346
    push(@ld_library_paths, $debug_libraries_path);
1347
  }
1348
992.1.2 by Monty Taylor
Append local @ld_library_paths, rather than the other way around.
1349
  $ENV{'LD_LIBRARY_PATH'}= join(":", 
1 by brian
clean slate
1350
				$ENV{'LD_LIBRARY_PATH'} ?
992.1.2 by Monty Taylor
Append local @ld_library_paths, rather than the other way around.
1351
				split(':', $ENV{'LD_LIBRARY_PATH'}) : (),
1352
                                @ld_library_paths);
1 by brian
clean slate
1353
  mtr_debug("LD_LIBRARY_PATH: $ENV{'LD_LIBRARY_PATH'}");
1354
1355
  $ENV{'DYLD_LIBRARY_PATH'}= join(":", @ld_library_paths,
1356
				  $ENV{'DYLD_LIBRARY_PATH'} ?
1357
				  split(':', $ENV{'DYLD_LIBRARY_PATH'}) : ());
1358
  mtr_debug("DYLD_LIBRARY_PATH: $ENV{'DYLD_LIBRARY_PATH'}");
1359
1360
  # The environment variable used for shared libs on AIX
1361
  $ENV{'SHLIB_PATH'}= join(":", @ld_library_paths,
1362
                           $ENV{'SHLIB_PATH'} ?
1363
                           split(':', $ENV{'SHLIB_PATH'}) : ());
1364
  mtr_debug("SHLIB_PATH: $ENV{'SHLIB_PATH'}");
1365
1366
  # The environment variable used for shared libs on hp-ux
1367
  $ENV{'LIBPATH'}= join(":", @ld_library_paths,
1368
                        $ENV{'LIBPATH'} ?
1369
                        split(':', $ENV{'LIBPATH'}) : ());
1370
  mtr_debug("LIBPATH: $ENV{'LIBPATH'}");
1371
1372
  # --------------------------------------------------------------------------
1373
  # Also command lines in .opt files may contain env vars
1374
  # --------------------------------------------------------------------------
1375
383.1.6 by Brian Aker
Removed more of the charset support.
1376
  $ENV{'CHARSETSDIR'}=              "";
1 by brian
clean slate
1377
  $ENV{'UMASK'}=              "0660"; # The octal *string*
1378
  $ENV{'UMASK_DIR'}=          "0770"; # The octal *string*
1379
  
1380
  #
1381
  # MySQL tests can produce output in various character sets
1382
  # (especially, ctype_xxx.test). To avoid confusing Perl
1383
  # with output which is incompatible with the current locale
1384
  # settings, we reset the current values of LC_ALL and LC_CTYPE to "C".
1385
  # For details, please see
1386
  # Bug#27636 tests fails if LC_* variables set to *_*.UTF-8
1387
  #
1388
  $ENV{'LC_ALL'}=             "C";
1389
  $ENV{'LC_CTYPE'}=           "C";
1390
  
1391
  $ENV{'LC_COLLATE'}=         "C";
1392
  $ENV{'USE_RUNNING_SERVER'}= $opt_extern;
685.1.29 by Monty Taylor
Some more cleanups to mtr.
1393
  $ENV{'DRIZZLE_TEST_DIR'}=     collapse_path($glob_mysql_test_dir);
1 by brian
clean slate
1394
  $ENV{'MYSQLTEST_VARDIR'}=   $opt_vardir;
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
1395
  $ENV{'DRIZZLE_TMP_DIR'}=      $opt_tmpdir;
1 by brian
clean slate
1396
  $ENV{'MASTER_MYSOCK'}=      $master->[0]->{'path_sock'};
1397
  $ENV{'MASTER_MYSOCK1'}=     $master->[1]->{'path_sock'};
1398
  $ENV{'MASTER_MYPORT'}=      $master->[0]->{'port'};
1399
  $ENV{'MASTER_MYPORT1'}=     $master->[1]->{'port'};
1400
  $ENV{'SLAVE_MYSOCK'}=       $slave->[0]->{'path_sock'};
1401
  $ENV{'SLAVE_MYPORT'}=       $slave->[0]->{'port'};
1402
  $ENV{'SLAVE_MYPORT1'}=      $slave->[1]->{'port'};
1403
  $ENV{'SLAVE_MYPORT2'}=      $slave->[2]->{'port'};
1166.6.3 by Monty Taylor
Made the memcached_functions run in distcheck and VPATH builds. Also made it so that the ports don't step on each other.
1404
  $ENV{'MC_PORT'}=            $opt_memc_myport;
301 by Brian Aker
Clean up port startup
1405
  $ENV{'DRIZZLE_TCP_PORT'}=     $mysqld_variables{'port'};
1 by brian
clean slate
1406
685.1.36 by Monty Taylor
Made make test rotate ports.
1407
  $ENV{'MTR_BUILD_THREAD'}=      $opt_mtr_build_thread;
1 by brian
clean slate
1408
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1409
  $ENV{'EXE_MYSQL'}=          $exe_drizzle;
1 by brian
clean slate
1410
1411
1412
  # ----------------------------------------------------
1413
  # Setup env to childs can execute myqldump
1414
  # ----------------------------------------------------
1415
  my $cmdline_mysqldump= generate_cmdline_mysqldump($master->[0]);
1416
  my $cmdline_mysqldumpslave= generate_cmdline_mysqldump($slave->[0]);
1417
1418
  if ( $opt_debug )
1419
  {
1420
    $cmdline_mysqldump .=
1421
      " --debug=d:t:A,$path_vardir_trace/log/mysqldump-master.trace";
1422
    $cmdline_mysqldumpslave .=
1423
      " --debug=d:t:A,$path_vardir_trace/log/mysqldump-slave.trace";
1424
  }
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
1425
  $ENV{'DRIZZLE_DUMP'}= $cmdline_mysqldump;
1426
  $ENV{'DRIZZLE_DUMP_SLAVE'}= $cmdline_mysqldumpslave;
1 by brian
clean slate
1427
373.1.9 by Monty Taylor
Added back mysqlslap as drizzleslap. Also made it C++ and removed DYNAMIC_STRING.
1428
  # ----------------------------------------------------
1429
  # Setup env so childs can execute mysqlslap
1430
  # ----------------------------------------------------
1431
  if ( $exe_drizzleslap )
1432
  {
1433
    my $cmdline_drizzleslap=
1434
      mtr_native_path($exe_drizzleslap) .
1435
      " -uroot " .
1436
      "--port=$master->[0]->{'port'} ";
1437
1438
    if ( $opt_debug )
1439
   {
1440
      $cmdline_drizzleslap .=
1441
        " --debug=d:t:A,$path_vardir_trace/log/drizzleslap.trace";
1442
    }
1443
    $ENV{'DRIZZLE_SLAP'}= $cmdline_drizzleslap;
1444
  }
1445
1446
1 by brian
clean slate
1447
1448
  # ----------------------------------------------------
1449
  # Setup env so childs can execute mysqlimport
1450
  # ----------------------------------------------------
1451
  my $cmdline_mysqlimport=
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1452
    mtr_native_path($exe_drizzleimport) .
1 by brian
clean slate
1453
    " -uroot --debug-check " .
1454
    "--port=$master->[0]->{'port'} ";
1455
1456
  if ( $opt_debug )
1457
  {
1458
    $cmdline_mysqlimport .=
1459
      " --debug=d:t:A,$path_vardir_trace/log/mysqlimport.trace";
1460
  }
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
1461
  $ENV{'DRIZZLE_IMPORT'}= $cmdline_mysqlimport;
1 by brian
clean slate
1462
1463
1464
  # ----------------------------------------------------
1465
  # Setup env so childs can execute mysql
1466
  # ----------------------------------------------------
1467
  my $cmdline_mysql=
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1468
    mtr_native_path($exe_drizzle) .
1 by brian
clean slate
1469
    " --no-defaults --debug-check --host=localhost  --user=root --password= " .
383.1.6 by Brian Aker
Removed more of the charset support.
1470
    "--port=$master->[0]->{'port'} ";
1 by brian
clean slate
1471
1472
  $ENV{'MYSQL'}= $cmdline_mysql;
1473
1474
  # ----------------------------------------------------
1475
  # Setup env so childs can execute bug25714
1476
  # ----------------------------------------------------
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
1477
  $ENV{'DRIZZLE_BUG25714'}=  $exe_bug25714;
1 by brian
clean slate
1478
1479
  # ----------------------------------------------------
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1480
  # Setup env so childs can execute drizzle_client_test
1 by brian
clean slate
1481
  # ----------------------------------------------------
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
1482
  $ENV{'DRIZZLE_CLIENT_TEST'}=  drizzle_client_test_arguments();
1 by brian
clean slate
1483
1484
1485
  # ----------------------------------------------------
1486
  # Setup env so childs can execute mysql_fix_system_tables
1487
  # ----------------------------------------------------
87 by Brian Aker
First pass on cleaning out mysql-test-run
1488
  #if ( !$opt_extern)
54 by brian
Disabling myisam tools until incomming link patch from Monty
1489
  if ( 0 )
1 by brian
clean slate
1490
  {
1491
    my $cmdline_mysql_fix_system_tables=
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
1492
      "$exe_drizzle_fix_system_tables --no-defaults --host=localhost " .
1 by brian
clean slate
1493
      "--user=root --password= " .
1494
      "--basedir=$glob_basedir --bindir=$path_client_bindir --verbose " .
1495
      "--port=$master->[0]->{'port'} ";
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
1496
    $ENV{'DRIZZLE_FIX_SYSTEM_TABLES'}=  $cmdline_mysql_fix_system_tables;
1 by brian
clean slate
1497
1498
  }
1499
1500
  # ----------------------------------------------------
1501
  # Setup env so childs can execute my_print_defaults
1502
  # ----------------------------------------------------
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
1503
  $ENV{'DRIZZLE_MY_PRINT_DEFAULTS'}= mtr_native_path($exe_my_print_defaults);
1 by brian
clean slate
1504
1505
  # ----------------------------------------------------
973.1.3 by Toru Maesaka
Remove drizzleadmin from the repository and fix the test suite for it.
1506
  # Setup env so childs can shutdown the server
1 by brian
clean slate
1507
  # ----------------------------------------------------
973.1.3 by Toru Maesaka
Remove drizzleadmin from the repository and fix the test suite for it.
1508
  $ENV{'DRIZZLED_SHUTDOWN'}= mtr_native_path($exe_drizzle);
1 by brian
clean slate
1509
1510
  # ----------------------------------------------------
1511
  # Setup env so childs can execute perror  
1512
  # ----------------------------------------------------
1513
  $ENV{'MY_PERROR'}= mtr_native_path($exe_perror);
1514
1515
  # ----------------------------------------------------
1516
  # Add the path where mysqld will find ha_example.so
1517
  # ----------------------------------------------------
1518
  $ENV{'EXAMPLE_PLUGIN'}=
1519
    ($lib_example_plugin ? basename($lib_example_plugin) : "");
1520
  $ENV{'EXAMPLE_PLUGIN_OPT'}=
1521
    ($lib_example_plugin ? "--plugin_dir=" . dirname($lib_example_plugin) : "");
1522
1523
  # ----------------------------------------------------
1524
  # Setup env so childs can execute myisampack and myisamchk
1525
  # ----------------------------------------------------
54 by brian
Disabling myisam tools until incomming link patch from Monty
1526
#  $ENV{'MYISAMCHK'}= mtr_native_path(mtr_exe_exists(
1527
#                       "$path_client_bindir/myisamchk",
1528
#                       "$glob_basedir/storage/myisam/myisamchk",
1529
#                       "$glob_basedir/myisam/myisamchk"));
1530
#  $ENV{'MYISAMPACK'}= mtr_native_path(mtr_exe_exists(
1531
#                        "$path_client_bindir/myisampack",
1532
#                        "$glob_basedir/storage/myisam/myisampack",
1533
#                        "$glob_basedir/myisam/myisampack"));
1 by brian
clean slate
1534
1535
  # ----------------------------------------------------
1536
  # We are nice and report a bit about our settings
1537
  # ----------------------------------------------------
1538
  if (!$opt_extern)
1539
  {
1540
    print "Using MTR_BUILD_THREAD      = $ENV{MTR_BUILD_THREAD}\n";
1541
    print "Using MASTER_MYPORT         = $ENV{MASTER_MYPORT}\n";
1542
    print "Using MASTER_MYPORT1        = $ENV{MASTER_MYPORT1}\n";
1543
    print "Using SLAVE_MYPORT          = $ENV{SLAVE_MYPORT}\n";
1544
    print "Using SLAVE_MYPORT1         = $ENV{SLAVE_MYPORT1}\n";
1545
    print "Using SLAVE_MYPORT2         = $ENV{SLAVE_MYPORT2}\n";
1166.6.3 by Monty Taylor
Made the memcached_functions run in distcheck and VPATH builds. Also made it so that the ports don't step on each other.
1546
    print "Using MC_PORT               = $ENV{MC_PORT}\n";
1 by brian
clean slate
1547
  }
1548
1549
  # Create an environment variable to make it possible
1550
  # to detect that valgrind is being used from test cases
1551
  $ENV{'VALGRIND_TEST'}= $opt_valgrind;
1552
1553
}
1554
1555
1556
##############################################################################
1557
#
1558
#  If we get a ^C, we try to clean up before termination
1559
#
1560
##############################################################################
1561
# FIXME check restrictions what to do in a signal handler
1562
1563
sub signal_setup () {
1564
  $SIG{INT}= \&handle_int_signal;
1565
}
1566
1567
1568
sub handle_int_signal () {
1569
  $SIG{INT}= 'DEFAULT';         # If we get a ^C again, we die...
1570
  mtr_warning("got INT signal, cleaning up.....");
1571
  stop_all_servers();
1572
  mtr_error("We die from ^C signal from user");
1573
}
1574
1575
1576
##############################################################################
1577
#
1578
#  Handle left overs from previous runs
1579
#
1580
##############################################################################
1581
1582
sub kill_running_servers () {
1583
  {
1584
    # Ensure that no old mysqld test servers are running
1585
    # This is different from terminating processes we have
1586
    # started from this run of the script, this is terminating
1587
    # leftovers from previous runs.
1588
    mtr_kill_leftovers();
1589
   }
1590
}
1591
1592
#
1593
# Remove var and any directories in var/ created by previous
1594
# tests
1595
#
1596
sub remove_stale_vardir () {
1597
1598
  mtr_report("Removing Stale Files");
1599
1600
  # Safety!
1601
  mtr_error("No, don't remove the vardir when running with --extern")
1602
    if $opt_extern;
1603
1604
  mtr_verbose("opt_vardir: $opt_vardir");
1605
  if ( $opt_vardir eq $default_vardir )
1606
  {
1607
    #
1608
    # Running with "var" in mysql-test dir
1609
    #
1610
    if ( -l $opt_vardir)
1611
    {
1612
      # var is a symlink
1613
1614
      if ( $opt_mem and readlink($opt_vardir) eq $opt_mem )
1615
      {
1616
	# Remove the directory which the link points at
1617
	mtr_verbose("Removing " . readlink($opt_vardir));
1618
	mtr_rmtree(readlink($opt_vardir));
1619
1620
	# Remove the "var" symlink
1621
	mtr_verbose("unlink($opt_vardir)");
1622
	unlink($opt_vardir);
1623
      }
1624
      elsif ( $opt_mem )
1625
      {
1626
	# Just remove the "var" symlink
1627
	mtr_report("WARNING: Removing '$opt_vardir' symlink it's wrong");
1628
1629
	mtr_verbose("unlink($opt_vardir)");
1630
	unlink($opt_vardir);
1631
      }
1632
      else
1633
      {
1634
	# Some users creates a soft link in mysql-test/var to another area
1635
	# - allow it, but remove all files in it
1636
1637
	mtr_report("WARNING: Using the 'mysql-test/var' symlink");
1638
1639
	# Make sure the directory where it points exist
1640
	mtr_error("The destination for symlink $opt_vardir does not exist")
1641
	  if ! -d readlink($opt_vardir);
1642
1643
	foreach my $bin ( glob("$opt_vardir/*") )
1644
	{
1645
	  mtr_verbose("Removing bin $bin");
1646
	  mtr_rmtree($bin);
1647
	}
1648
      }
1649
    }
1650
    else
1651
    {
1652
      # Remove the entire "var" dir
1653
      mtr_verbose("Removing $opt_vardir/");
1654
      mtr_rmtree("$opt_vardir/");
1655
    }
1656
1657
    if ( $opt_mem )
1658
    {
1659
      # A symlink from var/ to $opt_mem will be set up
1660
      # remove the $opt_mem dir to assure the symlink
1661
      # won't point at an old directory
1662
      mtr_verbose("Removing $opt_mem");
1663
      mtr_rmtree($opt_mem);
1664
    }
1665
1666
  }
1667
  else
1668
  {
1669
    #
1670
    # Running with "var" in some other place
1671
    #
1672
1673
    # Remove the var/ dir in mysql-test dir if any
1674
    # this could be an old symlink that shouldn't be there
1675
    mtr_verbose("Removing $default_vardir");
1676
    mtr_rmtree($default_vardir);
1677
1678
    # Remove the "var" dir
1679
    mtr_verbose("Removing $opt_vardir/");
1680
    mtr_rmtree("$opt_vardir/");
1681
  }
1682
}
1683
1684
#
1685
# Create var and the directories needed in var
1686
#
1687
sub setup_vardir() {
1688
  mtr_report("Creating Directories");
1689
1690
  if ( $opt_vardir eq $default_vardir )
1691
  {
1692
    #
1693
    # Running with "var" in mysql-test dir
1694
    #
1695
    if ( -l $opt_vardir )
1696
    {
1697
      #  it's a symlink
1698
1699
      # Make sure the directory where it points exist
1700
      mtr_error("The destination for symlink $opt_vardir does not exist")
1701
	if ! -d readlink($opt_vardir);
1702
    }
1703
    elsif ( $opt_mem )
1704
    {
1705
      # Runinng with "var" as a link to some "memory" location, normally tmpfs
1706
      mtr_verbose("Creating $opt_mem");
1707
      mkpath($opt_mem);
1708
1709
      mtr_report("Symlinking 'var' to '$opt_mem'");
1710
      symlink($opt_mem, $opt_vardir);
1711
    }
1712
  }
1713
1714
  if ( ! -d $opt_vardir )
1715
  {
1716
    mtr_verbose("Creating $opt_vardir");
1717
    mkpath($opt_vardir);
1718
  }
1719
1720
  # Ensure a proper error message if vardir couldn't be created
1721
  unless ( -d $opt_vardir and -w $opt_vardir )
1722
  {
1723
    mtr_error("Writable 'var' directory is needed, use the " .
1724
	      "'--vardir=<path>' option");
1725
  }
1726
1727
  mkpath("$opt_vardir/log");
1728
  mkpath("$opt_vardir/run");
1729
  mkpath("$opt_vardir/tmp");
1730
  mkpath($opt_tmpdir) if $opt_tmpdir ne "$opt_vardir/tmp";
1731
1732
  # Create new data dirs
1733
  foreach my $data_dir (@data_dir_lst)
1734
  {
1735
    mkpath("$data_dir/mysql");
1736
    mkpath("$data_dir/test");
1737
  }
1738
1739
  # Make a link std_data_ln in var/ that points to std_data
685.1.29 by Monty Taylor
Some more cleanups to mtr.
1740
  symlink(collapse_path("$glob_mysql_test_dir/std_data"),
685.1.28 by Monty Taylor
Fixed a coupla more relative-path bugs.
1741
          "$opt_vardir/std_data_ln");
1 by brian
clean slate
1742
1743
  # Remove old log files
1744
  foreach my $name (glob("r/*.progress r/*.log r/*.warnings"))
1745
  {
1746
    unlink($name);
1747
  }
971.1.2 by Monty Taylor
Moved recursive chmod to test-run rather than Makefile - since the dir isn't there to chmod by Makefile time.
1748
  system("chmod -R ugo+r $opt_vardir");
988.3.1 by lbieber
fix test suite permission problem - https://bugs.launchpad.net/drizzle/+bug/324689
1749
  system("chmod -R ugo+r $opt_vardir/std_data_ln/*");
1 by brian
clean slate
1750
}
1751
1752
1753
sub  check_running_as_root () {
1754
  # Check if running as root
1755
  # i.e a file can be read regardless what mode we set it to
1756
  my $test_file= "$opt_vardir/test_running_as_root.txt";
1757
  mtr_tofile($test_file, "MySQL");
1758
  chmod(oct("0000"), $test_file);
1759
1760
  my $result="";
1761
  if (open(FILE,"<",$test_file))
1762
  {
1763
    $result= join('', <FILE>);
1764
    close FILE;
1765
  }
1766
1767
  # Some filesystems( for example CIFS) allows reading a file
1768
  # although mode was set to 0000, but in that case a stat on
1769
  # the file will not return 0000
1770
  my $file_mode= (stat($test_file))[2] & 07777;
1771
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
1772
  $ENV{'DRIZZLE_TEST_ROOT'}= "NO";
1 by brian
clean slate
1773
  mtr_verbose("result: $result, file_mode: $file_mode");
1774
  if ($result eq "MySQL" && $file_mode == 0)
1775
  {
1776
    mtr_warning("running this script as _root_ will cause some " .
1777
                "tests to be skipped");
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
1778
    $ENV{'DRIZZLE_TEST_ROOT'}= "YES";
1 by brian
clean slate
1779
  }
1780
1781
  chmod(oct("0755"), $test_file);
1782
  unlink($test_file);
1783
1784
}
1785
1786
1787
sub check_debug_support ($) {
1788
  my $mysqld_variables= shift;
1789
1790
  if ( ! $mysqld_variables->{'debug'} )
1791
  {
1792
    #mtr_report("Binaries are not debug compiled");
1793
    $debug_compiled_binaries= 0;
1794
1795
    if ( $opt_debug )
1796
    {
1797
      mtr_error("Can't use --debug, binaries does not support it");
1798
    }
1799
    return;
1800
  }
1801
  mtr_report("Binaries are debug compiled");
1802
  $debug_compiled_binaries= 1;
1803
}
1804
1805
1806
##############################################################################
1807
#
1808
#  Run the benchmark suite
1809
#
1810
##############################################################################
1811
1812
sub run_benchmarks ($) {
1813
  my $benchmark=  shift;
1814
1815
  my $args;
1816
1817
  {
1818
    mysqld_start($master->[0],[],[]);
1819
    if ( ! $master->[0]->{'pid'} )
1820
    {
1821
      mtr_error("Can't start the mysqld server");
1822
    }
1823
  }
1824
1825
  mtr_init_args(\$args);
1826
1827
  mtr_add_arg($args, "--user=%s", $opt_user);
1828
1829
  if ( $opt_small_bench )
1830
  {
1831
    mtr_add_arg($args, "--small-test");
1832
    mtr_add_arg($args, "--small-tables");
1833
  }
1834
1835
  chdir($glob_mysql_bench_dir)
1836
    or mtr_error("Couldn't chdir to '$glob_mysql_bench_dir': $!");
1837
1838
  if ( ! $benchmark )
1839
  {
1840
    mtr_run("$glob_mysql_bench_dir/run-all-tests", $args, "", "", "", "");
1841
    # FIXME check result code?!
1842
  }
1843
  elsif ( -x $benchmark )
1844
  {
1845
    mtr_run("$glob_mysql_bench_dir/$benchmark", $args, "", "", "", "");
1846
    # FIXME check result code?!
1847
  }
1848
  else
1849
  {
1850
    mtr_error("Benchmark $benchmark not found");
1851
  }
1852
1853
  chdir($glob_mysql_test_dir);          # Go back
1854
1855
  {
1856
    stop_masters();
1857
  }
1858
}
1859
1860
1861
##############################################################################
1862
#
1863
#  Run the tests
1864
#
1865
##############################################################################
1866
1867
sub run_tests () {
1868
  my ($tests)= @_;
1869
1870
  mtr_print_thick_line();
1871
1872
  mtr_timer_start($glob_timers,"suite", 60 * $opt_suite_timeout);
1873
1874
  mtr_report_tests_not_skipped_though_disabled($tests);
1875
1876
  mtr_print_header();
1877
1878
  foreach my $tinfo ( @$tests )
1879
  {
974.1.1 by Stewart Smith
add repeat-test=n option to test-run.pl to repeat a test n times
1880
    foreach(1..$opt_repeat_test)
1 by brian
clean slate
1881
    {
974.1.1 by Stewart Smith
add repeat-test=n option to test-run.pl to repeat a test n times
1882
      if (run_testcase_check_skip_test($tinfo))
1883
	{
1884
	  next;
1885
	}
1886
1887
      mtr_timer_start($glob_timers,"testcase", 60 * $opt_testcase_timeout);
1888
      run_testcase($tinfo);
1889
      mtr_timer_stop($glob_timers,"testcase");
1 by brian
clean slate
1890
    }
1891
  }
1892
1893
  mtr_print_line();
1894
1895
  if ( ! $glob_debugger and
89 by Brian Aker
Saving changes/removals to test run
1896
       ! $opt_extern )
1 by brian
clean slate
1897
  {
1898
    stop_all_servers();
1899
  }
1900
1901
  if ( $opt_gcov )
1902
  {
1903
    gcov_collect(); # collect coverage information
1904
  }
1905
  if ( $opt_gprof )
1906
  {
1907
    gprof_collect(); # collect coverage information
1908
  }
1909
1910
  mtr_report_stats($tests);
1911
1912
  mtr_timer_stop($glob_timers,"suite");
1913
}
1914
1915
1916
##############################################################################
1917
#
1918
#  Initiate the test databases
1919
#
1920
##############################################################################
1921
1922
sub initialize_servers () {
1923
1924
  datadir_list_setup();
1925
1926
  if ( $opt_extern )
1927
  {
1928
    # Running against an already started server, if the specified
1929
    # vardir does not already exist it should be created
1930
    if ( ! -d $opt_vardir )
1931
    {
1932
      mtr_report("Creating '$opt_vardir'");
1933
      setup_vardir();
1934
    }
1935
    else
1936
    {
1937
      mtr_verbose("No need to create '$opt_vardir' it already exists");
1938
    }
1939
  }
1940
  else
1941
  {
1942
    kill_running_servers();
1943
1944
    if ( ! $opt_start_dirty )
1945
    {
1946
      remove_stale_vardir();
1947
      setup_vardir();
1948
1949
      mysql_install_db();
1950
      if ( $opt_force )
1951
      {
1952
	# Save a snapshot of the freshly installed db
1953
	# to make it possible to restore to a known point in time
1954
	save_installed_db();
1955
      }
1956
    }
1957
  }
1958
  check_running_as_root();
1959
77.1.40 by Monty Taylor
More naming changes.
1960
  mtr_log_init("$opt_vardir/log/drizzle-test-run.log");
1 by brian
clean slate
1961
1962
}
1963
1964
sub mysql_install_db () {
1965
1966
  if ($max_master_num > 1)
1967
  {
1968
    copy_install_db('master', $master->[1]->{'path_myddir'});
1969
  }
1970
1971
  # Install the number of slave databses needed
1972
  for (my $idx= 0; $idx < $max_slave_num; $idx++)
1973
  {
1974
    copy_install_db("slave".($idx+1), $slave->[$idx]->{'path_myddir'});
1975
  }
1976
1977
  return 0;
1978
}
1979
1980
1981
sub copy_install_db ($$) {
1982
  my $type=      shift;
1983
  my $data_dir=  shift;
1984
1985
  mtr_report("Installing \u$type Database");
1986
1987
  # Just copy the installed db from first master
1988
  mtr_copy_dir($master->[0]->{'path_myddir'}, $data_dir);
1989
1990
}
1991
1992
1993
#
1994
# Restore snapshot of the installed slave databases
1995
# if the snapshot exists
1996
#
1997
sub restore_slave_databases ($) {
1998
  my ($num_slaves)= @_;
1999
2000
  if ( -d $path_snapshot)
2001
  {
2002
    for (my $idx= 0; $idx < $num_slaves; $idx++)
2003
    {
2004
      my $data_dir= $slave->[$idx]->{'path_myddir'};
2005
      my $name= basename($data_dir);
2006
      mtr_rmtree($data_dir);
2007
      mtr_copy_dir("$path_snapshot/$name", $data_dir);
2008
    }
2009
  }
2010
}
2011
2012
2013
sub run_testcase_check_skip_test($)
2014
{
2015
  my ($tinfo)= @_;
2016
2017
  # ----------------------------------------------------------------------
2018
  # If marked to skip, just print out and return.
2019
  # Note that a test case not marked as 'skip' can still be
2020
  # skipped later, because of the test case itself in cooperation
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2021
  # with the drizzletest program tells us so.
1 by brian
clean slate
2022
  # ----------------------------------------------------------------------
2023
2024
  if ( $tinfo->{'skip'} )
2025
  {
2026
    mtr_report_test_name($tinfo);
2027
    mtr_report_test_skipped($tinfo);
2028
    return 1;
2029
  }
2030
2031
  return 0;
2032
}
2033
2034
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2035
sub do_before_run_drizzletest($)
1 by brian
clean slate
2036
{
2037
  my $tinfo= shift;
2038
  my $args;
2039
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2040
  # Remove old files produced by drizzletest
1 by brian
clean slate
2041
  my $base_file= mtr_match_extension($tinfo->{'result_file'},
2042
				    "result"); # Trim extension
2043
  unlink("$base_file.reject");
2044
  unlink("$base_file.progress");
2045
  unlink("$base_file.log");
2046
  unlink("$base_file.warnings");
2047
2048
}
2049
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2050
sub do_after_run_drizzletest($)
1 by brian
clean slate
2051
{
2052
  my $tinfo= shift;
2053
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2054
  # Save info from this testcase run to drizzletest.log
2055
  mtr_appendfile_to_file($path_current_test_log, $path_drizzletest_log)
1 by brian
clean slate
2056
    if -f $path_current_test_log;
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2057
  mtr_appendfile_to_file($path_timefile, $path_drizzletest_log)
1 by brian
clean slate
2058
    if -f $path_timefile;
2059
}
2060
2061
2062
sub run_testcase_mark_logs($$)
2063
{
2064
  my ($tinfo, $log_msg)= @_;
2065
2066
  # Write a marker to all log files
2067
2068
  # The file indicating current test name
2069
  mtr_tonewfile($path_current_test_log, $log_msg);
2070
2071
  # each mysqld's .err file
2072
  foreach my $mysqld (@{$master}, @{$slave})
2073
  {
2074
    mtr_tofile($mysqld->{path_myerr}, $log_msg);
2075
  }
2076
2077
}
2078
2079
sub find_testcase_skipped_reason($)
2080
{
2081
  my ($tinfo)= @_;
2082
2083
  # Set default message
2084
  $tinfo->{'comment'}= "Detected by testcase(no log file)";
2085
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2086
  # Open drizzletest-time(the drizzletest log file)
1 by brian
clean slate
2087
  my $F= IO::File->new($path_timefile)
2088
    or return;
2089
  my $reason;
2090
2091
  while ( my $line= <$F> )
2092
  {
2093
    # Look for "reason: <reason for skipping test>"
2094
    if ( $line =~ /reason: (.*)/ )
2095
    {
2096
      $reason= $1;
2097
    }
2098
  }
2099
2100
  if ( ! $reason )
2101
  {
2102
    mtr_warning("Could not find reason for skipping test in $path_timefile");
2103
    $reason= "Detected by testcase(reason unknown) ";
2104
  }
2105
  $tinfo->{'comment'}= $reason;
2106
}
2107
2108
2109
##############################################################################
2110
#
2111
#  Run a single test case
2112
#
2113
##############################################################################
2114
2115
# When we get here, we have already filtered out test cases that doesn't
2116
# apply to the current setup, for example if we use a running server, test
2117
# cases that restart the server are dropped. So this function should mostly
2118
# be about doing things, not a lot of logic.
2119
2120
# We don't start and kill the servers for each testcase. But some
2121
# testcases needs a restart, because they specify options to start
2122
# mysqld with. After that testcase, we need to restart again, to set
2123
# back the normal options.
2124
2125
sub run_testcase ($) {
2126
  my $tinfo=  shift;
2127
2128
  # -------------------------------------------------------
2129
  # Init variables that can change between each test case
2130
  # -------------------------------------------------------
2131
2132
  $ENV{'TZ'}= $tinfo->{'timezone'};
2133
  mtr_verbose("Setting timezone: $tinfo->{'timezone'}");
2134
2135
  my $master_restart= run_testcase_need_master_restart($tinfo);
2136
  my $slave_restart= run_testcase_need_slave_restart($tinfo);
2137
2138
  if ($master_restart or $slave_restart)
2139
  {
2140
    # Can't restart a running server that may be in use
2141
    if ( $opt_extern )
2142
    {
2143
      mtr_report_test_name($tinfo);
2144
      $tinfo->{comment}= "Can't restart a running server";
2145
      mtr_report_test_skipped($tinfo);
2146
      return;
2147
    }
2148
2149
    run_testcase_stop_servers($tinfo, $master_restart, $slave_restart);
2150
  }
2151
2152
  # Write to all log files to indicate start of testcase
2153
  run_testcase_mark_logs($tinfo, "CURRENT_TEST: $tinfo->{name}\n");
2154
2155
  my $died= mtr_record_dead_children();
2156
  if ($died or $master_restart or $slave_restart)
2157
  {
2158
    if (run_testcase_start_servers($tinfo))
2159
    {
2160
      mtr_report_test_name($tinfo);
2161
      report_failure_and_restart($tinfo);
2162
      return 1;
2163
    }
2164
  }
2165
  # ----------------------------------------------------------------------
2166
  # If --start-and-exit or --start-dirty given, stop here to let user manually
2167
  # run tests
2168
  # ----------------------------------------------------------------------
2169
  if ( $opt_start_and_exit or $opt_start_dirty )
2170
  {
2171
    mtr_timer_stop_all($glob_timers);
2172
    mtr_report("\nServers started, exiting");
2173
    exit(0);
2174
  }
2175
2176
  {
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2177
    do_before_run_drizzletest($tinfo);
1 by brian
clean slate
2178
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2179
    my $res= run_drizzletest($tinfo);
1 by brian
clean slate
2180
    mtr_report_test_name($tinfo);
2181
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2182
    do_after_run_drizzletest($tinfo);
1 by brian
clean slate
2183
2184
    if ( $res == 0 )
2185
    {
2186
      mtr_report_test_passed($tinfo);
2187
    }
2188
    elsif ( $res == 62 )
2189
    {
2190
      # Testcase itself tell us to skip this one
2191
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2192
      # Try to get reason from drizzletest.log
1 by brian
clean slate
2193
      find_testcase_skipped_reason($tinfo);
2194
      mtr_report_test_skipped($tinfo);
2195
    }
2196
    elsif ( $res == 63 )
2197
    {
2198
      $tinfo->{'timeout'}= 1;           # Mark as timeout
2199
      report_failure_and_restart($tinfo);
2200
    }
2201
    elsif ( $res == 1 )
2202
    {
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2203
      # Test case failure reported by drizzletest
1 by brian
clean slate
2204
      report_failure_and_restart($tinfo);
2205
    }
2206
    else
2207
    {
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2208
      # drizzletest failed, probably crashed
1 by brian
clean slate
2209
      $tinfo->{comment}=
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2210
	"drizzletest returned unexpected code $res, it has probably crashed";
1 by brian
clean slate
2211
      report_failure_and_restart($tinfo);
2212
    }
2213
  }
2214
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2215
  # Remove the file that drizzletest writes info to
1 by brian
clean slate
2216
  unlink($path_timefile);
2217
2218
  # ----------------------------------------------------------------------
2219
  # Stop Instance Manager if we are processing an IM-test case.
2220
  # ----------------------------------------------------------------------
2221
}
2222
2223
2224
#
2225
# Save a snapshot of the installed test db(s)
2226
# I.e take a snapshot of the var/ dir
2227
#
2228
sub save_installed_db () {
2229
2230
  mtr_report("Saving snapshot of installed databases");
2231
  mtr_rmtree($path_snapshot);
2232
2233
  foreach my $data_dir (@data_dir_lst)
2234
  {
2235
    my $name= basename($data_dir);
2236
    mtr_copy_dir("$data_dir", "$path_snapshot/$name");
2237
  }
2238
}
2239
2240
2241
#
2242
# Save any interesting files in the data_dir
2243
# before the data dir is removed.
2244
#
2245
sub save_files_before_restore($$) {
2246
  my $test_name= shift;
2247
  my $data_dir= shift;
2248
  my $save_name= "$opt_vardir/log/$test_name";
2249
2250
  # Look for core files
2251
  foreach my $core_file ( glob("$data_dir/core*") )
2252
  {
2253
    last if $opt_max_save_core > 0 && $num_saved_cores >= $opt_max_save_core;
2254
    my $core_name= basename($core_file);
2255
    mtr_report("Saving $core_name");
2256
    mkdir($save_name) if ! -d $save_name;
2257
    rename("$core_file", "$save_name/$core_name");
2258
    ++$num_saved_cores;
2259
  }
2260
}
2261
2262
2263
#
2264
# Restore snapshot of the installed test db(s)
2265
# if the snapshot exists
2266
#
2267
sub restore_installed_db ($) {
2268
  my $test_name= shift;
2269
2270
  if ( -d $path_snapshot)
2271
  {
2272
    mtr_report("Restoring snapshot of databases");
2273
2274
    foreach my $data_dir (@data_dir_lst)
2275
    {
2276
      my $name= basename($data_dir);
2277
      save_files_before_restore($test_name, $data_dir);
2278
      mtr_rmtree("$data_dir");
2279
      mtr_copy_dir("$path_snapshot/$name", "$data_dir");
2280
    }
2281
  }
2282
  else
2283
  {
2284
    # No snapshot existed
2285
    mtr_error("No snapshot existed");
2286
  }
2287
}
2288
2289
sub report_failure_and_restart ($) {
2290
  my $tinfo= shift;
2291
2292
  mtr_report_test_failed($tinfo);
2293
  print "\n";
2294
  if ( $opt_force )
2295
  {
2296
    # Stop all servers that are known to be running
2297
    stop_all_servers();
2298
2299
    # Restore the snapshot of the installed test db
2300
    restore_installed_db($tinfo->{'name'});
2301
    mtr_report("Resuming Tests\n");
2302
    return;
2303
  }
2304
2305
  my $test_mode= join(" ", @::glob_test_mode) || "default";
2306
  mtr_report("Aborting: $tinfo->{'name'} failed in $test_mode mode. ");
2307
  mtr_report("To continue, re-run with '--force'.");
2308
  if ( ! $glob_debugger and
89 by Brian Aker
Saving changes/removals to test run
2309
       ! $opt_extern )
1 by brian
clean slate
2310
  {
2311
    stop_all_servers();
2312
  }
2313
  mtr_exit(1);
2314
2315
}
2316
2317
2318
sub run_master_init_script ($) {
2319
  my ($tinfo)= @_;
2320
  my $init_script= $tinfo->{'master_sh'};
2321
2322
  # Run master initialization shell script if one exists
2323
  if ( $init_script )
2324
  {
2325
    my $ret= mtr_run("/bin/sh", [$init_script], "", "", "", "");
2326
    if ( $ret != 0 )
2327
    {
2328
      # FIXME rewrite those scripts to return 0 if successful
2329
      # mtr_warning("$init_script exited with code $ret");
2330
    }
2331
  }
2332
}
2333
2334
2335
##############################################################################
2336
#
2337
#  Start and stop servers
2338
#
2339
##############################################################################
2340
2341
2342
sub do_before_start_master ($) {
2343
  my ($tinfo)= @_;
2344
2345
  my $tname= $tinfo->{'name'};
2346
2347
  # FIXME what about second master.....
2348
2349
  # Don't delete anything if starting dirty
2350
  return if ($opt_start_dirty);
2351
2352
  foreach my $bin ( glob("$opt_vardir/log/master*-bin*") )
2353
  {
2354
    unlink($bin);
2355
  }
2356
2357
  # FIXME only remove the ones that are tied to this master
2358
  # Remove old master.info and relay-log.info files
2359
  unlink("$master->[0]->{'path_myddir'}/master.info");
2360
  unlink("$master->[0]->{'path_myddir'}/relay-log.info");
2361
  unlink("$master->[1]->{'path_myddir'}/master.info");
2362
  unlink("$master->[1]->{'path_myddir'}/relay-log.info");
2363
2364
  run_master_init_script($tinfo);
2365
}
2366
2367
2368
sub do_before_start_slave ($) {
2369
  my ($tinfo)= @_;
2370
2371
  my $tname= $tinfo->{'name'};
2372
  my $init_script= $tinfo->{'master_sh'};
2373
2374
  # Don't delete anything if starting dirty
2375
  return if ($opt_start_dirty);
2376
2377
  foreach my $bin ( glob("$opt_vardir/log/slave*-bin*") )
2378
  {
2379
    unlink($bin);
2380
  }
2381
2382
  unlink("$slave->[0]->{'path_myddir'}/master.info");
2383
  unlink("$slave->[0]->{'path_myddir'}/relay-log.info");
2384
2385
  # Run slave initialization shell script if one exists
2386
  if ( $init_script )
2387
  {
2388
    my $ret= mtr_run("/bin/sh", [$init_script], "", "", "", "");
2389
    if ( $ret != 0 )
2390
    {
2391
      # FIXME rewrite those scripts to return 0 if successful
2392
      # mtr_warning("$init_script exited with code $ret");
2393
    }
2394
  }
2395
2396
  foreach my $bin ( glob("$slave->[0]->{'path_myddir'}/log.*") )
2397
  {
2398
    unlink($bin);
2399
  }
2400
}
2401
2402
2403
sub mysqld_arguments ($$$$) {
2404
  my $args=              shift;
2405
  my $mysqld=            shift;
2406
  my $extra_opt=         shift;
2407
  my $slave_master_info= shift;
2408
2409
  my $idx= $mysqld->{'idx'};
2410
  my $sidx= "";                 # Index as string, 0 is empty string
2411
  if ( $idx> 0 )
2412
  {
2413
    $sidx= $idx;
2414
  }
2415
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2416
  my $prefix= "";               # If drizzletest server arg
1 by brian
clean slate
2417
2418
  mtr_add_arg($args, "%s--no-defaults", $prefix);
2419
685.1.29 by Monty Taylor
Some more cleanups to mtr.
2420
  $path_my_basedir= collapse_path($path_my_basedir);
1 by brian
clean slate
2421
  mtr_add_arg($args, "%s--basedir=%s", $prefix, $path_my_basedir);
2422
496.1.1 by Paul McCullagh
Added --engine option to drizzle-test-run (default innodb)
2423
  if ($opt_engine)
2424
  {
2425
    mtr_add_arg($args, "%s--default-storage-engine=%s", $prefix, $opt_engine);
2426
  }
2427
1 by brian
clean slate
2428
  if ( $mysql_version_id >= 50036)
2429
  {
2430
    # By default, prevent the started mysqld to access files outside of vardir
2431
    mtr_add_arg($args, "%s--secure-file-priv=%s", $prefix, $opt_vardir);
2432
  }
2433
2434
  mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
2435
2436
  # Increase default connect_timeout to avoid intermittent
2437
  # disconnects when test servers are put under load
2438
  # see BUG#28359
971.3.60 by Eric Day
Moved connect_timeout, net_*_timeout, and retry_count to plugin.
2439
  mtr_add_arg($args, "%s--oldlibdrizzle-connect-timeout=60", $prefix);
1 by brian
clean slate
2440
2441
2442
  # When mysqld is run by a root user(euid is 0), it will fail
2443
  # to start unless we specify what user to run as, see BUG#30630
2444
  my $euid= $>;
87 by Brian Aker
First pass on cleaning out mysql-test-run
2445
  if (grep(/^--user/, @$extra_opt, @opt_extra_mysqld_opt) == 0) {
1 by brian
clean slate
2446
    mtr_add_arg($args, "%s--user=root", $prefix);
2447
  }
2448
2449
  mtr_add_arg($args, "%s--pid-file=%s", $prefix,
2450
	      $mysqld->{'path_pid'});
2451
2452
  mtr_add_arg($args, "%s--port=%d", $prefix,
2453
                $mysqld->{'port'});
2454
2455
  mtr_add_arg($args, "%s--datadir=%s", $prefix,
2456
	      $mysqld->{'path_myddir'});
2457
2458
  # Check if "extra_opt" contains --skip-log-bin
2459
  if ( $mysqld->{'type'} eq 'master' )
2460
  {
2461
    mtr_add_arg($args, "%s--server-id=%d", $prefix,
2462
	       $idx > 0 ? $idx + 101 : 1);
2463
2464
    mtr_add_arg($args, "%s--loose-innodb_data_file_path=ibdata1:10M:autoextend",
2465
		$prefix);
2466
656.1.43 by Monty Taylor
Quick fix to lower the innodb_lock_wait_timeout so that the stinking lock_wait_timeout tests don't take a year and a day.
2467
    mtr_add_arg($args, "%s--loose-innodb-lock-wait-timeout=5", $prefix);
2468
1 by brian
clean slate
2469
    if ( $idx > 0 or !$use_innodb)
2470
    {
2471
      mtr_add_arg($args, "%s--loose-skip-innodb", $prefix);
2472
    }
2473
  }
2474
  else
2475
  {
2476
    mtr_error("unknown mysqld type")
2477
      unless $mysqld->{'type'} eq 'slave';
2478
2479
    # Directory where slaves find the dumps generated by "load data"
2480
    # on the server. The path need to have constant length otherwise
2481
    # test results will vary, thus a relative path is used.
2482
    my $slave_load_path= "../tmp";
2483
2484
    if ( @$slave_master_info )
2485
    {
2486
      foreach my $arg ( @$slave_master_info )
2487
      {
2488
        mtr_add_arg($args, "%s%s", $prefix, $arg);
2489
      }
2490
    }
2491
    else
2492
    {
2493
      my $slave_server_id=  2 + $idx;
2494
      my $slave_rpl_rank= $slave_server_id;
2495
      mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
2496
    }
2497
  } # end slave
2498
2499
  if ( $opt_debug )
2500
  {
2501
    mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/%s%s.trace",
2502
                $prefix, $path_vardir_trace, $mysqld->{'type'}, $sidx);
2503
  }
2504
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);
2508
2509
  if ( $opt_warnings )
2510
  {
2511
    mtr_add_arg($args, "%s--log-warnings", $prefix);
2512
  }
2513
2514
  # Indicate to "mysqld" it will be debugged in debugger
2515
  if ( $glob_debugger )
2516
  {
2517
    mtr_add_arg($args, "%s--gdb", $prefix);
2518
  }
2519
2520
  my $found_skip_core= 0;
2521
  foreach my $arg ( @opt_extra_mysqld_opt, @$extra_opt )
2522
  {
2523
    # Allow --skip-core-file to be set in <testname>-[master|slave].opt file
2524
    if ($arg eq "--skip-core-file")
2525
    {
2526
      $found_skip_core= 1;
2527
    }
2528
    else
2529
    {
2530
      mtr_add_arg($args, "%s%s", $prefix, $arg);
2531
    }
2532
  }
2533
  if ( !$found_skip_core )
2534
  {
2535
    mtr_add_arg($args, "%s%s", $prefix, "--core-file");
2536
  }
2537
2538
  return $args;
2539
}
2540
2541
2542
##############################################################################
2543
#
2544
#  Start mysqld and return the PID
2545
#
2546
##############################################################################
2547
2548
sub mysqld_start ($$$) {
2549
  my $mysqld=            shift;
2550
  my $extra_opt=         shift;
2551
  my $slave_master_info= shift;
2552
2553
  my $args;                             # Arg vector
2554
  my $exe;
2555
  my $pid= -1;
2556
  my $wait_for_pid_file= 1;
2557
2558
  my $type= $mysqld->{'type'};
2559
  my $idx= $mysqld->{'idx'};
2560
2561
  if ( $type eq 'master' )
2562
  {
2563
    $exe= $exe_master_mysqld;
2564
  }
2565
  elsif ( $type eq 'slave' )
2566
  {
2567
    $exe= $exe_slave_mysqld;
2568
  }
2569
  else
2570
  {
2571
    mtr_error("Unknown 'type' \"$type\" passed to mysqld_start");
2572
  }
2573
2574
  mtr_init_args(\$args);
2575
2576
  if ( $opt_valgrind_mysqld )
2577
  {
2578
    valgrind_arguments($args, \$exe);
2579
  }
2580
2581
  mysqld_arguments($args,$mysqld,$extra_opt,$slave_master_info);
2582
2583
  if ( $opt_gdb || $opt_manual_gdb)
2584
  {
2585
    gdb_arguments(\$args, \$exe, "$type"."_$idx");
2586
  }
2587
  elsif ( $opt_ddd || $opt_manual_ddd )
2588
  {
2589
    ddd_arguments(\$args, \$exe, "$type"."_$idx");
2590
  }
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
2591
  if ( $opt_dbx || $opt_manual_dbx)
2592
  {
2593
    dbx_arguments(\$args, \$exe, "$type"."_$idx");
2594
  }
1 by brian
clean slate
2595
  elsif ( $opt_debugger )
2596
  {
2597
    debugger_arguments(\$args, \$exe, "$type"."_$idx");
2598
  }
2599
  elsif ( $opt_manual_debug )
2600
  {
2601
     print "\nStart $type in your debugger\n" .
2602
           "dir: $glob_mysql_test_dir\n" .
2603
           "exe: $exe\n" .
2604
	   "args:  " . join(" ", @$args)  . "\n\n" .
2605
	   "Waiting ....\n";
2606
2607
     # Indicate the exe should not be started
2608
    $exe= undef;
2609
  }
2610
  else
2611
  {
2612
    # Default to not wait until pid file has been created
2613
    $wait_for_pid_file= 0;
2614
  }
2615
2616
  # Remove the pidfile
2617
  unlink($mysqld->{'path_pid'});
2618
2619
  if ( defined $exe )
2620
  {
2621
    $pid= mtr_spawn($exe, $args, "",
2622
		    $mysqld->{'path_myerr'},
2623
		    $mysqld->{'path_myerr'},
2624
		    "",
2625
		    { append_log_file => 1 });
2626
  }
2627
2628
2629
  if ( $wait_for_pid_file && !sleep_until_file_created($mysqld->{'path_pid'},
2630
						       $mysqld->{'start_timeout'},
2631
						       $pid))
2632
  {
2633
2634
    mtr_error("Failed to start mysqld $mysqld->{'type'}");
2635
  }
2636
2637
2638
  # Remember pid of the started process
2639
  $mysqld->{'pid'}= $pid;
2640
2641
  # Remember options used when starting
2642
  $mysqld->{'start_opts'}= $extra_opt;
2643
  $mysqld->{'start_slave_master_info'}= $slave_master_info;
2644
2645
  mtr_verbose("mysqld pid: $pid");
2646
  return $pid;
2647
}
2648
2649
2650
sub stop_all_servers () {
2651
2652
  mtr_report("Stopping All Servers");
2653
2654
  my %admin_pids; # hash of admin processes that requests shutdown
2655
  my @kill_pids;  # list of processes to shutdown/kill
2656
  my $pid;
2657
2658
  # Start shutdown of all started masters
2659
  foreach my $mysqld (@{$slave}, @{$master})
2660
  {
2661
    if ( $mysqld->{'pid'} )
2662
    {
973.1.3 by Toru Maesaka
Remove drizzleadmin from the repository and fix the test suite for it.
2663
      $pid= mtr_server_shutdown($mysqld);
1 by brian
clean slate
2664
      $admin_pids{$pid}= 1;
2665
2666
      push(@kill_pids,{
2667
		       pid      => $mysqld->{'pid'},
2668
                       real_pid => $mysqld->{'real_pid'},
2669
		       pidfile  => $mysqld->{'path_pid'},
2670
		       sockfile => $mysqld->{'path_sock'},
2671
		       port     => $mysqld->{'port'},
2672
                       errfile  => $mysqld->{'path_myerr'},
2673
		      });
2674
2675
      $mysqld->{'pid'}= 0; # Assume we are done with it
2676
    }
2677
  }
2678
2679
  # Wait blocking until all shutdown processes has completed
2680
  mtr_wait_blocking(\%admin_pids);
2681
2682
  # Make sure that process has shutdown else try to kill them
2683
  mtr_check_stop_servers(\@kill_pids);
2684
}
2685
2686
2687
sub run_testcase_need_master_restart($)
2688
{
2689
  my ($tinfo)= @_;
2690
2691
  # We try to find out if we are to restart the master(s)
2692
  my $do_restart= 0;          # Assumes we don't have to
2693
89 by Brian Aker
Saving changes/removals to test run
2694
  if ( $tinfo->{'master_sh'} )
1 by brian
clean slate
2695
  {
2696
    $do_restart= 1;           # Always restart if script to run
2697
    mtr_verbose("Restart master: Always restart if script to run");
2698
  }
2699
  if ( $tinfo->{'force_restart'} )
2700
  {
2701
    $do_restart= 1; # Always restart if --force-restart in -opt file
2702
    mtr_verbose("Restart master: Restart forced with --force-restart");
2703
  }
2704
  elsif( $tinfo->{'component_id'} eq 'im' )
2705
  {
2706
    $do_restart= 1;
2707
    mtr_verbose("Restart master: Always restart for im tests");
2708
  }
2709
  elsif ( $master->[0]->{'running_master_options'} and
2710
	  $master->[0]->{'running_master_options'}->{'timezone'} ne
2711
	  $tinfo->{'timezone'})
2712
  {
2713
    $do_restart= 1;
2714
    mtr_verbose("Restart master: Different timezone");
2715
  }
2716
  # Check that running master was started with same options
2717
  # as the current test requires
2718
  elsif (! mtr_same_opts($master->[0]->{'start_opts'},
2719
                         $tinfo->{'master_opt'}) )
2720
  {
2721
    # Chech that diff is binlog format only
2722
    my $diff_opts= mtr_diff_opts($master->[0]->{'start_opts'},$tinfo->{'master_opt'});
2723
    if (scalar(@$diff_opts) eq 2) 
2724
    {
798.2.11 by Brian Aker
Factor test-run for binlog removal
2725
      $do_restart= 1;
1 by brian
clean slate
2726
    }
2727
    else
2728
    {
2729
      $do_restart= 1;
2730
      mtr_verbose("Restart master: running with different options '" .
2731
	         join(" ", @{$tinfo->{'master_opt'}}) . "' != '" .
2732
	  	join(" ", @{$master->[0]->{'start_opts'}}) . "'" );
2733
    }
2734
  }
2735
  elsif( ! $master->[0]->{'pid'} )
2736
  {
2737
    if ( $opt_extern )
2738
    {
2739
      $do_restart= 0;
2740
      mtr_verbose("No restart: using extern master");
2741
    }
2742
    else
2743
    {
2744
      $do_restart= 1;
2745
      mtr_verbose("Restart master: master is not started");
2746
    }
2747
  }
2748
  return $do_restart;
2749
}
2750
2751
sub run_testcase_need_slave_restart($)
2752
{
2753
  my ($tinfo)= @_;
2754
2755
  # We try to find out if we are to restart the slaves
2756
  my $do_slave_restart= 0;     # Assumes we don't have to
2757
89 by Brian Aker
Saving changes/removals to test run
2758
  if ( $max_slave_num == 0)
1 by brian
clean slate
2759
  {
2760
    mtr_verbose("Skip slave restart: No testcase use slaves");
2761
  }
2762
  else
2763
  {
2764
2765
    # Check if any slave is currently started
2766
    my $any_slave_started= 0;
2767
    foreach my $mysqld (@{$slave})
2768
    {
2769
      if ( $mysqld->{'pid'} )
2770
      {
2771
	$any_slave_started= 1;
2772
	last;
2773
      }
2774
    }
2775
2776
    if ($any_slave_started)
2777
    {
2778
      mtr_verbose("Restart slave: Slave is started, always restart");
2779
      $do_slave_restart= 1;
2780
    }
2781
    elsif ( $tinfo->{'slave_num'} )
2782
    {
2783
      mtr_verbose("Restart slave: Test need slave");
2784
      $do_slave_restart= 1;
2785
    }
2786
  }
2787
2788
  return $do_slave_restart;
2789
2790
}
2791
2792
# ----------------------------------------------------------------------
2793
# If not using a running servers we may need to stop and restart.
2794
# We restart in the case we have initiation scripts, server options
2795
# etc to run. But we also restart again after the test first restart
2796
# and test is run, to get back to normal server settings.
2797
#
2798
# To make the code a bit more clean, we actually only stop servers
2799
# here, and mark this to be done. Then a generic "start" part will
2800
# start up the needed servers again.
2801
# ----------------------------------------------------------------------
2802
2803
sub run_testcase_stop_servers($$$) {
2804
  my ($tinfo, $do_restart, $do_slave_restart)= @_;
2805
  my $pid;
2806
  my %admin_pids; # hash of admin processes that requests shutdown
2807
  my @kill_pids;  # list of processes to shutdown/kill
2808
2809
  # Remember if we restarted for this test case (count restarts)
2810
  $tinfo->{'restarted'}= $do_restart;
2811
2812
  if ( $do_restart )
2813
  {
2814
    delete $master->[0]->{'running_master_options'}; # Forget history
2815
2816
    # Start shutdown of all started masters
2817
    foreach my $mysqld (@{$master})
2818
    {
2819
      if ( $mysqld->{'pid'} )
2820
      {
973.1.3 by Toru Maesaka
Remove drizzleadmin from the repository and fix the test suite for it.
2821
        $pid= mtr_server_shutdown($mysqld);
2822
2823
        $admin_pids{$pid}= 1;
2824
2825
        push(@kill_pids,{
2826
              pid      => $mysqld->{'pid'},
2827
              real_pid => $mysqld->{'real_pid'},
2828
              pidfile  => $mysqld->{'path_pid'},
2829
              sockfile => $mysqld->{'path_sock'},
2830
              port     => $mysqld->{'port'},
2831
              errfile   => $mysqld->{'path_myerr'},
2832
        });
2833
2834
        $mysqld->{'pid'}= 0; # Assume we are done with it
1 by brian
clean slate
2835
      }
2836
    }
2837
  }
2838
2839
  if ( $do_restart || $do_slave_restart )
2840
  {
2841
2842
    delete $slave->[0]->{'running_slave_options'}; # Forget history
2843
2844
    # Start shutdown of all started slaves
2845
    foreach my $mysqld (@{$slave})
2846
    {
2847
      if ( $mysqld->{'pid'} )
2848
      {
973.1.3 by Toru Maesaka
Remove drizzleadmin from the repository and fix the test suite for it.
2849
        $pid= mtr_server_shutdown($mysqld);
2850
2851
        $admin_pids{$pid}= 1;
2852
2853
        push(@kill_pids,{
2854
              pid      => $mysqld->{'pid'},
2855
              real_pid => $mysqld->{'real_pid'},
2856
              pidfile  => $mysqld->{'path_pid'},
2857
              sockfile => $mysqld->{'path_sock'},
2858
              port     => $mysqld->{'port'},
2859
              errfile  => $mysqld->{'path_myerr'},
2860
        });
2861
2862
        $mysqld->{'pid'}= 0; # Assume we are done with it
1 by brian
clean slate
2863
      }
2864
    }
2865
  }
2866
2867
  # ----------------------------------------------------------------------
2868
  # Shutdown has now been started and lists for the shutdown processes
2869
  # and the processes to be killed has been created
2870
  # ----------------------------------------------------------------------
2871
2872
  # Wait blocking until all shutdown processes has completed
2873
  mtr_wait_blocking(\%admin_pids);
2874
2875
2876
  # Make sure that process has shutdown else try to kill them
2877
  mtr_check_stop_servers(\@kill_pids);
2878
}
2879
2880
2881
#
2882
# run_testcase_start_servers
2883
#
2884
# Start the servers needed by this test case
2885
#
2886
# RETURN
2887
#  0 OK
2888
#  1 Start failed
2889
#
2890
2891
sub run_testcase_start_servers($) {
2892
  my $tinfo= shift;
2893
  my $tname= $tinfo->{'name'};
2894
2895
  if ( $tinfo->{'component_id'} eq 'mysqld' )
2896
  {
2897
    if ( !$master->[0]->{'pid'} )
2898
    {
2899
      # Master mysqld is not started
2900
      do_before_start_master($tinfo);
2901
2902
      mysqld_start($master->[0],$tinfo->{'master_opt'},[]);
2903
2904
    }
2905
2906
    # Save this test case information, so next can examine it
2907
    $master->[0]->{'running_master_options'}= $tinfo;
2908
  }
2909
2910
  # ----------------------------------------------------------------------
2911
  # Start slaves - if needed
2912
  # ----------------------------------------------------------------------
2913
  if ( $tinfo->{'slave_num'} )
2914
  {
2915
    restore_slave_databases($tinfo->{'slave_num'});
2916
2917
    do_before_start_slave($tinfo);
2918
2919
    for ( my $idx= 0; $idx <  $tinfo->{'slave_num'}; $idx++ )
2920
    {
2921
      if ( ! $slave->[$idx]->{'pid'} )
2922
      {
2923
	mysqld_start($slave->[$idx],$tinfo->{'slave_opt'},
2924
		     $tinfo->{'slave_mi'});
2925
2926
      }
2927
    }
2928
2929
    # Save this test case information, so next can examine it
2930
    $slave->[0]->{'running_slave_options'}= $tinfo;
2931
  }
2932
2933
  # Wait for mysqld's to start
2934
  foreach my $mysqld (@{$master},@{$slave})
2935
  {
2936
2937
    next if !$mysqld->{'pid'};
2938
2939
    if (mysqld_wait_started($mysqld))
2940
    {
2941
      # failed to start
2942
      $tinfo->{'comment'}=
2943
	"Failed to start $mysqld->{'type'} mysqld $mysqld->{'idx'}";
2944
      return 1;
2945
    }
2946
  }
2947
  return 0;
2948
}
2949
2950
#
2951
# Run include/check-testcase.test
2952
# Before a testcase, run in record mode, save result file to var
2953
# After testcase, run and compare with the recorded file, they should be equal!
2954
#
2955
# RETURN VALUE
2956
#  0 OK
2957
#  1 Check failed
2958
#
2959
sub run_check_testcase ($$) {
2960
2961
  my $mode=     shift;
2962
  my $mysqld=   shift;
2963
2964
  my $name= "check-" . $mysqld->{'type'} . $mysqld->{'idx'};
2965
2966
  my $args;
2967
  mtr_init_args(\$args);
2968
2969
  mtr_add_arg($args, "--no-defaults");
2970
  mtr_add_arg($args, "--silent");
2971
  mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
2972
2973
  mtr_add_arg($args, "--port=%d", $mysqld->{'port'});
2974
  mtr_add_arg($args, "--database=test");
2975
  mtr_add_arg($args, "--user=%s", $opt_user);
2976
  mtr_add_arg($args, "--password=");
2977
2978
  mtr_add_arg($args, "-R");
2979
  mtr_add_arg($args, "$opt_vardir/tmp/$name.result");
2980
2981
  if ( $mode eq "before" )
2982
  {
2983
    mtr_add_arg($args, "--record");
2984
  }
2985
685.1.22 by Monty Taylor
Added testdir setting support to drizzletest.
2986
  if ( $opt_testdir )
2987
  {
2988
    mtr_add_arg($args, "--testdir=%s", $opt_testdir);
2989
  }
2990
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2991
  my $res = mtr_run_test($exe_drizzletest,$args,
1 by brian
clean slate
2992
	        "include/check-testcase.test", "", "", "");
2993
2994
  if ( $res == 1  and $mode eq "after")
2995
  {
2996
    mtr_run("diff",["-u",
2997
		    "$opt_vardir/tmp/$name.result",
2998
		    "$opt_vardir/tmp/$name.reject"],
2999
	    "", "", "", "");
3000
  }
3001
  elsif ( $res )
3002
  {
3003
    mtr_error("Could not execute 'check-testcase' $mode testcase");
3004
  }
3005
  return $res;
3006
}
3007
3008
##############################################################################
3009
#
3010
#  Report the features that were compiled in
3011
#
3012
##############################################################################
3013
3014
sub run_report_features () {
3015
  my $args;
3016
3017
  {
3018
    mysqld_start($master->[0],[],[]);
3019
    if ( ! $master->[0]->{'pid'} )
3020
    {
3021
      mtr_error("Can't start the mysqld server");
3022
    }
3023
    mysqld_wait_started($master->[0]);
3024
  }
3025
3026
  my $tinfo = {};
3027
  $tinfo->{'name'} = 'report features';
3028
  $tinfo->{'result_file'} = undef;
3029
  $tinfo->{'component_id'} = 'mysqld';
3030
  $tinfo->{'path'} = 'include/report-features.test';
3031
  $tinfo->{'timezone'}=  "GMT-3";
3032
  $tinfo->{'slave_num'} = 0;
3033
  $tinfo->{'master_opt'} = [];
3034
  $tinfo->{'slave_opt'} = [];
3035
  $tinfo->{'slave_mi'} = [];
3036
  $tinfo->{'comment'} = 'report server features';
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3037
  run_drizzletest($tinfo);
1 by brian
clean slate
3038
3039
  {
3040
    stop_all_servers();
3041
  }
3042
}
3043
3044
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3045
sub run_drizzletest ($) {
1 by brian
clean slate
3046
  my ($tinfo)= @_;
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3047
  my $exe= $exe_drizzletest;
1 by brian
clean slate
3048
  my $args;
3049
3050
  mtr_init_args(\$args);
3051
3052
  mtr_add_arg($args, "--no-defaults");
3053
  mtr_add_arg($args, "--silent");
3054
  mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
3055
  mtr_add_arg($args, "--logdir=%s/log", $opt_vardir);
3056
3057
  # Log line number and time  for each line in .test file
3058
  mtr_add_arg($args, "--mark-progress")
3059
    if $opt_mark_progress;
3060
3061
  {
3062
    mtr_add_arg($args, "--port=%d", $master->[0]->{'port'});
3063
    mtr_add_arg($args, "--database=test");
3064
    mtr_add_arg($args, "--user=%s", $opt_user);
3065
    mtr_add_arg($args, "--password=");
3066
  }
3067
3068
  if ( $opt_strace_client )
3069
  {
3070
    $exe=  "strace";            # FIXME there are ktrace, ....
3071
    mtr_add_arg($args, "-o");
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3072
    mtr_add_arg($args, "%s/log/drizzletest.strace", $opt_vardir);
3073
    mtr_add_arg($args, "$exe_drizzletest");
1 by brian
clean slate
3074
  }
3075
3076
  if ( $opt_timer )
3077
  {
3078
    mtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir);
3079
  }
3080
3081
  if ( $opt_compress )
3082
  {
3083
    mtr_add_arg($args, "--compress");
3084
  }
3085
3086
  if ( $opt_sleep )
3087
  {
3088
    mtr_add_arg($args, "--sleep=%d", $opt_sleep);
3089
  }
3090
3091
  if ( $opt_debug )
3092
  {
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3093
    mtr_add_arg($args, "--debug=d:t:A,%s/log/drizzletest.trace",
1 by brian
clean slate
3094
		$path_vardir_trace);
3095
  }
3096
685.1.22 by Monty Taylor
Added testdir setting support to drizzletest.
3097
  if ( $opt_testdir )
3098
  {
3099
    mtr_add_arg($args, "--testdir=%s", $opt_testdir);
3100
  }
3101
3102
1 by brian
clean slate
3103
  # ----------------------------------------------------------------------
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
3104
  # export DRIZZLE_TEST variable containing <path>/drizzletest <args>
1 by brian
clean slate
3105
  # ----------------------------------------------------------------------
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
3106
  $ENV{'DRIZZLE_TEST'}=
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3107
    mtr_native_path($exe_drizzletest) . " " . join(" ", @$args);
1 by brian
clean slate
3108
3109
  # ----------------------------------------------------------------------
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
3110
  # Add arguments that should not go into the DRIZZLE_TEST env var
1 by brian
clean slate
3111
  # ----------------------------------------------------------------------
3112
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3113
  if ( $opt_valgrind_drizzletest )
1 by brian
clean slate
3114
  {
3115
    # Prefix the Valgrind options to the argument list.
3116
    # We do this here, since we do not want to Valgrind the nested invocations
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3117
    # of drizzletest; that would mess up the stderr output causing test failure.
1 by brian
clean slate
3118
    my @args_saved = @$args;
3119
    mtr_init_args(\$args);
3120
    valgrind_arguments($args, \$exe);
3121
    mtr_add_arg($args, "%s", $_) for @args_saved;
3122
  }
3123
3124
  mtr_add_arg($args, "--test-file=%s", $tinfo->{'path'});
3125
3126
  # Number of lines of resut to include in failure report
3127
  mtr_add_arg($args, "--tail-lines=20");
3128
3129
  if ( defined $tinfo->{'result_file'} ) {
3130
    mtr_add_arg($args, "--result-file=%s", $tinfo->{'result_file'});
3131
  }
3132
3133
  if ( $opt_record )
3134
  {
3135
    mtr_add_arg($args, "--record");
3136
  }
3137
3138
  if ( $opt_client_gdb )
3139
  {
3140
    gdb_arguments(\$args, \$exe, "client");
3141
  }
3142
  elsif ( $opt_client_ddd )
3143
  {
3144
    ddd_arguments(\$args, \$exe, "client");
3145
  }
3146
  elsif ( $opt_client_debugger )
3147
  {
3148
    debugger_arguments(\$args, \$exe, "client");
3149
  }
3150
3151
  if ( $opt_check_testcases )
3152
  {
3153
    foreach my $mysqld (@{$master}, @{$slave})
3154
    {
3155
      if ($mysqld->{'pid'})
3156
      {
3157
	run_check_testcase("before", $mysqld);
3158
      }
3159
    }
3160
  }
3161
3162
  my $res = mtr_run_test($exe,$args,"","",$path_timefile,"");
3163
3164
  if ( $opt_check_testcases )
3165
  {
3166
    foreach my $mysqld (@{$master}, @{$slave})
3167
    {
3168
      if ($mysqld->{'pid'})
3169
      {
3170
	if (run_check_testcase("after", $mysqld))
3171
	{
3172
	  # Check failed, mark the test case with that info
3173
	  $tinfo->{'check_testcase_failed'}= 1;
3174
	}
3175
      }
3176
    }
3177
  }
3178
3179
  return $res;
3180
3181
}
3182
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
3183
#
3184
# Modify the exe and args so that program is run in gdb in xterm
3185
#
3186
sub dbx_arguments {
3187
  my $args= shift;
3188
  my $exe=  shift;
3189
  my $type= shift;
3190
3191
  # Write $args to gdb init file
3192
  my $str= join(" ", @$$args);
3193
  my $dbx_init_file= "$opt_tmpdir/dbxinit.$type";
3194
3195
  # Remove the old gdbinit file
3196
  unlink($dbx_init_file);
1101.1.32 by Monty Taylor
Fixed the mtr launching a bit.
3197
  if ( $type eq "client" )
3198
  {
3199
    # write init file for client
3200
    mtr_tofile($dbx_init_file,
3201
               "runargs $str\n" .
3202
               "run\n");
3203
  }
3204
  else
3205
  {
3206
    # write init file for drizzled
3207
    mtr_tofile($dbx_init_file,
3208
               "stop in mysql_parse\n" .
3209
               "runargs $str\n" .
3210
               "run\n" .
3211
               "\n");
3212
  }
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
3213
3214
  if ( $opt_manual_dbx )
3215
  {
3216
     print "\nTo start dbx for $type, type in another window:\n";
1101.1.32 by Monty Taylor
Fixed the mtr launching a bit.
3217
     print "dbx -c 'source $dbx_init_file' $$exe\n";
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
3218
3219
     # Indicate the exe should not be started
3220
     $$exe= undef;
3221
     return;
3222
  }
3223
3224
  $$args= [];
3225
  mtr_add_arg($$args, "-title");
3226
  mtr_add_arg($$args, "$type");
3227
  mtr_add_arg($$args, "-e");
3228
3229
  mtr_add_arg($$args, "dbx");
3230
  mtr_add_arg($$args, "-c");
1101.1.32 by Monty Taylor
Fixed the mtr launching a bit.
3231
  mtr_add_arg($$args, "source $dbx_init_file");
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
3232
  mtr_add_arg($$args, "$$exe");
3233
3234
  $$exe= "xterm";
3235
}
1 by brian
clean slate
3236
3237
#
3238
# Modify the exe and args so that program is run in gdb in xterm
3239
#
3240
sub gdb_arguments {
3241
  my $args= shift;
3242
  my $exe=  shift;
3243
  my $type= shift;
3244
3245
  # Write $args to gdb init file
3246
  my $str= join(" ", @$$args);
3247
  my $gdb_init_file= "$opt_tmpdir/gdbinit.$type";
3248
3249
  # Remove the old gdbinit file
3250
  unlink($gdb_init_file);
3251
3252
  if ( $type eq "client" )
3253
  {
3254
    # write init file for client
3255
    mtr_tofile($gdb_init_file,
3256
	       "set args $str\n" .
3257
	       "break main\n");
3258
  }
3259
  else
3260
  {
3261
    # write init file for mysqld
3262
    mtr_tofile($gdb_init_file,
3263
	       "set args $str\n" .
3264
	       "break mysql_parse\n" .
3265
	       "commands 1\n" .
3266
	       "disable 1\n" .
3267
	       "end\n" .
3268
	       "run");
3269
  }
3270
3271
  if ( $opt_manual_gdb )
3272
  {
3273
     print "\nTo start gdb for $type, type in another window:\n";
3274
     print "gdb -cd $glob_mysql_test_dir -x $gdb_init_file $$exe\n";
3275
3276
     # Indicate the exe should not be started
3277
     $$exe= undef;
3278
     return;
3279
  }
3280
3281
  $$args= [];
3282
  mtr_add_arg($$args, "-title");
3283
  mtr_add_arg($$args, "$type");
3284
  mtr_add_arg($$args, "-e");
3285
3286
  if ( $exe_libtool )
3287
  {
3288
    mtr_add_arg($$args, $exe_libtool);
3289
    mtr_add_arg($$args, "--mode=execute");
3290
  }
3291
3292
  mtr_add_arg($$args, "gdb");
3293
  mtr_add_arg($$args, "-x");
3294
  mtr_add_arg($$args, "$gdb_init_file");
3295
  mtr_add_arg($$args, "$$exe");
3296
3297
  $$exe= "xterm";
3298
}
3299
3300
3301
#
3302
# Modify the exe and args so that program is run in ddd
3303
#
3304
sub ddd_arguments {
3305
  my $args= shift;
3306
  my $exe=  shift;
3307
  my $type= shift;
3308
3309
  # Write $args to ddd init file
3310
  my $str= join(" ", @$$args);
3311
  my $gdb_init_file= "$opt_tmpdir/gdbinit.$type";
3312
3313
  # Remove the old gdbinit file
3314
  unlink($gdb_init_file);
3315
3316
  if ( $type eq "client" )
3317
  {
3318
    # write init file for client
3319
    mtr_tofile($gdb_init_file,
3320
	       "set args $str\n" .
3321
	       "break main\n");
3322
  }
3323
  else
3324
  {
3325
    # write init file for mysqld
3326
    mtr_tofile($gdb_init_file,
3327
	       "file $$exe\n" .
3328
	       "set args $str\n" .
3329
	       "break mysql_parse\n" .
3330
	       "commands 1\n" .
3331
	       "disable 1\n" .
3332
	       "end");
3333
  }
3334
3335
  if ( $opt_manual_ddd )
3336
  {
3337
     print "\nTo start ddd for $type, type in another window:\n";
3338
     print "ddd -cd $glob_mysql_test_dir -x $gdb_init_file $$exe\n";
3339
3340
     # Indicate the exe should not be started
3341
     $$exe= undef;
3342
     return;
3343
  }
3344
3345
  my $save_exe= $$exe;
3346
  $$args= [];
3347
  if ( $exe_libtool )
3348
  {
3349
    $$exe= $exe_libtool;
3350
    mtr_add_arg($$args, "--mode=execute");
3351
    mtr_add_arg($$args, "ddd");
3352
  }
3353
  else
3354
  {
3355
    $$exe= "ddd";
3356
  }
3357
  mtr_add_arg($$args, "--command=$gdb_init_file");
3358
  mtr_add_arg($$args, "$save_exe");
3359
}
3360
3361
3362
#
3363
# Modify the exe and args so that program is run in the selected debugger
3364
#
3365
sub debugger_arguments {
3366
  my $args= shift;
3367
  my $exe=  shift;
3368
  my $debugger= $opt_debugger || $opt_client_debugger;
3369
3370
  if ( $debugger =~ /vcexpress|vc|devenv/ )
3371
  {
3372
    # vc[express] /debugexe exe arg1 .. argn
3373
3374
    # Add /debugexe and name of the exe before args
3375
    unshift(@$$args, "/debugexe");
3376
    unshift(@$$args, "$$exe");
3377
3378
    # Set exe to debuggername
3379
    $$exe= $debugger;
3380
3381
  }
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
3382
  #elsif ( $debugger eq "dbx" )
3383
  #{
3384
  #  # xterm -e dbx -r exe arg1 .. argn
3385
#
3386
#    unshift(@$$args, $$exe);
3387
#    unshift(@$$args, "-r");
3388
#    unshift(@$$args, $debugger);
3389
#    unshift(@$$args, "-e");
3390
#
3391
#    $$exe= "xterm";
3392
#
3393
#  }
1 by brian
clean slate
3394
  else
3395
  {
3396
    mtr_error("Unknown argument \"$debugger\" passed to --debugger");
3397
  }
3398
}
3399
3400
3401
#
3402
# Modify the exe and args so that program is run in valgrind
3403
#
3404
sub valgrind_arguments {
3405
  my $args= shift;
3406
  my $exe=  shift;
3407
3408
  if ( $opt_callgrind)
3409
  {
3410
    mtr_add_arg($args, "--tool=callgrind");
3411
    mtr_add_arg($args, "--base=$opt_vardir/log");
3412
  }
3413
  else
3414
  {
3415
    mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
3416
    mtr_add_arg($args, "--leak-check=yes");
3417
    mtr_add_arg($args, "--num-callers=16");
3418
    mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir)
3419
      if -f "$glob_mysql_test_dir/valgrind.supp";
3420
  }
3421
3422
  # Add valgrind options, can be overriden by user
3423
  mtr_add_arg($args, '%s', $_) for (@valgrind_args);
3424
3425
  mtr_add_arg($args, $$exe);
3426
3427
  $$exe= $opt_valgrind_path || "valgrind";
3428
3429
  if ($exe_libtool)
3430
  {
3431
    # Add "libtool --mode-execute" before the test to execute
3432
    # if running in valgrind(to avoid valgrinding bash)
3433
    unshift(@$args, "--mode=execute", $$exe);
3434
    $$exe= $exe_libtool;
3435
  }
3436
}
3437
3438
87 by Brian Aker
First pass on cleaning out mysql-test-run
3439
sub mysqld_wait_started($){
3440
  my $mysqld= shift;
3441
3442
  if (sleep_until_file_created($mysqld->{'path_pid'},
3443
            $mysqld->{'start_timeout'},
3444
            $mysqld->{'pid'}) == 0)
3445
  {
3446
    # Failed to wait for pid file
3447
    return 1;
3448
  }
3449
3450
  # Get the "real pid" of the process, it will be used for killing
3451
  # the process in ActiveState's perl on windows
3452
  $mysqld->{'real_pid'}= mtr_get_pid_from_file($mysqld->{'path_pid'});
3453
3454
  return 0;
3455
}
3456
685.1.25 by Monty Taylor
Fixed absolute path generation for real. Sigh.
3457
sub collapse_path ($) {
3458
685.1.29 by Monty Taylor
Some more cleanups to mtr.
3459
    my $c_path= rel2abs(shift);
685.1.25 by Monty Taylor
Fixed absolute path generation for real. Sigh.
3460
    my $updir  = updir($c_path);
3461
    my $curdir = curdir($c_path);
3462
3463
    my($vol, $dirs, $file) = splitpath($c_path);
3464
    my @dirs = splitdir($dirs);
3465
3466
    my @collapsed;
3467
    foreach my $dir (@dirs) {
3468
        if( $dir eq $updir              and   # if we have an updir
3469
            @collapsed                  and   # and something to collapse
3470
            length $collapsed[-1]       and   # and its not the rootdir
3471
            $collapsed[-1] ne $updir    and   # nor another updir
3472
            $collapsed[-1] ne $curdir         # nor the curdir
3473
          )
3474
        {                                     # then
3475
            pop @collapsed;                   # collapse
3476
        }
3477
        else {                                # else
3478
            push @collapsed, $dir;            # just hang onto it
3479
        }
3480
    }
3481
3482
    return catpath($vol, catdir(@collapsed), $file);
3483
}
87 by Brian Aker
First pass on cleaning out mysql-test-run
3484
1 by brian
clean slate
3485
##############################################################################
3486
#
3487
#  Usage
3488
#
3489
##############################################################################
3490
3491
sub usage ($) {
3492
  my $message= shift;
3493
3494
  if ( $message )
3495
  {
3496
    print STDERR "$message\n";
3497
  }
3498
3499
  print <<HERE;
3500
3501
$0 [ OPTIONS ] [ TESTCASE ]
3502
3503
Options to control what engine/variation to run
3504
3505
  compress              Use the compressed protocol between client and server
3506
  bench                 Run the benchmark suite
3507
  small-bench           Run the benchmarks with --small-tests --small-tables
3508
3509
Options to control directories to use
3510
  benchdir=DIR          The directory where the benchmark suite is stored
3511
                        (default: ../../mysql-bench)
3512
  tmpdir=DIR            The directory where temporary files are stored
3513
                        (default: ./var/tmp).
3514
  vardir=DIR            The directory where files generated from the test run
3515
                        is stored (default: ./var). Specifying a ramdisk or
3516
                        tmpfs will speed up tests.
3517
  mem                   Run testsuite in "memory" using tmpfs or ramdisk
3518
                        Attempts to find a suitable location
3519
                        using a builtin list of standard locations
3520
                        for tmpfs (/dev/shm)
3521
                        The option can also be set using environment
3522
                        variable MTR_MEM=[DIR]
3523
3524
Options to control what test suites or cases to run
3525
3526
  force                 Continue to run the suite after failure
3527
  do-test=PREFIX or REGEX
3528
                        Run test cases which name are prefixed with PREFIX
3529
                        or fulfills REGEX
3530
  skip-test=PREFIX or REGEX
3531
                        Skip test cases which name are prefixed with PREFIX
3532
                        or fulfills REGEX
3533
  start-from=PREFIX     Run test cases starting from test prefixed with PREFIX
3534
  suite[s]=NAME1,..,NAMEN Collect tests in suites from the comma separated
3535
                        list of suite names.
3536
                        The default is: "$opt_suites_default"
3537
  skip-rpl              Skip the replication test cases.
3538
  combination="ARG1 .. ARG2" Specify a set of "mysqld" arguments for one
3539
                        combination.
3540
  skip-combination      Skip any combination options and combinations files
974.1.1 by Stewart Smith
add repeat-test=n option to test-run.pl to repeat a test n times
3541
  repeat-test=n         How many times to repeat each test (default: 1)
1 by brian
clean slate
3542
3543
Options that specify ports
3544
3545
  master_port=PORT      Specify the port number used by the first master
3546
  slave_port=PORT       Specify the port number used by the first slave
3547
  mtr-build-thread=#    Specify unique collection of ports. Can also be set by
3548
                        setting the environment variable MTR_BUILD_THREAD.
3549
3550
Options for test case authoring
3551
3552
  record TESTNAME       (Re)genereate the result file for TESTNAME
3553
  check-testcases       Check testcases for sideeffects
3554
  mark-progress         Log line number and elapsed time to <testname>.progress
3555
3556
Options that pass on options
3557
3558
  mysqld=ARGS           Specify additional arguments to "mysqld"
3559
3560
Options to run test on running server
3561
3562
  extern                Use running server for tests
3563
  user=USER             User for connection to extern server
3564
3565
Options for debugging the product
3566
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3567
  client-ddd            Start drizzletest client in ddd
3568
  client-debugger=NAME  Start drizzletest in the selected debugger
3569
  client-gdb            Start drizzletest client in gdb
1 by brian
clean slate
3570
  ddd                   Start mysqld in ddd
3571
  debug                 Dump trace output for all servers and client programs
3572
  debugger=NAME         Start mysqld in the selected debugger
3573
  gdb                   Start the mysqld(s) in gdb
3574
  manual-debug          Let user manually start mysqld in debugger, before
3575
                        running test(s)
3576
  manual-gdb            Let user manually start mysqld in gdb, before running
3577
                        test(s)
3578
  manual-ddd            Let user manually start mysqld in ddd, before running
3579
                        test(s)
3580
  master-binary=PATH    Specify the master "mysqld" to use
3581
  slave-binary=PATH     Specify the slave "mysqld" to use
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3582
  strace-client         Create strace output for drizzletest client
1 by brian
clean slate
3583
  max-save-core         Limit the number of core files saved (to avoid filling
3584
                        up disks for heavily crashing server). Defaults to
3585
                        $opt_max_save_core, set to 0 for no limit.
3586
3587
Options for coverage, profiling etc
3588
3589
  gcov                  FIXME
191 by Brian Aker
Merge from mark
3590
  gprof                 See online documentation on how to use it.
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3591
  valgrind              Run the "drizzletest" and "mysqld" executables using
1 by brian
clean slate
3592
                        valgrind with default options
3593
  valgrind-all          Synonym for --valgrind
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3594
  valgrind-drizzletest    Run the "drizzletest" and "drizzle_client_test" executable
1 by brian
clean slate
3595
                        with valgrind
3596
  valgrind-mysqld       Run the "mysqld" executable with valgrind
3597
  valgrind-options=ARGS Deprecated, use --valgrind-option
3598
  valgrind-option=ARGS  Option to give valgrind, replaces default option(s),
3599
                        can be specified more then once
3600
  valgrind-path=[EXE]   Path to the valgrind executable
3601
  callgrind             Instruct valgrind to use callgrind
3602
3603
Misc options
3604
3605
  comment=STR           Write STR to the output
3606
  notimer               Don't show test case execution time
3607
  script-debug          Debug this script itself
3608
  verbose               More verbose output
3609
  start-and-exit        Only initialize and start the servers, using the
3610
                        startup settings for the specified test case (if any)
3611
  start-dirty           Only start the servers (without initialization) for
3612
                        the specified test case (if any)
3613
  fast                  Don't try to clean up from earlier runs
3614
  reorder               Reorder tests to get fewer server restarts
3615
  help                  Get this help text
3616
3617
  testcase-timeout=MINUTES Max test case run time (default $default_testcase_timeout)
3618
  suite-timeout=MINUTES Max test suite run time (default $default_suite_timeout)
3619
  warnings | log-warnings Pass --log-warnings to mysqld
3620
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3621
  sleep=SECONDS         Passed to drizzletest, will be used as fixed sleep time
1 by brian
clean slate
3622
3623
HERE
3624
  mtr_exit(1);
3625
3626
}