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