-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathmysql-test-run.pl
executable file
·4324 lines (3620 loc) · 123 KB
/
mysql-test-run.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env perl
# -*- cperl -*-
# Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
##############################################################################
#
# mysql-test-run.pl
#
# Tool used for executing a suite of .test file
#
# See the "MySQL Test framework manual" for more information
# https://mariadb.com/kb/en/library/mysqltest/
#
# Please keep the test framework tools identical in all versions!
#
##############################################################################
#
# Coding style directions for this perl script
#
# - To make this Perl script easy to alter even for those that not
# code Perl that often, keeep the coding style as close as possible to
# the C/C++ MySQL coding standard.
#
# - All lists of arguments to send to commands are Perl lists/arrays,
# not strings we append args to. Within reason, most string
# concatenation for arguments should be avoided.
#
# - Functions defined in the main program are not to be prefixed,
# functions in "library files" are to be prefixed with "mtr_" (for
# Mysql-Test-Run). There are some exceptions, code that fits best in
# the main program, but are put into separate files to avoid
# clutter, may be without prefix.
#
# - All stat/opendir/-f/ is to be kept in collect_test_cases(). It
# will create a struct that the rest of the program can use to get
# the information. This separates the "find information" from the
# "do the work" and makes the program more easy to maintain.
#
# - The rule when it comes to the logic of this program is
#
# command_line_setup() - is to handle the logic between flags
# collect_test_cases() - is to do its best to select what tests
# to run, dig out options, if needs restart etc.
# run_testcase() - is to run a single testcase, and follow the
# logic set in both above. No, or rare file
# system operations. If a test seems complex,
# it should probably not be here.
#
# A nice way to trace the execution of this script while debugging
# is to use the Devel::Trace package found at
# "http://www.plover.com/~mjd/perl/Trace/" and run this script like
# "perl -d:Trace mysql-test-run.pl"
#
use lib "lib/v1/";
$Devel::Trace::TRACE= 0; # Don't trace boring init stuff
#require 5.6.1;
use File::Path;
use File::Basename;
use File::Copy;
use File::Temp qw /tempdir/;
use File::Spec::Functions qw /splitdir/;
use Cwd;
use Getopt::Long;
use IO::Socket;
use IO::Socket::INET;
use strict;
use warnings;
select(STDOUT);
$| = 1; # Automatically flush STDOUT
our $glob_win32_perl= ($^O eq "MSWin32"); # ActiveState Win32 Perl
our $glob_cygwin_perl= ($^O eq "cygwin"); # Cygwin Perl
our $glob_win32= ($glob_win32_perl or $glob_cygwin_perl);
require "lib/v1/mtr_cases.pl";
require "lib/v1/mtr_process.pl";
require "lib/v1/mtr_timer.pl";
require "lib/v1/mtr_io.pl";
require "lib/v1/mtr_gcov.pl";
require "lib/v1/mtr_gprof.pl";
require "lib/v1/mtr_report.pl";
require "lib/v1/mtr_match.pl";
require "lib/v1/mtr_misc.pl";
require "lib/v1/mtr_stress.pl";
require "lib/v1/mtr_unique.pl";
$Devel::Trace::TRACE= 1;
##############################################################################
#
# Default settings
#
##############################################################################
# Misc global variables
our $mysql_version_id;
our $glob_mysql_test_dir= undef;
our $glob_mysql_bench_dir= undef;
our $glob_scriptname= undef;
our $glob_timers= undef;
our $glob_use_embedded_server= 0;
our @glob_test_mode;
our $glob_basedir;
our $glob_bindir;
our $path_charsetsdir;
our $path_client_bindir;
our $path_client_libdir;
our $path_share;
our $path_language;
our $path_timefile;
our $path_snapshot;
our $path_mysqltest_log;
our $path_current_test_log;
our $opt_vardir; # A path but set directly on cmd line
our $path_vardir_trace; # unix formatted opt_vardir for trace files
our $opt_tmpdir; # A path but set directly on cmd line
# Visual Studio produces executables in different sub-directories based on the
# configuration used to build them. To make life easier, an environment
# variable or command-line option may be specified to control which set of
# executables will be used by the test suite.
our $multiconfig = $ENV{'MTR_VS_CONFIG'};
our $default_vardir;
our $opt_usage;
our $opt_list_options;
our $opt_suites;
our $opt_suites_default= "main,binlog,rpl,maria"; # Default suites to run
our $opt_script_debug= 0; # Script debugging, enable with --script-debug
our $opt_verbose= 0; # Verbose output, enable with --verbose
our $exe_master_mysqld;
our $exe_mysql;
our $exe_mysqladmin;
our $exe_mysql_upgrade;
our $exe_mysqlbinlog;
our $exe_mysql_client_test;
our $exe_bug25714;
our $exe_mysqld;
our $exe_mysqlcheck;
our $exe_mysqldump;
our $exe_mysqlslap;
our $exe_mysqlimport;
our $exe_mysqlshow;
our $file_mysql_fix_privilege_tables;
our $exe_mysqltest;
our $exe_slave_mysqld;
our $exe_my_print_defaults;
our $exe_perror;
our $lib_udf_example;
our $lib_example_plugin;
our $exe_libtool;
our $opt_bench= 0;
our $opt_small_bench= 0;
our $opt_big_test= 0;
our @opt_combinations;
our $opt_skip_combination;
our @opt_extra_mysqld_opt;
our @opt_extra_mysqltest_opt;
our $opt_compress;
our $opt_ssl;
our $opt_skip_ssl;
our $opt_ssl_supported;
our $opt_ps_protocol;
our $opt_sp_protocol;
our $opt_cursor_protocol;
our $opt_view_protocol;
our $opt_debug;
our $opt_do_test;
our @opt_cases; # The test cases names in argv
our $opt_embedded_server;
our $opt_extern= 0;
our $opt_socket;
our $opt_fast;
our $opt_force;
our $opt_reorder= 0;
our $opt_enable_disabled;
our $opt_mem= $ENV{'MTR_MEM'};
our $opt_gcov;
our $opt_gcov_err;
our $opt_gcov_msg;
our $glob_debugger= 0;
our $opt_gdb;
our $opt_client_gdb;
our $opt_ddd;
our $opt_client_ddd;
our $opt_manual_gdb;
our $opt_manual_ddd;
our $opt_manual_debug;
our $opt_mtr_build_thread=0;
our $opt_debugger;
our $opt_client_debugger;
our $opt_gprof;
our $opt_gprof_dir;
our $opt_gprof_master;
our $opt_gprof_slave;
our $master;
our $slave;
our $opt_master_myport;
our $opt_slave_myport;
our $opt_record;
my $opt_report_features;
our $opt_check_testcases;
our $opt_mark_progress;
our $opt_skip_rpl;
our $max_slave_num= 0;
our $max_master_num= 1;
our $use_innodb;
our $opt_skip_test;
our $opt_sleep;
our $opt_testcase_timeout;
our $opt_suite_timeout;
my $default_testcase_timeout= 15; # 15 min max
my $default_suite_timeout= 300; # 5 hours max
our $opt_start_and_exit;
our $opt_start_dirty;
our $opt_start_from;
our $opt_strace_client;
our $opt_timer= 1;
our $opt_user;
my $opt_valgrind= 0;
my $opt_valgrind_mysqld= 0;
my $opt_valgrind_mysqltest= 0;
my @default_valgrind_args= ("--show-reachable=yes");
my @valgrind_args;
my $opt_valgrind_path;
my $opt_callgrind;
our $opt_stress= "";
our $opt_stress_suite= "main";
our $opt_stress_mode= "random";
our $opt_stress_threads= 5;
our $opt_stress_test_count= 0;
our $opt_stress_loop_count= 0;
our $opt_stress_test_duration= 0;
our $opt_stress_init_file= "";
our $opt_stress_test_file= "";
our $opt_warnings;
our $opt_skip_master_binlog= 0;
our $opt_skip_slave_binlog= 0;
our $path_sql_dir;
our @data_dir_lst;
our $used_binlog_format;
our $used_default_engine;
our $debug_compiled_binaries;
our %mysqld_variables;
my $source_dist= 0;
our $opt_max_save_core= 5;
my $num_saved_cores= 0; # Number of core files saved in vardir/log/ so far.
######################################################################
#
# Function declarations
#
######################################################################
sub main ();
sub initial_setup ();
sub command_line_setup ();
sub set_mtr_build_thread_ports($);
sub datadir_list_setup ();
sub executable_setup ();
sub environment_setup ();
sub kill_running_servers ();
sub remove_stale_vardir ();
sub setup_vardir ();
sub check_ssl_support ($);
sub check_running_as_root();
sub mysqld_wait_started($);
sub run_benchmarks ($);
sub initialize_servers ();
sub mysql_install_db ();
sub install_db ($$);
sub copy_install_db ($$);
sub run_testcase ($);
sub run_testcase_stop_servers ($$$);
sub run_testcase_start_servers ($);
sub run_testcase_check_skip_test($);
sub report_failure_and_restart ($);
sub do_before_start_master ($);
sub do_before_start_slave ($);
sub mysqld_start ($$$);
sub mysqld_arguments ($$$$);
sub stop_all_servers ();
sub run_mysqltest ($);
sub usage ($);
######################################################################
#
# Main program
#
######################################################################
main();
sub main () {
command_line_setup();
check_ssl_support(\%mysqld_variables);
check_debug_support(\%mysqld_variables);
executable_setup();
environment_setup();
signal_setup();
if ( $opt_gcov )
{
gcov_prepare();
}
if ( $opt_gprof )
{
gprof_prepare();
}
if ( $opt_bench )
{
initialize_servers();
run_benchmarks(shift); # Shift what? Extra arguments?!
}
elsif ( $opt_stress )
{
initialize_servers();
run_stress_test()
}
else
{
# Figure out which tests we are going to run
if (!$opt_suites)
{
$opt_suites= $opt_suites_default;
}
my $tests= collect_test_cases($opt_suites);
my ($need_debug);
foreach my $test (@$tests)
{
next if $test->{skip};
if (!$opt_extern)
{
$need_debug||=$test->{need_debug};
# Count max number of slaves used by a test case
if ( $test->{slave_num} > $max_slave_num) {
$max_slave_num= $test->{slave_num};
mtr_error("Too many slaves") if $max_slave_num > 3;
}
# Count max number of masters used by a test case
if ( $test->{master_num} > $max_master_num) {
$max_master_num= $test->{master_num};
mtr_error("Too many masters") if $max_master_num > 2;
mtr_error("Too few masters") if $max_master_num < 1;
}
}
$use_innodb||= $test->{'innodb_test'};
}
if ( !$need_debug && !$opt_debug)
{
$opt_debug=0;
}
initialize_servers();
if ( $opt_report_features ) {
run_report_features();
}
run_tests($tests);
}
mtr_exit(0);
}
##############################################################################
#
# Default settings
#
##############################################################################
#
# When an option is no longer used by this program, it must be explicitly
# ignored or else it will be passed through to mysqld. GetOptions will call
# this subroutine once for each such option on the command line. See
# Getopt::Long documentation.
#
sub warn_about_removed_option {
my ($option, $value, $hash_value) = @_;
warn "WARNING: This option is no longer used, and is ignored: --$option\n";
}
sub command_line_setup () {
# These are defaults for things that are set on the command line
my $opt_comment;
# Magic number -69.4 results in traditional test ports starting from 9306.
set_mtr_build_thread_ports(-69.4);
# If so requested, we try to avail ourselves of a unique build thread number.
if ( $ENV{'MTR_BUILD_THREAD'} ) {
if ( lc($ENV{'MTR_BUILD_THREAD'}) eq 'auto' ) {
print "Requesting build thread... ";
$ENV{'MTR_BUILD_THREAD'} = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299);
print "got ".$ENV{'MTR_BUILD_THREAD'}."\n";
}
}
if ( $ENV{'MTR_BUILD_THREAD'} )
{
set_mtr_build_thread_ports($ENV{'MTR_BUILD_THREAD'});
}
# This is needed for test log evaluation in "gen-build-status-page"
# in all cases where the calling tool does not log the commands
# directly before it executes them, like "make test-force-pl" in RPM builds.
print "Logging: $0 ", join(" ", @ARGV), "\n";
# Read the command line
# Note: Keep list, and the order, in sync with usage at end of this file
# Options that are no longer used must still be processed, because all
# unprocessed options are passed directly to mysqld. The user will be
# warned that the option is being ignored.
#
# Put the complete option string here. For example, to remove the --suite
# option, remove it from GetOptions() below and put 'suite|suites=s' here.
my @removed_options = (
);
Getopt::Long::Configure("pass_through");
my %options=(
# Control what engine/variation to run
'embedded-server' => \$opt_embedded_server,
'ps-protocol' => \$opt_ps_protocol,
'sp-protocol' => \$opt_sp_protocol,
'view-protocol' => \$opt_view_protocol,
'cursor-protocol' => \$opt_cursor_protocol,
'ssl|with-openssl' => \$opt_ssl,
'skip-ssl' => \$opt_skip_ssl,
'compress' => \$opt_compress,
'bench' => \$opt_bench,
'small-bench' => \$opt_small_bench,
'vs-config' => \$multiconfig,
# Control what test suites or cases to run
'force' => \$opt_force,
'skip-master-binlog' => \$opt_skip_master_binlog,
'skip-slave-binlog' => \$opt_skip_slave_binlog,
'do-test=s' => \$opt_do_test,
'start-from=s' => \$opt_start_from,
'suite|suites=s' => \$opt_suites,
'skip-rpl' => \$opt_skip_rpl,
'skip-test=s' => \$opt_skip_test,
'big-test' => \$opt_big_test,
'combination=s' => \@opt_combinations,
'skip-combination' => \$opt_skip_combination,
# Specify ports
'master_port=i' => \$opt_master_myport,
'slave_port=i' => \$opt_slave_myport,
'mtr-build-thread=i' => \$opt_mtr_build_thread,
# Test case authoring
'record' => \$opt_record,
'check-testcases' => \$opt_check_testcases,
'mark-progress' => \$opt_mark_progress,
# Extra options used when starting mysqld
'mysqld=s' => \@opt_extra_mysqld_opt,
# Extra options used when starting mysqld
'mysqltest=s' => \@opt_extra_mysqltest_opt,
# Run test on running server
'extern' => \$opt_extern,
# Debugging
'gdb' => \$opt_gdb,
'client-gdb' => \$opt_client_gdb,
'manual-gdb' => \$opt_manual_gdb,
'manual-debug' => \$opt_manual_debug,
'ddd' => \$opt_ddd,
'client-ddd' => \$opt_client_ddd,
'manual-ddd' => \$opt_manual_ddd,
'debugger=s' => \$opt_debugger,
'client-debugger=s' => \$opt_client_debugger,
'strace-client' => \$opt_strace_client,
'master-binary=s' => \$exe_master_mysqld,
'slave-binary=s' => \$exe_slave_mysqld,
'max-save-core=i' => \$opt_max_save_core,
# Coverage, profiling etc
'gcov' => \$opt_gcov,
'gprof' => \$opt_gprof,
'valgrind|valgrind-all' => \$opt_valgrind,
'valgrind-mysqltest' => \$opt_valgrind_mysqltest,
'valgrind-mysqld' => \$opt_valgrind_mysqld,
'valgrind-options=s' => sub {
my ($opt, $value)= @_;
# Deprecated option unless it's what we know pushbuild uses
if ($value eq "--gen-suppressions=all --show-reachable=yes") {
push(@valgrind_args, $_) for (split(' ', $value));
return;
}
die("--valgrind-options=s is deprecated. Use ",
"--valgrind-option=s, to be specified several",
" times if necessary");
},
'valgrind-option=s' => \@valgrind_args,
'valgrind-path=s' => \$opt_valgrind_path,
'callgrind' => \$opt_callgrind,
# Stress testing
'stress' => \$opt_stress,
'stress-suite=s' => \$opt_stress_suite,
'stress-threads=i' => \$opt_stress_threads,
'stress-test-file=s' => \$opt_stress_test_file,
'stress-init-file=s' => \$opt_stress_init_file,
'stress-mode=s' => \$opt_stress_mode,
'stress-loop-count=i' => \$opt_stress_loop_count,
'stress-test-count=i' => \$opt_stress_test_count,
'stress-test-duration=i' => \$opt_stress_test_duration,
# Directories
'tmpdir=s' => \$opt_tmpdir,
'vardir=s' => \$opt_vardir,
'benchdir=s' => \$glob_mysql_bench_dir,
'mem' => \$opt_mem,
'client-bindir=s' => \$path_client_bindir,
'client-libdir=s' => \$path_client_libdir,
# Misc
'report-features' => \$opt_report_features,
'comment=s' => \$opt_comment,
'debug' => \$opt_debug,
'fast' => \$opt_fast,
'reorder' => \$opt_reorder,
'enable-disabled' => \$opt_enable_disabled,
'script-debug' => \$opt_script_debug,
'verbose' => \$opt_verbose,
'sleep=i' => \$opt_sleep,
'socket=s' => \$opt_socket,
'start-dirty' => \$opt_start_dirty,
'start-and-exit' => \$opt_start_and_exit,
'timer!' => \$opt_timer,
'user=s' => \$opt_user,
'testcase-timeout=i' => \$opt_testcase_timeout,
'suite-timeout=i' => \$opt_suite_timeout,
'warnings|log-warnings' => \$opt_warnings,
# Options which are no longer used
(map { $_ => \&warn_about_removed_option } @removed_options),
'help|h' => \$opt_usage,
'list-options' => \$opt_list_options,
);
GetOptions(%options) or usage("Can't read options");
usage("") if $opt_usage;
list_options(\%options) if $opt_list_options;
$glob_scriptname= basename($0);
if ($opt_mtr_build_thread != 0)
{
set_mtr_build_thread_ports($opt_mtr_build_thread)
}
elsif ($ENV{'MTR_BUILD_THREAD'})
{
$opt_mtr_build_thread= $ENV{'MTR_BUILD_THREAD'};
}
# We require that we are in the "mysql-test" directory
# to run mysql-test-run
if (! -f $glob_scriptname)
{
mtr_error("Can't find the location for the mysql-test-run script\n" .
"Go to the mysql-test directory and execute the script " .
"as follows:\n./$glob_scriptname");
}
if ( -d "../sql" )
{
$source_dist= 1;
}
# Find the absolute path to the test directory
$glob_mysql_test_dir= cwd();
if ( $glob_cygwin_perl )
{
# Windows programs like 'mysqld' needs Windows paths
$glob_mysql_test_dir= `cygpath -m "$glob_mysql_test_dir"`;
chomp($glob_mysql_test_dir);
}
if (defined $ENV{MTR_BINDIR})
{
$default_vardir= "$ENV{MTR_BINDIR}/mysql-test/var";
}
else
{
$default_vardir= "$glob_mysql_test_dir/var";
}
# In most cases, the base directory we find everything relative to,
# is the parent directory of the "mysql-test" directory. For source
# distributions, TAR binary distributions and some other packages.
$glob_basedir= dirname($glob_mysql_test_dir);
$glob_bindir= $ENV{'MTR_BINDIR'} || $glob_basedir;
# In the RPM case, binaries and libraries are installed in the
# default system locations, instead of having our own private base
# directory. And we install "/usr/share/mysql-test". Moving up one
# more directory relative to "mysql-test" gives us a usable base
# directory for RPM installs.
if ( ! $source_dist and ! -d "$glob_basedir/bin" )
{
$glob_basedir= dirname($glob_basedir);
}
# Expect mysql-bench to be located adjacent to the source tree, by default
$glob_mysql_bench_dir= "$glob_basedir/../mysql-bench"
unless defined $glob_mysql_bench_dir;
$glob_mysql_bench_dir= undef
unless -d $glob_mysql_bench_dir;
$glob_timers= mtr_init_timers();
# --------------------------------------------------------------------------
# Embedded server flag
# --------------------------------------------------------------------------
if ( $opt_embedded_server )
{
$glob_use_embedded_server= 1;
# Add the location for libmysqld.dll to the path.
if ( $glob_win32 )
{
my $lib_mysqld=
mtr_path_exists(vs_config_dirs('libmysqld',''));
$lib_mysqld= $glob_cygwin_perl ? ":".`cygpath "$lib_mysqld"`
: ";".$lib_mysqld;
chomp($lib_mysqld);
$ENV{'PATH'}="$ENV{'PATH'}".$lib_mysqld;
}
push(@glob_test_mode, "embedded");
$opt_skip_rpl= 1; # We never run replication with embedded
$opt_skip_ssl= 1; # Turn off use of SSL
# Turn off use of bin log
push(@opt_extra_mysqld_opt, "--skip-log-bin");
if ( $opt_extern )
{
mtr_error("Can't use --extern with --embedded-server");
}
}
#
# Find the mysqld executable to be able to find the mysqld version
# number as early as possible
#
# Look for the client binaries directory
if ($path_client_bindir)
{
# --client-bindir=path set on command line, check that the path exists
$path_client_bindir= mtr_path_exists($path_client_bindir);
}
else
{
$path_client_bindir= mtr_path_exists("$glob_bindir/client_release",
"$glob_bindir/client_debug",
vs_config_dirs('client', ''),
"$glob_bindir/client",
"$glob_bindir/bin");
}
# Look for language files and charsetsdir, use same share
$path_share= mtr_path_exists("$glob_bindir/share/mysql",
"$glob_bindir/sql/share",
"$glob_bindir/share");
$path_language= mtr_path_exists("$path_share");
$path_charsetsdir = mtr_path_exists("$glob_basedir/share/mysql/charsets",
"$glob_basedir/sql/share/charsets",
"$glob_basedir/share/charsets");
if (!$opt_extern)
{
$exe_mysqld= mtr_exe_exists (vs_config_dirs('sql', 'mysqld'),
vs_config_dirs('sql', 'mysqld-debug'),
"$glob_bindir/sql/mysqld",
"$path_client_bindir/mysqld-max-nt",
"$path_client_bindir/mysqld-max",
"$path_client_bindir/mysqld-nt",
"$path_client_bindir/mysqld",
"$path_client_bindir/mysqld-debug",
"$path_client_bindir/mysqld-max",
"$glob_bindir/libexec/mysqld",
"$glob_bindir/bin/mariadbd",
"$glob_bindir/sbin/mariadbd");
# Use the mysqld found above to find out what features are available
collect_mysqld_features();
}
else
{
$mysqld_variables{'port'}= 3306;
$mysqld_variables{'master-port'}= 3306;
}
if ( $opt_comment )
{
print "\n";
print '#' x 78, "\n";
print "# $opt_comment\n";
print '#' x 78, "\n\n";
}
foreach my $arg ( @ARGV )
{
if ( $arg =~ /^--skip-/ )
{
push(@opt_extra_mysqld_opt, $arg);
}
elsif ( $arg =~ /^--$/ )
{
# It is an effect of setting 'pass_through' in option processing
# that the lone '--' separating options from arguments survives,
# simply ignore it.
}
elsif ( $arg =~ /^-/ )
{
usage("Invalid option \"$arg\"");
}
else
{
push(@opt_cases, $arg);
}
}
# --------------------------------------------------------------------------
# Find out type of logging that are being used
# --------------------------------------------------------------------------
if (!$opt_extern && $mysql_version_id >= 50100 )
{
foreach my $arg ( @opt_extra_mysqld_opt )
{
if ( $arg =~ /binlog[-_]format=(\S+)/ )
{
$used_binlog_format= $1;
}
}
if (defined $used_binlog_format)
{
mtr_report("Using binlog format '$used_binlog_format'");
}
else
{
mtr_report("Using dynamic switching of binlog format");
}
}
# --------------------------------------------------------------------------
# Find out default storage engine being used(if any)
# --------------------------------------------------------------------------
foreach my $arg ( @opt_extra_mysqld_opt )
{
if ( $arg =~ /default-storage-engine=(\S+)/ )
{
$used_default_engine= $1;
}
}
mtr_report("Using default engine '$used_default_engine'")
if defined $used_default_engine;
if ($glob_win32 and defined $opt_mem) {
mtr_report("--mem not supported on Windows, ignored");
$opt_mem= undef;
}
# --------------------------------------------------------------------------
# Check if we should speed up tests by trying to run on tmpfs
# --------------------------------------------------------------------------
if ( defined $opt_mem )
{
mtr_error("Can't use --mem and --vardir at the same time ")
if $opt_vardir;
mtr_error("Can't use --mem and --tmpdir at the same time ")
if $opt_tmpdir;
# Search through list of locations that are known
# to be "fast disks" to list to find a suitable location
# Use --mem=<dir> as first location to look.
my @tmpfs_locations= ($opt_mem, "/dev/shm", "/tmp");
foreach my $fs (@tmpfs_locations)
{
if ( -d $fs )
{
mtr_report("Using tmpfs in $fs");
$opt_mem= "$fs/var";
$opt_mem .= $opt_mtr_build_thread if $opt_mtr_build_thread;
last;
}
}
}
# --------------------------------------------------------------------------
# Set the "var/" directory, as it is the base for everything else
# --------------------------------------------------------------------------
if ( ! $opt_vardir )
{
$opt_vardir= $default_vardir;
}
elsif ( $mysql_version_id < 50000 and
$opt_vardir ne $default_vardir)
{
# Version 4.1 and --vardir was specified
# Only supported as a symlink from var/
# by setting up $opt_mem that symlink will be created
if ( ! $glob_win32 )
{
# Only platforms that have native symlinks can use the vardir trick
$opt_mem= $opt_vardir;
mtr_report("Using 4.1 vardir trick");
}
$opt_vardir= $default_vardir;
}
$path_vardir_trace= $opt_vardir;
# Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/...
$path_vardir_trace=~ s/^\w://;
# We make the path absolute, as the server will do a chdir() before usage
unless ( $opt_vardir =~ m,^/, or
($glob_win32 and $opt_vardir =~ m,^[a-z]:/,i) )
{
# Make absolute path, relative test dir
$opt_vardir= "$glob_mysql_test_dir/$opt_vardir";
}
# --------------------------------------------------------------------------
# Set tmpdir
# --------------------------------------------------------------------------
$opt_tmpdir= "$opt_vardir/tmp" unless $opt_tmpdir;
$opt_tmpdir =~ s,/+$,,; # Remove ending slash if any
# --------------------------------------------------------------------------
# Record flag
# --------------------------------------------------------------------------
if ( $opt_record and ! @opt_cases )
{
mtr_error("Will not run in record mode without a specific test case");
}
if ( $opt_record )
{
$opt_skip_combination = 1;
}
# --------------------------------------------------------------------------
# ps protcol flag
# --------------------------------------------------------------------------
if ( $opt_ps_protocol )
{
push(@glob_test_mode, "ps-protocol");
}
# --------------------------------------------------------------------------
# Bench flags
# --------------------------------------------------------------------------
if ( $opt_small_bench )
{
$opt_bench= 1;
}
# --------------------------------------------------------------------------
# Big test flags
# --------------------------------------------------------------------------
if ( $opt_big_test )
{
$ENV{'BIG_TEST'}= 1;
}
# --------------------------------------------------------------------------
# Gcov flag
# --------------------------------------------------------------------------
if ( $opt_gcov and ! $source_dist )
{
mtr_error("Coverage test needs the source - please use source dist");
}
# --------------------------------------------------------------------------
# Check debug related options
# --------------------------------------------------------------------------
if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd ||
$opt_manual_gdb || $opt_manual_ddd || $opt_manual_debug ||
$opt_debugger || $opt_client_debugger )
{
# Indicate that we are using debugger
$glob_debugger= 1;
if ( $opt_extern )
{
mtr_error("Can't use --extern when using debugger");
}
}
# --------------------------------------------------------------------------
# Check if special exe was selected for master or slave
# --------------------------------------------------------------------------
$exe_master_mysqld= $exe_master_mysqld || $exe_mysqld;
$exe_slave_mysqld= $exe_slave_mysqld || $exe_mysqld;
# --------------------------------------------------------------------------
# Check valgrind arguments
# --------------------------------------------------------------------------
if ( $opt_valgrind or $opt_valgrind_path or @valgrind_args)
{
mtr_report("Turning on valgrind for all executables");
$opt_valgrind= 1;
$opt_valgrind_mysqld= 1;
$opt_valgrind_mysqltest= 1;
}
elsif ( $opt_valgrind_mysqld )
{
mtr_report("Turning on valgrind for mysqld(s) only");
$opt_valgrind= 1;
}
elsif ( $opt_valgrind_mysqltest )
{
mtr_report("Turning on valgrind for mysqltest and mysql_client_test only");
$opt_valgrind= 1;
}