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