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