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