~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
1863
  # Remove old log files
1864
  foreach my $name (glob("r/*.progress r/*.log r/*.warnings"))
1865
  {
1866
    unlink($name);
1867
  }
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.
1868
  system("chmod -R ugo+r $opt_vardir");
988.3.1 by lbieber
fix test suite permission problem - https://bugs.launchpad.net/drizzle/+bug/324689
1869
  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
1870
  system("chmod -R ugo+rw $opt_vardir/filesystem_ln/*");
1 by brian
clean slate
1871
}
1872
1873
1874
sub  check_running_as_root () {
1875
  # Check if running as root
1876
  # i.e a file can be read regardless what mode we set it to
1877
  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.
1878
  dtr_tofile($test_file, "Drizzle");
1 by brian
clean slate
1879
  chmod(oct("0000"), $test_file);
1880
1881
  my $result="";
1882
  if (open(FILE,"<",$test_file))
1883
  {
1884
    $result= join('', <FILE>);
1885
    close FILE;
1886
  }
1887
1888
  # Some filesystems( for example CIFS) allows reading a file
1889
  # although mode was set to 0000, but in that case a stat on
1890
  # the file will not return 0000
1891
  my $file_mode= (stat($test_file))[2] & 07777;
1892
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
1893
  $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.
1894
  dtr_verbose("result: $result, file_mode: $file_mode");
1895
  if ($result eq "Drizzle" && $file_mode == 0)
1 by brian
clean slate
1896
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
1897
    dtr_warning("running this script as _root_ will cause some " .
1 by brian
clean slate
1898
                "tests to be skipped");
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
1899
    $ENV{'DRIZZLE_TEST_ROOT'}= "YES";
1 by brian
clean slate
1900
  }
1901
1902
  chmod(oct("0755"), $test_file);
1903
  unlink($test_file);
1904
1905
}
1906
1907
1908
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.
1909
  my $drizzled_variables= shift;
1 by brian
clean slate
1910
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
1911
  if ( ! $drizzled_variables->{'debug'} )
1 by brian
clean slate
1912
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
1913
    #dtr_report("Binaries are not debug compiled");
1 by brian
clean slate
1914
    $debug_compiled_binaries= 0;
1915
1916
    if ( $opt_debug )
1917
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
1918
      dtr_error("Can't use --debug, binaries does not support it");
1 by brian
clean slate
1919
    }
1920
    return;
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_report("Binaries are debug compiled");
1 by brian
clean slate
1923
  $debug_compiled_binaries= 1;
1924
}
1925
1926
1927
##############################################################################
1928
#
1929
#  Run the benchmark suite
1930
#
1931
##############################################################################
1932
1933
sub run_benchmarks ($) {
1934
  my $benchmark=  shift;
1935
1936
  my $args;
1937
1938
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
1939
    drizzled_start($master->[0],[],[]);
1 by brian
clean slate
1940
    if ( ! $master->[0]->{'pid'} )
1941
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
1942
      dtr_error("Can't start the drizzled server");
1 by brian
clean slate
1943
    }
1944
  }
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_init_args(\$args);
1 by brian
clean slate
1947
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
1948
  dtr_add_arg($args, "--user=%s", $opt_user);
1 by brian
clean slate
1949
1950
  if ( $opt_small_bench )
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, "--small-test");
1953
    dtr_add_arg($args, "--small-tables");
1 by brian
clean slate
1954
  }
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
  chdir($glob_drizzle_bench_dir)
1957
    or dtr_error("Couldn't chdir to '$glob_drizzle_bench_dir': $!");
1 by brian
clean slate
1958
1959
  if ( ! $benchmark )
1960
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
1961
    dtr_run("$glob_drizzle_bench_dir/run-all-tests", $args, "", "", "", "");
1 by brian
clean slate
1962
    # FIXME check result code?!
1963
  }
1964
  elsif ( -x $benchmark )
1965
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
1966
    dtr_run("$glob_drizzle_bench_dir/$benchmark", $args, "", "", "", "");
1 by brian
clean slate
1967
    # FIXME check result code?!
1968
  }
1969
  else
1970
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
1971
    dtr_error("Benchmark $benchmark not found");
1 by brian
clean slate
1972
  }
1973
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
1974
  chdir($glob_drizzle_test_dir);          # Go back
1 by brian
clean slate
1975
1976
  {
1977
    stop_masters();
1978
  }
1979
}
1980
1981
1982
##############################################################################
1983
#
1984
#  Run the tests
1985
#
1986
##############################################################################
1987
1988
sub run_tests () {
1989
  my ($tests)= @_;
1990
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
1991
  dtr_print_thick_line();
1992
1993
  dtr_timer_start($glob_timers,"suite", 60 * $opt_suite_timeout);
1994
1995
  dtr_report_tests_not_skipped_though_disabled($tests);
1996
1997
  dtr_print_header();
1 by brian
clean slate
1998
1999
  foreach my $tinfo ( @$tests )
2000
  {
974.1.1 by Stewart Smith
add repeat-test=n option to test-run.pl to repeat a test n times
2001
    foreach(1..$opt_repeat_test)
1 by brian
clean slate
2002
    {
974.1.1 by Stewart Smith
add repeat-test=n option to test-run.pl to repeat a test n times
2003
      if (run_testcase_check_skip_test($tinfo))
2004
	{
2005
	  next;
2006
	}
2007
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2008
      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
2009
      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.
2010
      dtr_timer_stop($glob_timers,"testcase");
1 by brian
clean slate
2011
    }
2012
  }
2013
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use 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_print_line();
1 by brian
clean slate
2015
2016
  if ( ! $glob_debugger and
89 by Brian Aker
Saving changes/removals to test run
2017
       ! $opt_extern )
1 by brian
clean slate
2018
  {
2019
    stop_all_servers();
2020
  }
2021
2022
  if ( $opt_gcov )
2023
  {
2024
    gcov_collect(); # collect coverage information
2025
  }
2026
  if ( $opt_gprof )
2027
  {
2028
    gprof_collect(); # collect coverage information
2029
  }
2030
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2031
  dtr_report_stats($tests);
1 by brian
clean slate
2032
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2033
  dtr_timer_stop($glob_timers,"suite");
1 by brian
clean slate
2034
}
2035
2036
2037
##############################################################################
2038
#
2039
#  Initiate the test databases
2040
#
2041
##############################################################################
2042
2043
sub initialize_servers () {
2044
2045
  datadir_list_setup();
2046
2047
  if ( $opt_extern )
2048
  {
2049
    # Running against an already started server, if the specified
2050
    # vardir does not already exist it should be created
2051
    if ( ! -d $opt_vardir )
2052
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2053
      dtr_report("Creating '$opt_vardir'");
1 by brian
clean slate
2054
      setup_vardir();
2055
    }
2056
    else
2057
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2058
      dtr_verbose("No need to create '$opt_vardir' it already exists");
1 by brian
clean slate
2059
    }
2060
  }
2061
  else
2062
  {
2063
    kill_running_servers();
2064
2065
    if ( ! $opt_start_dirty )
2066
    {
2067
      remove_stale_vardir();
2068
      setup_vardir();
2069
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2070
      drizzle_install_db();
1 by brian
clean slate
2071
      if ( $opt_force )
2072
      {
2073
	# Save a snapshot of the freshly installed db
2074
	# to make it possible to restore to a known point in time
2075
	save_installed_db();
2076
      }
2077
    }
2078
  }
2079
  check_running_as_root();
2080
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2081
  dtr_log_init("$opt_vardir/log/drizzle-test-run.log");
1 by brian
clean slate
2082
2083
}
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
sub drizzle_install_db () {
1 by brian
clean slate
2086
2087
  if ($max_master_num > 1)
2088
  {
1786.3.1 by Monty Taylor
Initial working local catalog.
2089
    copy_install_db('master', $master->[1]->{'path_myddir'} . "/local");
1 by brian
clean slate
2090
  }
2091
2092
  # Install the number of slave databses needed
2093
  for (my $idx= 0; $idx < $max_slave_num; $idx++)
2094
  {
2095
    copy_install_db("slave".($idx+1), $slave->[$idx]->{'path_myddir'});
2096
  }
2097
2098
  return 0;
2099
}
2100
2101
2102
sub copy_install_db ($$) {
2103
  my $type=      shift;
2104
  my $data_dir=  shift;
2105
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2106
  dtr_report("Installing \u$type Database");
1 by brian
clean slate
2107
2108
  # 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.
2109
  dtr_copy_dir($master->[0]->{'path_myddir'}, $data_dir);
1 by brian
clean slate
2110
2111
}
2112
2113
2114
#
2115
# Restore snapshot of the installed slave databases
2116
# if the snapshot exists
2117
#
2118
sub restore_slave_databases ($) {
2119
  my ($num_slaves)= @_;
2120
2121
  if ( -d $path_snapshot)
2122
  {
2123
    for (my $idx= 0; $idx < $num_slaves; $idx++)
2124
    {
2125
      my $data_dir= $slave->[$idx]->{'path_myddir'};
2126
      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.
2127
      dtr_rmtree($data_dir);
2128
      dtr_copy_dir("$path_snapshot/$name", $data_dir);
1 by brian
clean slate
2129
    }
2130
  }
2131
}
2132
2133
2134
sub run_testcase_check_skip_test($)
2135
{
2136
  my ($tinfo)= @_;
2137
2138
  # ----------------------------------------------------------------------
2139
  # If marked to skip, just print out and return.
2140
  # Note that a test case not marked as 'skip' can still be
2141
  # skipped later, because of the test case itself in cooperation
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2142
  # with the drizzletest program tells us so.
1 by brian
clean slate
2143
  # ----------------------------------------------------------------------
2144
2145
  if ( $tinfo->{'skip'} )
2146
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2147
    dtr_report_test_name($tinfo);
2148
    dtr_report_test_skipped($tinfo);
1 by brian
clean slate
2149
    return 1;
2150
  }
2151
2152
  return 0;
2153
}
2154
2155
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2156
sub do_before_run_drizzletest($)
1 by brian
clean slate
2157
{
2158
  my $tinfo= shift;
2159
  my $args;
2160
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2161
  # 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.
2162
  my $base_file= dtr_match_extension($tinfo->{'result_file'},
1 by brian
clean slate
2163
				    "result"); # Trim extension
2164
  unlink("$base_file.reject");
2165
  unlink("$base_file.progress");
2166
  unlink("$base_file.log");
2167
  unlink("$base_file.warnings");
2168
2169
}
2170
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2171
sub do_after_run_drizzletest($)
1 by brian
clean slate
2172
{
2173
  my $tinfo= shift;
2174
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2175
  # 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.
2176
  dtr_appendfile_to_file($path_current_test_log, $path_drizzletest_log)
1 by brian
clean slate
2177
    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.
2178
  dtr_appendfile_to_file($path_timefile, $path_drizzletest_log)
1 by brian
clean slate
2179
    if -f $path_timefile;
2180
}
2181
2182
2183
sub run_testcase_mark_logs($$)
2184
{
2185
  my ($tinfo, $log_msg)= @_;
2186
2187
  # Write a marker to all log files
2188
2189
  # 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.
2190
  dtr_tonewfile($path_current_test_log, $log_msg);
1 by brian
clean slate
2191
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2192
  # each drizzled's .err file
2193
  foreach my $drizzled (@{$master}, @{$slave})
1 by brian
clean slate
2194
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2195
    dtr_tofile($drizzled->{path_myerr}, $log_msg);
1 by brian
clean slate
2196
  }
2197
2198
}
2199
2200
sub find_testcase_skipped_reason($)
2201
{
2202
  my ($tinfo)= @_;
2203
2204
  # Set default message
2205
  $tinfo->{'comment'}= "Detected by testcase(no log file)";
2206
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2207
  # Open drizzletest-time(the drizzletest log file)
1 by brian
clean slate
2208
  my $F= IO::File->new($path_timefile)
2209
    or return;
2210
  my $reason;
2211
2212
  while ( my $line= <$F> )
2213
  {
2214
    # Look for "reason: <reason for skipping test>"
2215
    if ( $line =~ /reason: (.*)/ )
2216
    {
2217
      $reason= $1;
2218
    }
2219
  }
2220
2221
  if ( ! $reason )
2222
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2223
    dtr_warning("Could not find reason for skipping test in $path_timefile");
1 by brian
clean slate
2224
    $reason= "Detected by testcase(reason unknown) ";
2225
  }
2226
  $tinfo->{'comment'}= $reason;
2227
}
2228
2229
2230
##############################################################################
2231
#
2232
#  Run a single test case
2233
#
2234
##############################################################################
2235
2236
# When we get here, we have already filtered out test cases that doesn't
2237
# apply to the current setup, for example if we use a running server, test
2238
# cases that restart the server are dropped. So this function should mostly
2239
# be about doing things, not a lot of logic.
2240
2241
# We don't start and kill the servers for each testcase. But some
2242
# 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.
2243
# drizzled with. After that testcase, we need to restart again, to set
1 by brian
clean slate
2244
# back the normal options.
2245
2246
sub run_testcase ($) {
2247
  my $tinfo=  shift;
2248
2249
  # -------------------------------------------------------
2250
  # Init variables that can change between each test case
2251
  # -------------------------------------------------------
2252
2253
  $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.
2254
  dtr_verbose("Setting timezone: $tinfo->{'timezone'}");
1 by brian
clean slate
2255
2256
  my $master_restart= run_testcase_need_master_restart($tinfo);
2257
  my $slave_restart= run_testcase_need_slave_restart($tinfo);
2258
2259
  if ($master_restart or $slave_restart)
2260
  {
2261
    # Can't restart a running server that may be in use
2262
    if ( $opt_extern )
2263
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2264
      dtr_report_test_name($tinfo);
1 by brian
clean slate
2265
      $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.
2266
      dtr_report_test_skipped($tinfo);
1 by brian
clean slate
2267
      return;
2268
    }
2269
2270
    run_testcase_stop_servers($tinfo, $master_restart, $slave_restart);
2271
  }
2272
2273
  # Write to all log files to indicate start of testcase
2274
  run_testcase_mark_logs($tinfo, "CURRENT_TEST: $tinfo->{name}\n");
2275
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2276
  my $died= dtr_record_dead_children();
1 by brian
clean slate
2277
  if ($died or $master_restart or $slave_restart)
2278
  {
2279
    if (run_testcase_start_servers($tinfo))
2280
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2281
      dtr_report_test_name($tinfo);
1 by brian
clean slate
2282
      report_failure_and_restart($tinfo);
2283
      return 1;
2284
    }
2285
  }
2286
  # ----------------------------------------------------------------------
2287
  # If --start-and-exit or --start-dirty given, stop here to let user manually
2288
  # run tests
2289
  # ----------------------------------------------------------------------
2290
  if ( $opt_start_and_exit or $opt_start_dirty )
2291
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2292
    dtr_timer_stop_all($glob_timers);
2293
    dtr_report("\nServers started, exiting");
1 by brian
clean slate
2294
    exit(0);
2295
  }
2296
2297
  {
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2298
    do_before_run_drizzletest($tinfo);
1 by brian
clean slate
2299
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2300
    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.
2301
    dtr_report_test_name($tinfo);
1 by brian
clean slate
2302
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2303
    do_after_run_drizzletest($tinfo);
1 by brian
clean slate
2304
2305
    if ( $res == 0 )
2306
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2307
      dtr_report_test_passed($tinfo);
1 by brian
clean slate
2308
    }
2309
    elsif ( $res == 62 )
2310
    {
2311
      # Testcase itself tell us to skip this one
2312
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2313
      # Try to get reason from drizzletest.log
1 by brian
clean slate
2314
      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.
2315
      dtr_report_test_skipped($tinfo);
1 by brian
clean slate
2316
    }
2317
    elsif ( $res == 63 )
2318
    {
2319
      $tinfo->{'timeout'}= 1;           # Mark as timeout
2320
      report_failure_and_restart($tinfo);
2321
    }
2322
    elsif ( $res == 1 )
2323
    {
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2324
      # Test case failure reported by drizzletest
1 by brian
clean slate
2325
      report_failure_and_restart($tinfo);
2326
    }
2327
    else
2328
    {
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2329
      # drizzletest failed, probably crashed
1 by brian
clean slate
2330
      $tinfo->{comment}=
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2331
	"drizzletest returned unexpected code $res, it has probably crashed";
1 by brian
clean slate
2332
      report_failure_and_restart($tinfo);
2333
    }
2334
  }
2335
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2336
  # Remove the file that drizzletest writes info to
1 by brian
clean slate
2337
  unlink($path_timefile);
2338
2339
  # ----------------------------------------------------------------------
2340
  # Stop Instance Manager if we are processing an IM-test case.
2341
  # ----------------------------------------------------------------------
2342
}
2343
2344
2345
#
2346
# Save a snapshot of the installed test db(s)
2347
# I.e take a snapshot of the var/ dir
2348
#
2349
sub save_installed_db () {
2350
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2351
  dtr_report("Saving snapshot of installed databases");
2352
  dtr_rmtree($path_snapshot);
1 by brian
clean slate
2353
2354
  foreach my $data_dir (@data_dir_lst)
2355
  {
2356
    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.
2357
    dtr_copy_dir("$data_dir", "$path_snapshot/$name");
1 by brian
clean slate
2358
  }
2359
}
2360
2361
2362
#
2363
# Save any interesting files in the data_dir
2364
# before the data dir is removed.
2365
#
2366
sub save_files_before_restore($$) {
2367
  my $test_name= shift;
2368
  my $data_dir= shift;
2369
  my $save_name= "$opt_vardir/log/$test_name";
2370
2371
  # Look for core files
2372
  foreach my $core_file ( glob("$data_dir/core*") )
2373
  {
2374
    last if $opt_max_save_core > 0 && $num_saved_cores >= $opt_max_save_core;
2375
    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.
2376
    dtr_report("Saving $core_name");
1 by brian
clean slate
2377
    mkdir($save_name) if ! -d $save_name;
2378
    rename("$core_file", "$save_name/$core_name");
2379
    ++$num_saved_cores;
2380
  }
2381
}
2382
2383
2384
#
2385
# Restore snapshot of the installed test db(s)
2386
# if the snapshot exists
2387
#
2388
sub restore_installed_db ($) {
2389
  my $test_name= shift;
2390
2391
  if ( -d $path_snapshot)
2392
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2393
    dtr_report("Restoring snapshot of databases");
1 by brian
clean slate
2394
2395
    foreach my $data_dir (@data_dir_lst)
2396
    {
2397
      my $name= basename($data_dir);
2398
      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.
2399
      dtr_rmtree("$data_dir");
2400
      dtr_copy_dir("$path_snapshot/$name", "$data_dir");
1 by brian
clean slate
2401
    }
2402
  }
2403
  else
2404
  {
2405
    # 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.
2406
    dtr_error("No snapshot existed");
1 by brian
clean slate
2407
  }
2408
}
2409
2410
sub report_failure_and_restart ($) {
2411
  my $tinfo= shift;
2412
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2413
  dtr_report_test_failed($tinfo);
1 by brian
clean slate
2414
  print "\n";
2415
  if ( $opt_force )
2416
  {
2417
    # Stop all servers that are known to be running
2418
    stop_all_servers();
2419
2420
    # Restore the snapshot of the installed test db
2421
    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.
2422
    dtr_report("Resuming Tests\n");
1 by brian
clean slate
2423
    return;
2424
  }
2425
2426
  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.
2427
  dtr_report("Aborting: $tinfo->{'name'} failed in $test_mode mode. ");
2428
  dtr_report("To continue, re-run with '--force'.");
1 by brian
clean slate
2429
  if ( ! $glob_debugger and
89 by Brian Aker
Saving changes/removals to test run
2430
       ! $opt_extern )
1 by brian
clean slate
2431
  {
2432
    stop_all_servers();
2433
  }
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2434
  dtr_exit(1);
1 by brian
clean slate
2435
2436
}
2437
2438
2439
sub run_master_init_script ($) {
2440
  my ($tinfo)= @_;
2441
  my $init_script= $tinfo->{'master_sh'};
2442
2443
  # Run master initialization shell script if one exists
2444
  if ( $init_script )
2445
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2446
    my $ret= dtr_run("/bin/sh", [$init_script], "", "", "", "");
1 by brian
clean slate
2447
    if ( $ret != 0 )
2448
    {
2449
      # 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.
2450
      # dtr_warning("$init_script exited with code $ret");
1 by brian
clean slate
2451
    }
2452
  }
2453
}
2454
2455
2456
##############################################################################
2457
#
2458
#  Start and stop servers
2459
#
2460
##############################################################################
2461
2462
2463
sub do_before_start_master ($) {
2464
  my ($tinfo)= @_;
2465
2466
  my $tname= $tinfo->{'name'};
2467
2468
  # FIXME what about second master.....
2469
2470
  # Don't delete anything if starting dirty
2471
  return if ($opt_start_dirty);
2472
2473
  foreach my $bin ( glob("$opt_vardir/log/master*-bin*") )
2474
  {
2475
    unlink($bin);
2476
  }
2477
2478
  # FIXME only remove the ones that are tied to this master
2479
  # Remove old master.info and relay-log.info files
2480
  unlink("$master->[0]->{'path_myddir'}/master.info");
2481
  unlink("$master->[0]->{'path_myddir'}/relay-log.info");
2482
  unlink("$master->[1]->{'path_myddir'}/master.info");
2483
  unlink("$master->[1]->{'path_myddir'}/relay-log.info");
2484
2485
  run_master_init_script($tinfo);
2486
}
2487
2488
2489
sub do_before_start_slave ($) {
2490
  my ($tinfo)= @_;
2491
2492
  my $tname= $tinfo->{'name'};
2493
  my $init_script= $tinfo->{'master_sh'};
2494
2495
  # Don't delete anything if starting dirty
2496
  return if ($opt_start_dirty);
2497
2498
  foreach my $bin ( glob("$opt_vardir/log/slave*-bin*") )
2499
  {
2500
    unlink($bin);
2501
  }
2502
2503
  unlink("$slave->[0]->{'path_myddir'}/master.info");
2504
  unlink("$slave->[0]->{'path_myddir'}/relay-log.info");
2505
2506
  # Run slave initialization shell script if one exists
2507
  if ( $init_script )
2508
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2509
    my $ret= dtr_run("/bin/sh", [$init_script], "", "", "", "");
1 by brian
clean slate
2510
    if ( $ret != 0 )
2511
    {
2512
      # 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.
2513
      # dtr_warning("$init_script exited with code $ret");
1 by brian
clean slate
2514
    }
2515
  }
2516
2517
  foreach my $bin ( glob("$slave->[0]->{'path_myddir'}/log.*") )
2518
  {
2519
    unlink($bin);
2520
  }
2521
}
2522
2523
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2524
sub drizzled_arguments ($$$$) {
1 by brian
clean slate
2525
  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.
2526
  my $drizzled=            shift;
1 by brian
clean slate
2527
  my $extra_opt=         shift;
2528
  my $slave_master_info= shift;
2529
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2530
  my $idx= $drizzled->{'idx'};
1 by brian
clean slate
2531
  my $sidx= "";                 # Index as string, 0 is empty string
2532
  if ( $idx> 0 )
2533
  {
2534
    $sidx= $idx;
2535
  }
2536
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
2537
  my $prefix= "";               # If drizzletest server arg
1 by brian
clean slate
2538
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2539
  dtr_add_arg($args, "%s--no-defaults", $prefix);
1 by brian
clean slate
2540
496.1.1 by Paul McCullagh
Added --engine option to drizzle-test-run (default innodb)
2541
  if ($opt_engine)
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--default-storage-engine=%s", $prefix, $opt_engine);
496.1.1 by Paul McCullagh
Added --engine option to drizzle-test-run (default innodb)
2544
  }
2545
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
2546
  if ( $drizzle_version_id >= 50036)
1 by brian
clean slate
2547
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2548
    # By default, prevent the started drizzled to access files outside of vardir
2549
    dtr_add_arg($args, "%s--secure-file-priv=%s", $prefix, $opt_vardir);
1 by brian
clean slate
2550
  }
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
  dtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
1 by brian
clean slate
2553
2554
  # Increase default connect_timeout to avoid intermittent
2555
  # disconnects when test servers are put under load
2556
  # 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.
2557
  dtr_add_arg($args, "%s--mysql-protocol.connect-timeout=60", $prefix);
2558
2559
2560
  # When drizzled is run by a root user(euid is 0), it will fail
1 by brian
clean slate
2561
  # to start unless we specify what user to run as, see BUG#30630
2562
  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.
2563
  if (grep(/^--user/, @$extra_opt, @opt_extra_drizzled_opt) == 0) {
2564
    dtr_add_arg($args, "%s--user=root", $prefix);
1 by brian
clean slate
2565
  }
2566
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2567
  dtr_add_arg($args, "%s--pid-file=%s", $prefix,
2568
	      $drizzled->{'path_pid'});
2569
2570
  dtr_add_arg($args, "%s--mysql-protocol.port=%d", $prefix,
2571
              $drizzled->{'port'});
2572
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
2573
  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.
2574
              $drizzled->{'secondary_port'});
2575
2576
  dtr_add_arg($args, "%s--datadir=%s", $prefix,
2577
	      $drizzled->{'path_myddir'});
1 by brian
clean slate
2578
1945.1.4 by Monty Taylor
Fixes the issues with socket
2579
  dtr_add_arg($args, "%s--mysql-unix-socket-protocol.path=%s", $prefix,
2580
              $drizzled->{'path_sock'});
2581
1 by brian
clean slate
2582
  # 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.
2583
  if ( $drizzled->{'type'} eq 'master' )
1 by brian
clean slate
2584
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2585
    dtr_add_arg($args, "%s--server-id=%d", $prefix,
1 by brian
clean slate
2586
	       $idx > 0 ? $idx + 101 : 1);
2587
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2588
    dtr_add_arg($args,
1684.7.1 by Vijay Samuel
Merge re factored command line for embedded innodb
2589
      "%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.
2590
1 by brian
clean slate
2591
  }
2592
  else
2593
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2594
    dtr_error("unknown drizzled type")
2595
      unless $drizzled->{'type'} eq 'slave';
1 by brian
clean slate
2596
2597
    # Directory where slaves find the dumps generated by "load data"
2598
    # on the server. The path need to have constant length otherwise
2599
    # test results will vary, thus a relative path is used.
2600
    my $slave_load_path= "../tmp";
2601
2602
    if ( @$slave_master_info )
2603
    {
2604
      foreach my $arg ( @$slave_master_info )
2605
      {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2606
        dtr_add_arg($args, "%s%s", $prefix, $arg);
1 by brian
clean slate
2607
      }
2608
    }
2609
    else
2610
    {
2611
      my $slave_server_id=  2 + $idx;
2612
      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.
2613
      dtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
1 by brian
clean slate
2614
    }
2615
  } # end slave
2616
2617
  if ( $opt_debug )
2618
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2619
    dtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/%s%s.trace",
2620
                $prefix, $path_vardir_trace, $drizzled->{'type'}, $sidx);
1 by brian
clean slate
2621
  }
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--sort-buffer-size=256K", $prefix);
2624
  dtr_add_arg($args, "%s--max-heap-table-size=1M", $prefix);
1 by brian
clean slate
2625
2626
  if ( $opt_warnings )
2627
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2628
    dtr_add_arg($args, "%s--log-warnings", $prefix);
1 by brian
clean slate
2629
  }
2630
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2631
  # Indicate to "drizzled" it will be debugged in debugger
1 by brian
clean slate
2632
  if ( $glob_debugger )
2633
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2634
    dtr_add_arg($args, "%s--gdb", $prefix);
1 by brian
clean slate
2635
  }
2636
2637
  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.
2638
  foreach my $arg ( @opt_extra_drizzled_opt, @$extra_opt )
1 by brian
clean slate
2639
  {
2640
    # Allow --skip-core-file to be set in <testname>-[master|slave].opt file
2641
    if ($arg eq "--skip-core-file")
2642
    {
2643
      $found_skip_core= 1;
2644
    }
2645
    else
2646
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2647
      dtr_add_arg($args, "%s%s", $prefix, $arg);
1 by brian
clean slate
2648
    }
2649
  }
2650
  if ( !$found_skip_core )
2651
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2652
    dtr_add_arg($args, "%s%s", $prefix, "--core-file");
1 by brian
clean slate
2653
  }
2654
2655
  return $args;
2656
}
2657
2658
2659
##############################################################################
2660
#
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2661
#  Start drizzled and return the PID
1 by brian
clean slate
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
sub drizzled_start ($$$) {
2666
  my $drizzled=            shift;
1 by brian
clean slate
2667
  my $extra_opt=         shift;
2668
  my $slave_master_info= shift;
2669
2670
  my $args;                             # Arg vector
2671
  my $exe;
2672
  my $pid= -1;
2673
  my $wait_for_pid_file= 1;
2674
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2675
  my $type= $drizzled->{'type'};
2676
  my $idx= $drizzled->{'idx'};
1 by brian
clean slate
2677
2678
  if ( $type eq 'master' )
2679
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2680
    $exe= $exe_master_drizzled;
1 by brian
clean slate
2681
  }
2682
  elsif ( $type eq 'slave' )
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_slave_drizzled;
1 by brian
clean slate
2685
  }
2686
  else
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
    dtr_error("Unknown 'type' \"$type\" passed to drizzled_start");
1 by brian
clean slate
2689
  }
2690
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2691
  dtr_init_args(\$args);
1 by brian
clean slate
2692
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2693
  if ( $opt_valgrind_drizzled )
1 by brian
clean slate
2694
  {
2695
    valgrind_arguments($args, \$exe);
2696
  }
2697
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2698
  drizzled_arguments($args,$drizzled,$extra_opt,$slave_master_info);
1 by brian
clean slate
2699
2700
  if ( $opt_gdb || $opt_manual_gdb)
2701
  {
2702
    gdb_arguments(\$args, \$exe, "$type"."_$idx");
2703
  }
2704
  elsif ( $opt_ddd || $opt_manual_ddd )
2705
  {
2706
    ddd_arguments(\$args, \$exe, "$type"."_$idx");
2707
  }
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
2708
  if ( $opt_dbx || $opt_manual_dbx)
2709
  {
2710
    dbx_arguments(\$args, \$exe, "$type"."_$idx");
2711
  }
1 by brian
clean slate
2712
  elsif ( $opt_debugger )
2713
  {
2714
    debugger_arguments(\$args, \$exe, "$type"."_$idx");
2715
  }
2716
  elsif ( $opt_manual_debug )
2717
  {
2718
     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.
2719
           "dir: $glob_drizzle_test_dir\n" .
1 by brian
clean slate
2720
           "exe: $exe\n" .
2721
	   "args:  " . join(" ", @$args)  . "\n\n" .
2722
	   "Waiting ....\n";
2723
2724
     # Indicate the exe should not be started
2725
    $exe= undef;
2726
  }
2727
  else
2728
  {
2729
    # Default to not wait until pid file has been created
2730
    $wait_for_pid_file= 0;
2731
  }
2732
2733
  # 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.
2734
  unlink($drizzled->{'path_pid'});
1 by brian
clean slate
2735
2736
  if ( defined $exe )
2737
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use 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
    dtr_verbose("running Drizzle with: $exe @$args");
2739
    $pid= dtr_spawn($exe, $args, "",
2740
		    $drizzled->{'path_myerr'},
2741
		    $drizzled->{'path_myerr'},
1 by brian
clean slate
2742
		    "",
2743
		    { append_log_file => 1 });
2744
  }
2745
2746
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2747
  if ( $wait_for_pid_file && !sleep_until_file_created($drizzled->{'path_pid'},
2748
						       $drizzled->{'start_timeout'},
1 by brian
clean slate
2749
						       $pid))
2750
  {
2751
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2752
    dtr_error("Failed to start drizzled $drizzled->{'type'}");
1 by brian
clean slate
2753
  }
2754
2755
2756
  # 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.
2757
  $drizzled->{'pid'}= $pid;
1 by brian
clean slate
2758
2759
  # 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.
2760
  $drizzled->{'start_opts'}= $extra_opt;
2761
  $drizzled->{'start_slave_master_info'}= $slave_master_info;
1 by brian
clean slate
2762
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2763
  dtr_verbose("drizzled pid: $pid");
1 by brian
clean slate
2764
  return $pid;
2765
}
2766
2767
2768
sub stop_all_servers () {
2769
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2770
  dtr_report("Stopping All Servers");
1 by brian
clean slate
2771
2772
  my %admin_pids; # hash of admin processes that requests shutdown
2773
  my @kill_pids;  # list of processes to shutdown/kill
2774
  my $pid;
2775
2776
  # 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.
2777
  foreach my $drizzled (@{$slave}, @{$master})
1 by brian
clean slate
2778
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2779
    if ( $drizzled->{'pid'} )
1 by brian
clean slate
2780
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use 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
      $pid= dtr_server_shutdown($drizzled);
1 by brian
clean slate
2782
      $admin_pids{$pid}= 1;
2783
2784
      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.
2785
		       pid      => $drizzled->{'pid'},
2786
                       real_pid => $drizzled->{'real_pid'},
2787
		       pidfile  => $drizzled->{'path_pid'},
2788
		       sockfile => $drizzled->{'path_sock'},
2789
		       port     => $drizzled->{'port'},
2790
                       errfile  => $drizzled->{'path_myerr'},
1 by brian
clean slate
2791
		      });
2792
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2793
      $drizzled->{'pid'}= 0; # Assume we are done with it
1 by brian
clean slate
2794
    }
2795
  }
2796
2797
  # 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.
2798
  dtr_wait_blocking(\%admin_pids);
1 by brian
clean slate
2799
2800
  # 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.
2801
  dtr_check_stop_servers(\@kill_pids);
1 by brian
clean slate
2802
}
2803
2804
2805
sub run_testcase_need_master_restart($)
2806
{
2807
  my ($tinfo)= @_;
2808
2809
  # We try to find out if we are to restart the master(s)
2810
  my $do_restart= 0;          # Assumes we don't have to
2811
89 by Brian Aker
Saving changes/removals to test run
2812
  if ( $tinfo->{'master_sh'} )
1 by brian
clean slate
2813
  {
2814
    $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.
2815
    dtr_verbose("Restart master: Always restart if script to run");
1 by brian
clean slate
2816
  }
2817
  if ( $tinfo->{'force_restart'} )
2818
  {
2819
    $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.
2820
    dtr_verbose("Restart master: Restart forced with --force-restart");
1 by brian
clean slate
2821
  }
2822
  elsif( $tinfo->{'component_id'} eq 'im' )
2823
  {
2824
    $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.
2825
    dtr_verbose("Restart master: Always restart for im tests");
1 by brian
clean slate
2826
  }
2827
  elsif ( $master->[0]->{'running_master_options'} and
2828
	  $master->[0]->{'running_master_options'}->{'timezone'} ne
2829
	  $tinfo->{'timezone'})
2830
  {
2831
    $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.
2832
    dtr_verbose("Restart master: Different timezone");
1 by brian
clean slate
2833
  }
2834
  # Check that running master was started with same options
2835
  # 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.
2836
  elsif (! dtr_same_opts($master->[0]->{'start_opts'},
1 by brian
clean slate
2837
                         $tinfo->{'master_opt'}) )
2838
  {
2839
    # 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.
2840
    my $diff_opts= dtr_diff_opts($master->[0]->{'start_opts'},$tinfo->{'master_opt'});
1 by brian
clean slate
2841
    if (scalar(@$diff_opts) eq 2) 
2842
    {
798.2.11 by Brian Aker
Factor test-run for binlog removal
2843
      $do_restart= 1;
1 by brian
clean slate
2844
    }
2845
    else
2846
    {
2847
      $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.
2848
      dtr_verbose("Restart master: running with different options '" .
1 by brian
clean slate
2849
	         join(" ", @{$tinfo->{'master_opt'}}) . "' != '" .
2850
	  	join(" ", @{$master->[0]->{'start_opts'}}) . "'" );
2851
    }
2852
  }
2853
  elsif( ! $master->[0]->{'pid'} )
2854
  {
2855
    if ( $opt_extern )
2856
    {
2857
      $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.
2858
      dtr_verbose("No restart: using extern master");
1 by brian
clean slate
2859
    }
2860
    else
2861
    {
2862
      $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.
2863
      dtr_verbose("Restart master: master is not started");
1 by brian
clean slate
2864
    }
2865
  }
2866
  return $do_restart;
2867
}
2868
2869
sub run_testcase_need_slave_restart($)
2870
{
2871
  my ($tinfo)= @_;
2872
2873
  # We try to find out if we are to restart the slaves
2874
  my $do_slave_restart= 0;     # Assumes we don't have to
2875
89 by Brian Aker
Saving changes/removals to test run
2876
  if ( $max_slave_num == 0)
1 by brian
clean slate
2877
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2878
    dtr_verbose("Skip slave restart: No testcase use slaves");
1 by brian
clean slate
2879
  }
2880
  else
2881
  {
2882
2883
    # Check if any slave is currently started
2884
    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.
2885
    foreach my $drizzled (@{$slave})
1 by brian
clean slate
2886
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2887
      if ( $drizzled->{'pid'} )
1 by brian
clean slate
2888
      {
2889
	$any_slave_started= 1;
2890
	last;
2891
      }
2892
    }
2893
2894
    if ($any_slave_started)
2895
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2896
      dtr_verbose("Restart slave: Slave is started, always restart");
1 by brian
clean slate
2897
      $do_slave_restart= 1;
2898
    }
2899
    elsif ( $tinfo->{'slave_num'} )
2900
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2901
      dtr_verbose("Restart slave: Test need slave");
1 by brian
clean slate
2902
      $do_slave_restart= 1;
2903
    }
2904
  }
2905
2906
  return $do_slave_restart;
2907
2908
}
2909
2910
# ----------------------------------------------------------------------
2911
# If not using a running servers we may need to stop and restart.
2912
# We restart in the case we have initiation scripts, server options
2913
# etc to run. But we also restart again after the test first restart
2914
# and test is run, to get back to normal server settings.
2915
#
2916
# To make the code a bit more clean, we actually only stop servers
2917
# here, and mark this to be done. Then a generic "start" part will
2918
# start up the needed servers again.
2919
# ----------------------------------------------------------------------
2920
2921
sub run_testcase_stop_servers($$$) {
2922
  my ($tinfo, $do_restart, $do_slave_restart)= @_;
2923
  my $pid;
2924
  my %admin_pids; # hash of admin processes that requests shutdown
2925
  my @kill_pids;  # list of processes to shutdown/kill
2926
2927
  # Remember if we restarted for this test case (count restarts)
2928
  $tinfo->{'restarted'}= $do_restart;
2929
2930
  if ( $do_restart )
2931
  {
2932
    delete $master->[0]->{'running_master_options'}; # Forget history
2933
2934
    # 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.
2935
    foreach my $drizzled (@{$master})
1 by brian
clean slate
2936
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2937
      if ( $drizzled->{'pid'} )
1 by brian
clean slate
2938
      {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use 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
        $pid= dtr_server_shutdown($drizzled);
973.1.3 by Toru Maesaka
Remove drizzleadmin from the repository and fix the test suite for it.
2940
2941
        $admin_pids{$pid}= 1;
2942
2943
        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.
2944
              pid      => $drizzled->{'pid'},
2945
              real_pid => $drizzled->{'real_pid'},
2946
              pidfile  => $drizzled->{'path_pid'},
2947
              sockfile => $drizzled->{'path_sock'},
2948
              port     => $drizzled->{'port'},
2949
              errfile   => $drizzled->{'path_myerr'},
973.1.3 by Toru Maesaka
Remove drizzleadmin from the repository and fix the test suite for it.
2950
        });
2951
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2952
        $drizzled->{'pid'}= 0; # Assume we are done with it
1 by brian
clean slate
2953
      }
2954
    }
2955
  }
2956
2957
  if ( $do_restart || $do_slave_restart )
2958
  {
2959
2960
    delete $slave->[0]->{'running_slave_options'}; # Forget history
2961
2962
    # 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.
2963
    foreach my $drizzled (@{$slave})
1 by brian
clean slate
2964
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2965
      if ( $drizzled->{'pid'} )
1 by brian
clean slate
2966
      {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2967
        $pid= dtr_server_shutdown($drizzled);
973.1.3 by Toru Maesaka
Remove drizzleadmin from the repository and fix the test suite for it.
2968
2969
        $admin_pids{$pid}= 1;
2970
2971
        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.
2972
              pid      => $drizzled->{'pid'},
2973
              real_pid => $drizzled->{'real_pid'},
2974
              pidfile  => $drizzled->{'path_pid'},
2975
              sockfile => $drizzled->{'path_sock'},
2976
              port     => $drizzled->{'port'},
2977
              errfile  => $drizzled->{'path_myerr'},
973.1.3 by Toru Maesaka
Remove drizzleadmin from the repository and fix the test suite for it.
2978
        });
2979
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
2980
        $drizzled->{'pid'}= 0; # Assume we are done with it
1 by brian
clean slate
2981
      }
2982
    }
2983
  }
2984
2985
  # ----------------------------------------------------------------------
2986
  # Shutdown has now been started and lists for the shutdown processes
2987
  # and the processes to be killed has been created
2988
  # ----------------------------------------------------------------------
2989
2990
  # 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.
2991
  dtr_wait_blocking(\%admin_pids);
1 by brian
clean slate
2992
2993
2994
  # 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.
2995
  dtr_check_stop_servers(\@kill_pids);
1 by brian
clean slate
2996
}
2997
2998
2999
#
3000
# run_testcase_start_servers
3001
#
3002
# Start the servers needed by this test case
3003
#
3004
# RETURN
3005
#  0 OK
3006
#  1 Start failed
3007
#
3008
3009
sub run_testcase_start_servers($) {
3010
  my $tinfo= shift;
3011
  my $tname= $tinfo->{'name'};
3012
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3013
  if ( $tinfo->{'component_id'} eq 'drizzled' )
1 by brian
clean slate
3014
  {
3015
    if ( !$master->[0]->{'pid'} )
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
      # Master drizzled is not started
1 by brian
clean slate
3018
      do_before_start_master($tinfo);
3019
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3020
      drizzled_start($master->[0],$tinfo->{'master_opt'},[]);
1 by brian
clean slate
3021
3022
    }
3023
3024
    # Save this test case information, so next can examine it
3025
    $master->[0]->{'running_master_options'}= $tinfo;
3026
  }
3027
3028
  # ----------------------------------------------------------------------
3029
  # Start slaves - if needed
3030
  # ----------------------------------------------------------------------
3031
  if ( $tinfo->{'slave_num'} )
3032
  {
3033
    restore_slave_databases($tinfo->{'slave_num'});
3034
3035
    do_before_start_slave($tinfo);
3036
3037
    for ( my $idx= 0; $idx <  $tinfo->{'slave_num'}; $idx++ )
3038
    {
3039
      if ( ! $slave->[$idx]->{'pid'} )
3040
      {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3041
	drizzled_start($slave->[$idx],$tinfo->{'slave_opt'},
1 by brian
clean slate
3042
		     $tinfo->{'slave_mi'});
3043
3044
      }
3045
    }
3046
3047
    # Save this test case information, so next can examine it
3048
    $slave->[0]->{'running_slave_options'}= $tinfo;
3049
  }
3050
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3051
  # Wait for drizzled's to start
3052
  foreach my $drizzled (@{$master},@{$slave})
1 by brian
clean slate
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
    next if !$drizzled->{'pid'};
1 by brian
clean slate
3056
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3057
    if (drizzled_wait_started($drizzled))
1 by brian
clean slate
3058
    {
3059
      # failed to start
3060
      $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.
3061
	"Failed to start $drizzled->{'type'} drizzled $drizzled->{'idx'}";
1 by brian
clean slate
3062
      return 1;
3063
    }
3064
  }
3065
  return 0;
3066
}
3067
3068
#
3069
# Run include/check-testcase.test
3070
# Before a testcase, run in record mode, save result file to var
3071
# After testcase, run and compare with the recorded file, they should be equal!
3072
#
3073
# RETURN VALUE
3074
#  0 OK
3075
#  1 Check failed
3076
#
3077
sub run_check_testcase ($$) {
3078
3079
  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.
3080
  my $drizzled=   shift;
1 by brian
clean slate
3081
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3082
  my $name= "check-" . $drizzled->{'type'} . $drizzled->{'idx'};
1 by brian
clean slate
3083
3084
  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.
3085
  dtr_init_args(\$args);
3086
3087
  dtr_add_arg($args, "--no-defaults");
3088
  dtr_add_arg($args, "--silent");
3089
  dtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
3090
3091
  dtr_add_arg($args, "--port=%d", $drizzled->{'port'});
3092
  dtr_add_arg($args, "--database=test");
3093
  dtr_add_arg($args, "--user=%s", $opt_user);
3094
  dtr_add_arg($args, "--password=");
3095
3096
  dtr_add_arg($args, "-R");
3097
  dtr_add_arg($args, "$opt_vardir/tmp/$name.result");
1 by brian
clean slate
3098
3099
  if ( $mode eq "before" )
3100
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3101
    dtr_add_arg($args, "--record");
1 by brian
clean slate
3102
  }
3103
685.1.22 by Monty Taylor
Added testdir setting support to drizzletest.
3104
  if ( $opt_testdir )
3105
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3106
    dtr_add_arg($args, "--testdir=%s", $opt_testdir);
685.1.22 by Monty Taylor
Added testdir setting support to drizzletest.
3107
  }
3108
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3109
  my $res = dtr_run_test($exe_drizzletest,$args,
1 by brian
clean slate
3110
	        "include/check-testcase.test", "", "", "");
3111
3112
  if ( $res == 1  and $mode eq "after")
3113
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3114
    dtr_run("diff",["-u",
1 by brian
clean slate
3115
		    "$opt_vardir/tmp/$name.result",
3116
		    "$opt_vardir/tmp/$name.reject"],
3117
	    "", "", "", "");
3118
  }
3119
  elsif ( $res )
3120
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3121
    dtr_error("Could not execute 'check-testcase' $mode testcase");
1 by brian
clean slate
3122
  }
3123
  return $res;
3124
}
3125
3126
##############################################################################
3127
#
3128
#  Report the features that were compiled in
3129
#
3130
##############################################################################
3131
3132
sub run_report_features () {
3133
  my $args;
3134
3135
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3136
    drizzled_start($master->[0],[],[]);
1 by brian
clean slate
3137
    if ( ! $master->[0]->{'pid'} )
3138
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3139
      dtr_error("Can't start the drizzled server");
1 by brian
clean slate
3140
    }
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3141
    drizzled_wait_started($master->[0]);
1 by brian
clean slate
3142
  }
3143
3144
  my $tinfo = {};
3145
  $tinfo->{'name'} = 'report features';
3146
  $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.
3147
  $tinfo->{'component_id'} = 'drizzled';
1 by brian
clean slate
3148
  $tinfo->{'path'} = 'include/report-features.test';
3149
  $tinfo->{'timezone'}=  "GMT-3";
3150
  $tinfo->{'slave_num'} = 0;
3151
  $tinfo->{'master_opt'} = [];
3152
  $tinfo->{'slave_opt'} = [];
3153
  $tinfo->{'slave_mi'} = [];
3154
  $tinfo->{'comment'} = 'report server features';
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3155
  run_drizzletest($tinfo);
1 by brian
clean slate
3156
3157
  {
3158
    stop_all_servers();
3159
  }
3160
}
3161
3162
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3163
sub run_drizzletest ($) {
1 by brian
clean slate
3164
  my ($tinfo)= @_;
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3165
  my $exe= $exe_drizzletest;
1 by brian
clean slate
3166
  my $args;
3167
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3168
  dtr_init_args(\$args);
1 by brian
clean slate
3169
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3170
  dtr_add_arg($args, "--no-defaults");
3171
  dtr_add_arg($args, "--silent");
3172
  dtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
3173
  dtr_add_arg($args, "--logdir=%s/log", $opt_vardir);
1 by brian
clean slate
3174
3175
  # 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.
3176
  dtr_add_arg($args, "--mark-progress")
1 by brian
clean slate
3177
    if $opt_mark_progress;
3178
3179
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use 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, "--port=%d", $master->[0]->{'port'});
3181
    dtr_add_arg($args, "--database=test");
3182
    dtr_add_arg($args, "--user=%s", $opt_user);
3183
    dtr_add_arg($args, "--password=");
1 by brian
clean slate
3184
  }
3185
3186
  if ( $opt_strace_client )
3187
  {
3188
    $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.
3189
    dtr_add_arg($args, "-o");
3190
    dtr_add_arg($args, "%s/log/drizzletest.strace", $opt_vardir);
3191
    dtr_add_arg($args, "$exe_drizzletest");
1 by brian
clean slate
3192
  }
3193
3194
  if ( $opt_timer )
3195
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3196
    dtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir);
1 by brian
clean slate
3197
  }
3198
3199
  if ( $opt_compress )
3200
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3201
    dtr_add_arg($args, "--compress");
1 by brian
clean slate
3202
  }
3203
3204
  if ( $opt_sleep )
3205
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3206
    dtr_add_arg($args, "--sleep=%d", $opt_sleep);
1 by brian
clean slate
3207
  }
3208
3209
  if ( $opt_debug )
3210
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3211
    dtr_add_arg($args, "--debug=d:t:A,%s/log/drizzletest.trace",
1 by brian
clean slate
3212
		$path_vardir_trace);
3213
  }
3214
685.1.22 by Monty Taylor
Added testdir setting support to drizzletest.
3215
  if ( $opt_testdir )
3216
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3217
    dtr_add_arg($args, "--testdir=%s", $opt_testdir);
685.1.22 by Monty Taylor
Added testdir setting support to drizzletest.
3218
  }
3219
3220
1 by brian
clean slate
3221
  # ----------------------------------------------------------------------
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
3222
  # export DRIZZLE_TEST variable containing <path>/drizzletest <args>
1 by brian
clean slate
3223
  # ----------------------------------------------------------------------
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
3224
  $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.
3225
    dtr_native_path($exe_drizzletest) . " " . join(" ", @$args);
1 by brian
clean slate
3226
3227
  # ----------------------------------------------------------------------
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
3228
  # Add arguments that should not go into the DRIZZLE_TEST env var
1 by brian
clean slate
3229
  # ----------------------------------------------------------------------
3230
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3231
  if ( $opt_valgrind_drizzletest )
1 by brian
clean slate
3232
  {
3233
    # Prefix the Valgrind options to the argument list.
3234
    # 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.
3235
    # of drizzletest; that would mess up the stderr output causing test failure.
1 by brian
clean slate
3236
    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.
3237
    dtr_init_args(\$args);
1 by brian
clean slate
3238
    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.
3239
    dtr_add_arg($args, "%s", $_) for @args_saved;
1 by brian
clean slate
3240
  }
3241
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3242
  dtr_add_arg($args, "--test-file=%s", $tinfo->{'path'});
1 by brian
clean slate
3243
3244
  # 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.
3245
  dtr_add_arg($args, "--tail-lines=20");
1 by brian
clean slate
3246
3247
  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.
3248
    dtr_add_arg($args, "--result-file=%s", $tinfo->{'result_file'});
1 by brian
clean slate
3249
  }
3250
3251
  if ( $opt_record )
3252
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3253
    dtr_add_arg($args, "--record");
1 by brian
clean slate
3254
  }
3255
3256
  if ( $opt_client_gdb )
3257
  {
3258
    gdb_arguments(\$args, \$exe, "client");
3259
  }
3260
  elsif ( $opt_client_ddd )
3261
  {
3262
    ddd_arguments(\$args, \$exe, "client");
3263
  }
3264
  elsif ( $opt_client_debugger )
3265
  {
3266
    debugger_arguments(\$args, \$exe, "client");
3267
  }
3268
3269
  if ( $opt_check_testcases )
3270
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3271
    foreach my $drizzled (@{$master}, @{$slave})
1 by brian
clean slate
3272
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3273
      if ($drizzled->{'pid'})
1 by brian
clean slate
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
	run_check_testcase("before", $drizzled);
1 by brian
clean slate
3276
      }
3277
    }
3278
  }
3279
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3280
  my $res = dtr_run_test($exe,$args,"","",$path_timefile,"");
1 by brian
clean slate
3281
3282
  if ( $opt_check_testcases )
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
    foreach my $drizzled (@{$master}, @{$slave})
1 by brian
clean slate
3285
    {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3286
      if ($drizzled->{'pid'})
1 by brian
clean slate
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
	if (run_check_testcase("after", $drizzled))
1 by brian
clean slate
3289
	{
3290
	  # Check failed, mark the test case with that info
3291
	  $tinfo->{'check_testcase_failed'}= 1;
3292
	}
3293
      }
3294
    }
3295
  }
3296
3297
  return $res;
3298
3299
}
3300
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
3301
#
3302
# Modify the exe and args so that program is run in gdb in xterm
3303
#
3304
sub dbx_arguments {
3305
  my $args= shift;
3306
  my $exe=  shift;
3307
  my $type= shift;
3308
3309
  # Write $args to gdb init file
3310
  my $str= join(" ", @$$args);
3311
  my $dbx_init_file= "$opt_tmpdir/dbxinit.$type";
3312
3313
  # Remove the old gdbinit file
3314
  unlink($dbx_init_file);
1101.1.32 by Monty Taylor
Fixed the mtr launching a bit.
3315
  if ( $type eq "client" )
3316
  {
3317
    # 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.
3318
    dtr_tofile($dbx_init_file,
1101.1.32 by Monty Taylor
Fixed the mtr launching a bit.
3319
               "runargs $str\n" .
3320
               "run\n");
3321
  }
3322
  else
3323
  {
3324
    # 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.
3325
    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
3326
               "stop in __1cIdrizzledLparse6Fpn0AHSession_pkcI_v_\n" .
1101.1.32 by Monty Taylor
Fixed the mtr launching a bit.
3327
               "runargs $str\n" .
3328
               "run\n" .
3329
               "\n");
3330
  }
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
3331
3332
  if ( $opt_manual_dbx )
3333
  {
3334
     print "\nTo start dbx for $type, type in another window:\n";
1101.1.32 by Monty Taylor
Fixed the mtr launching a bit.
3335
     print "dbx -c 'source $dbx_init_file' $$exe\n";
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
3336
3337
     # Indicate the exe should not be started
3338
     $$exe= undef;
3339
     return;
3340
  }
3341
3342
  $$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.
3343
  dtr_add_arg($$args, "-title");
3344
  dtr_add_arg($$args, "$type");
3345
  dtr_add_arg($$args, "-e");
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
3346
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use 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, "dbx");
3348
  dtr_add_arg($$args, "-c");
3349
  dtr_add_arg($$args, "source $dbx_init_file");
3350
  dtr_add_arg($$args, "$$exe");
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
3351
3352
  $$exe= "xterm";
3353
}
1 by brian
clean slate
3354
3355
#
3356
# Modify the exe and args so that program is run in gdb in xterm
3357
#
3358
sub gdb_arguments {
3359
  my $args= shift;
3360
  my $exe=  shift;
3361
  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
3362
  # We add needed, extra lines to gdbinit on OS X
3363
  my $extra_gdb_init = '' ;
3364
  if ($^O eq 'darwin')
3365
  {
3366
    $extra_gdb_init= "set env DYLD_INSERT_LIBRARIES /usr/lib/libgmalloc.dylib\n".
3367
                 "set env MallocStackLogging 1\n".
3368
                 "set env MallocScribble 1\n".
3369
                 "set env MallocPreScribble 1\n".
3370
                 "set env MallocStackLogging 1\n".
3371
                 "set env MallocStackLoggingNoCompact 1\n".
3372
                 "set env MallocGuardEdges 1\n" ;
3373
  }
1 by brian
clean slate
3374
3375
  # Write $args to gdb init file
3376
  my $str= join(" ", @$$args);
3377
  my $gdb_init_file= "$opt_tmpdir/gdbinit.$type";
3378
3379
  # Remove the old gdbinit file
3380
  unlink($gdb_init_file);
3381
3382
  if ( $type eq "client" )
3383
  {
3384
    # 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.
3385
    dtr_tofile($gdb_init_file,
1 by brian
clean slate
3386
	       "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
3387
               "$extra_gdb_init" .
1 by brian
clean slate
3388
	       "break main\n");
3389
  }
3390
  else
3391
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3392
    # write init file for drizzled
3393
    dtr_tofile($gdb_init_file,
1 by brian
clean slate
3394
	       "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
3395
               "$extra_gdb_init" .
1300.5.23 by Monty Taylor
Merged in revs removing depend on the plugin tree.
3396
               "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
3397
	       "break drizzled::parse\n" .
1 by brian
clean slate
3398
	       "commands 1\n" .
3399
	       "disable 1\n" .
3400
	       "end\n" .
1300.5.23 by Monty Taylor
Merged in revs removing depend on the plugin tree.
3401
               "set breakpoint pending off\n" .
1 by brian
clean slate
3402
	       "run");
3403
  }
3404
3405
  if ( $opt_manual_gdb )
3406
  {
3407
     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.
3408
     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
3409
3410
     # Indicate the exe should not be started
3411
     $$exe= undef;
3412
     return;
3413
  }
3414
3415
  $$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.
3416
  dtr_add_arg($$args, "-title");
3417
  dtr_add_arg($$args, "$type");
3418
  dtr_add_arg($$args, "-e");
1 by brian
clean slate
3419
3420
  if ( $exe_libtool )
3421
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3422
    dtr_add_arg($$args, $exe_libtool);
3423
    dtr_add_arg($$args, "--mode=execute");
1 by brian
clean slate
3424
  }
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, "gdb");
3427
  dtr_add_arg($$args, "-x");
3428
  dtr_add_arg($$args, "$gdb_init_file");
3429
  dtr_add_arg($$args, "$$exe");
1 by brian
clean slate
3430
3431
  $$exe= "xterm";
3432
}
3433
3434
3435
#
3436
# Modify the exe and args so that program is run in ddd
3437
#
3438
sub ddd_arguments {
3439
  my $args= shift;
3440
  my $exe=  shift;
3441
  my $type= shift;
3442
3443
  # Write $args to ddd init file
3444
  my $str= join(" ", @$$args);
3445
  my $gdb_init_file= "$opt_tmpdir/gdbinit.$type";
3446
3447
  # Remove the old gdbinit file
3448
  unlink($gdb_init_file);
3449
3450
  if ( $type eq "client" )
3451
  {
3452
    # 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.
3453
    dtr_tofile($gdb_init_file,
1 by brian
clean slate
3454
	       "set args $str\n" .
3455
	       "break main\n");
3456
  }
3457
  else
3458
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3459
    # write init file for drizzled
3460
    dtr_tofile($gdb_init_file,
1 by brian
clean slate
3461
	       "file $$exe\n" .
3462
	       "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
3463
	       "break drizzled::parse\n" .
1 by brian
clean slate
3464
	       "commands 1\n" .
3465
	       "disable 1\n" .
3466
	       "end");
3467
  }
3468
3469
  if ( $opt_manual_ddd )
3470
  {
3471
     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.
3472
     print "ddd -cd $glob_drizzle_test_dir -x $gdb_init_file $$exe\n";
1 by brian
clean slate
3473
3474
     # Indicate the exe should not be started
3475
     $$exe= undef;
3476
     return;
3477
  }
3478
3479
  my $save_exe= $$exe;
3480
  $$args= [];
3481
  if ( $exe_libtool )
3482
  {
3483
    $$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.
3484
    dtr_add_arg($$args, "--mode=execute");
3485
    dtr_add_arg($$args, "ddd");
1 by brian
clean slate
3486
  }
3487
  else
3488
  {
3489
    $$exe= "ddd";
3490
  }
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3491
  dtr_add_arg($$args, "--command=$gdb_init_file");
3492
  dtr_add_arg($$args, "$save_exe");
1 by brian
clean slate
3493
}
3494
3495
3496
#
3497
# Modify the exe and args so that program is run in the selected debugger
3498
#
3499
sub debugger_arguments {
3500
  my $args= shift;
3501
  my $exe=  shift;
3502
  my $debugger= $opt_debugger || $opt_client_debugger;
3503
3504
  if ( $debugger =~ /vcexpress|vc|devenv/ )
3505
  {
3506
    # vc[express] /debugexe exe arg1 .. argn
3507
3508
    # Add /debugexe and name of the exe before args
3509
    unshift(@$$args, "/debugexe");
3510
    unshift(@$$args, "$$exe");
3511
3512
    # Set exe to debuggername
3513
    $$exe= $debugger;
3514
3515
  }
1099.3.1 by Patrick Galbraith
mtr now with dbx goodness.
3516
  #elsif ( $debugger eq "dbx" )
3517
  #{
3518
  #  # xterm -e dbx -r exe arg1 .. argn
3519
#
3520
#    unshift(@$$args, $$exe);
3521
#    unshift(@$$args, "-r");
3522
#    unshift(@$$args, $debugger);
3523
#    unshift(@$$args, "-e");
3524
#
3525
#    $$exe= "xterm";
3526
#
3527
#  }
1 by brian
clean slate
3528
  else
3529
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3530
    dtr_error("Unknown argument \"$debugger\" passed to --debugger");
1 by brian
clean slate
3531
  }
3532
}
3533
3534
3535
#
3536
# Modify the exe and args so that program is run in valgrind
3537
#
3538
sub valgrind_arguments {
3539
  my $args= shift;
3540
  my $exe=  shift;
3541
3542
  if ( $opt_callgrind)
3543
  {
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3544
    dtr_add_arg($args, "--tool=callgrind");
1 by brian
clean slate
3545
  }
1245.1.3 by Stewart Smith
add option to test-run.pl to run with massif valgrind tool
3546
  elsif ($opt_massif)
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=massif");
1245.1.3 by Stewart Smith
add option to test-run.pl to run with massif valgrind tool
3549
  }
1 by brian
clean slate
3550
  else
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=memcheck"); # From >= 2.1.2 needs this option
3553
    dtr_add_arg($args, "--leak-check=yes");
3554
    dtr_add_arg($args, "--num-callers=16");
3555
    dtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_drizzle_test_dir)
3556
      if -f "$glob_drizzle_test_dir/valgrind.supp";
1 by brian
clean slate
3557
  }
3558
3559
  # 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.
3560
  dtr_add_arg($args, '%s', $_) for (@valgrind_args);
1 by brian
clean slate
3561
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3562
  dtr_add_arg($args, $$exe);
1 by brian
clean slate
3563
3564
  $$exe= $opt_valgrind_path || "valgrind";
3565
3566
  if ($exe_libtool)
3567
  {
3568
    # Add "libtool --mode-execute" before the test to execute
3569
    # if running in valgrind(to avoid valgrinding bash)
3570
    unshift(@$args, "--mode=execute", $$exe);
3571
    $$exe= $exe_libtool;
3572
  }
3573
}
3574
3575
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3576
sub drizzled_wait_started($){
3577
  my $drizzled= shift;
87 by Brian Aker
First pass on cleaning out mysql-test-run
3578
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3579
  if (sleep_until_file_created($drizzled->{'path_pid'},
3580
            $drizzled->{'start_timeout'},
3581
            $drizzled->{'pid'}) == 0)
87 by Brian Aker
First pass on cleaning out mysql-test-run
3582
  {
3583
    # Failed to wait for pid file
3584
    return 1;
3585
  }
3586
3587
  # Get the "real pid" of the process, it will be used for killing
3588
  # 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.
3589
  $drizzled->{'real_pid'}= dtr_get_pid_from_file($drizzled->{'path_pid'});
87 by Brian Aker
First pass on cleaning out mysql-test-run
3590
3591
  return 0;
3592
}
3593
685.1.25 by Monty Taylor
Fixed absolute path generation for real. Sigh.
3594
sub collapse_path ($) {
3595
685.1.29 by Monty Taylor
Some more cleanups to mtr.
3596
    my $c_path= rel2abs(shift);
685.1.25 by Monty Taylor
Fixed absolute path generation for real. Sigh.
3597
    my $updir  = updir($c_path);
3598
    my $curdir = curdir($c_path);
3599
3600
    my($vol, $dirs, $file) = splitpath($c_path);
3601
    my @dirs = splitdir($dirs);
3602
3603
    my @collapsed;
3604
    foreach my $dir (@dirs) {
3605
        if( $dir eq $updir              and   # if we have an updir
3606
            @collapsed                  and   # and something to collapse
3607
            length $collapsed[-1]       and   # and its not the rootdir
3608
            $collapsed[-1] ne $updir    and   # nor another updir
3609
            $collapsed[-1] ne $curdir         # nor the curdir
3610
          )
3611
        {                                     # then
3612
            pop @collapsed;                   # collapse
3613
        }
3614
        else {                                # else
3615
            push @collapsed, $dir;            # just hang onto it
3616
        }
3617
    }
3618
3619
    return catpath($vol, catdir(@collapsed), $file);
3620
}
87 by Brian Aker
First pass on cleaning out mysql-test-run
3621
1 by brian
clean slate
3622
##############################################################################
3623
#
3624
#  Usage
3625
#
3626
##############################################################################
3627
3628
sub usage ($) {
3629
  my $message= shift;
3630
3631
  if ( $message )
3632
  {
3633
    print STDERR "$message\n";
3634
  }
3635
3636
  print <<HERE;
3637
3638
$0 [ OPTIONS ] [ TESTCASE ]
3639
3640
Options to control what engine/variation to run
3641
3642
  compress              Use the compressed protocol between client and server
3643
  bench                 Run the benchmark suite
3644
  small-bench           Run the benchmarks with --small-tests --small-tables
3645
3646
Options to control directories to use
3647
  benchdir=DIR          The directory where the benchmark suite is stored
3648
                        (default: ../../mysql-bench)
3649
  tmpdir=DIR            The directory where temporary files are stored
3650
                        (default: ./var/tmp).
3651
  vardir=DIR            The directory where files generated from the test run
3652
                        is stored (default: ./var). Specifying a ramdisk or
3653
                        tmpfs will speed up tests.
3654
  mem                   Run testsuite in "memory" using tmpfs or ramdisk
3655
                        Attempts to find a suitable location
3656
                        using a builtin list of standard locations
3657
                        for tmpfs (/dev/shm)
3658
                        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.
3659
                        variable DTR_MEM=[DIR]
1 by brian
clean slate
3660
3661
Options to control what test suites or cases to run
3662
3663
  force                 Continue to run the suite after failure
3664
  do-test=PREFIX or REGEX
3665
                        Run test cases which name are prefixed with PREFIX
3666
                        or fulfills REGEX
3667
  skip-test=PREFIX or REGEX
3668
                        Skip test cases which name are prefixed with PREFIX
3669
                        or fulfills REGEX
3670
  start-from=PREFIX     Run test cases starting from test prefixed with PREFIX
3671
  suite[s]=NAME1,..,NAMEN Collect tests in suites from the comma separated
3672
                        list of suite names.
3673
                        The default is: "$opt_suites_default"
3674
  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.
3675
  combination="ARG1 .. ARG2" Specify a set of "drizzled" arguments for one
1 by brian
clean slate
3676
                        combination.
3677
  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
3678
  repeat-test=n         How many times to repeat each test (default: 1)
1 by brian
clean slate
3679
3680
Options that specify ports
3681
3682
  master_port=PORT      Specify the port number used by the first master
3683
  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.
3684
  dtr-build-thread=#    Specify unique collection of ports. Can also be set by
3685
                        setting the environment variable DTR_BUILD_THREAD.
1 by brian
clean slate
3686
3687
Options for test case authoring
3688
3689
  record TESTNAME       (Re)genereate the result file for TESTNAME
3690
  check-testcases       Check testcases for sideeffects
3691
  mark-progress         Log line number and elapsed time to <testname>.progress
3692
3693
Options that pass on options
3694
1819.2.1 by patrick crews
Initial work on lp bug#656423 - remove use of 'mysql' from test-run tool. Removed / substituted mtr->dtr mysql->drizzle. Removed perl errors, but server won't start due to boost error.
3695
  drizzled=ARGS           Specify additional arguments to "drizzled"
1 by brian
clean slate
3696
3697
Options to run test on running server
3698
3699
  extern                Use running server for tests
3700
  user=USER             User for connection to extern server
3701
3702
Options for debugging the product
3703
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3704
  client-ddd            Start drizzletest client in ddd
3705
  client-debugger=NAME  Start drizzletest in the selected debugger
3706
  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.
3707
  ddd                   Start drizzled in ddd
1 by brian
clean slate
3708
  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.
3709
  debugger=NAME         Start drizzled in the selected debugger
3710
  gdb                   Start the drizzled(s) in gdb
3711
  manual-debug          Let user manually start drizzled in debugger, before
1 by brian
clean slate
3712
                        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.
3713
  manual-gdb            Let user manually start drizzled in gdb, before running
3714
                        test(s)
3715
  manual-ddd            Let user manually start drizzled in ddd, before running
3716
                        test(s)
3717
  master-binary=PATH    Specify the master "drizzled" to use
3718
  slave-binary=PATH     Specify the slave "drizzled" to use
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3719
  strace-client         Create strace output for drizzletest client
1 by brian
clean slate
3720
  max-save-core         Limit the number of core files saved (to avoid filling
3721
                        up disks for heavily crashing server). Defaults to
3722
                        $opt_max_save_core, set to 0 for no limit.
3723
3724
Options for coverage, profiling etc
3725
3726
  gcov                  FIXME
191 by Brian Aker
Merge from mark
3727
  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.
3728
  valgrind              Run the "drizzletest" and "drizzled" executables using
1 by brian
clean slate
3729
                        valgrind with default options
3730
  valgrind-all          Synonym for --valgrind
1707.1.21 by Brian Aker
Update for test to run slap correctly via flags (for valgrind).
3731
  valgrind-drizzleslap  Run "drizzleslap" with valgrind.
3732
  valgrind-drizzletest  Run the "drizzletest" and "drizzle_client_test" executable
1 by brian
clean slate
3733
                        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.
3734
  valgrind-drizzled       Run the "drizzled" executable with valgrind
1 by brian
clean slate
3735
  valgrind-options=ARGS Deprecated, use --valgrind-option
3736
  valgrind-option=ARGS  Option to give valgrind, replaces default option(s),
3737
                        can be specified more then once
3738
  valgrind-path=[EXE]   Path to the valgrind executable
3739
  callgrind             Instruct valgrind to use callgrind
1245.1.3 by Stewart Smith
add option to test-run.pl to run with massif valgrind tool
3740
  massif                Instruct valgrind to use massif
1 by brian
clean slate
3741
3742
Misc options
3743
3744
  comment=STR           Write STR to the output
3745
  notimer               Don't show test case execution time
3746
  script-debug          Debug this script itself
3747
  verbose               More verbose output
3748
  start-and-exit        Only initialize and start the servers, using the
3749
                        startup settings for the specified test case (if any)
3750
  start-dirty           Only start the servers (without initialization) for
3751
                        the specified test case (if any)
3752
  fast                  Don't try to clean up from earlier runs
3753
  reorder               Reorder tests to get fewer server restarts
3754
  help                  Get this help text
3755
3756
  testcase-timeout=MINUTES Max test case run time (default $default_testcase_timeout)
3757
  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.
3758
  warnings | log-warnings Pass --log-warnings to drizzled
1 by brian
clean slate
3759
77.3.9 by Monty Taylor
Renamed client programs to drizzle.
3760
  sleep=SECONDS         Passed to drizzletest, will be used as fixed sleep time
1 by brian
clean slate
3761
3762
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.
3763
  dtr_exit(1);
1 by brian
clean slate
3764
3765
}