From 12e3ac04febe16dd3ee15cd99f9196a60261f1b4 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Tue, 30 Jul 2019 17:16:25 +0200 Subject: [PATCH] MDEV-20185: Windows: Use of uninitialized value $bpath in string eq The execution of mtr in the Windows environment fails due to the fact that the new code from MDEV-18565 does not take into account the need to add the ".exe" extension to the names of executable files when searching for pre-requisites that are needed to run SST scripts (especially when using mariabackup) and when searching paths to some other Galera utilities. This patch fixes this flaw. Also adding paths to the PATH environment variable is now done with the correct delimiter character. --- mysql-test/mysql-test-run.pl | 33 ++++++++++++------- mysql-test/suite.pm | 10 +++--- .../t/galera_ist_innodb_flush_logs.test | 1 + 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 47f697ae0de..e3fe389d4c1 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -440,26 +440,36 @@ sub check_wsrep_support() { # ADD scripts to $PATH to that wsrep_sst_* can be found my ($spath) = grep { -f "$_/wsrep_sst_rsync"; } "$bindir/scripts", $path_client_bindir; mtr_error("No SST scripts") unless $spath; - $ENV{PATH}="$spath:$ENV{PATH}"; + my $separator= (IS_WINDOWS) ? ';' : ':'; + $ENV{PATH}="$spath$separator$ENV{PATH}"; # ADD mysql client library path to path so that wsrep_notify_cmd can find mysql # client for loading the tables. (Don't assume each machine has mysql install) my ($cpath) = grep { -f "$_/mysql"; } "$bindir/scripts", $path_client_bindir; mtr_error("No scritps") unless $cpath; - $ENV{PATH}="$cpath:$ENV{PATH}" unless $cpath eq $spath; + $ENV{PATH}="$cpath$separator$ENV{PATH}" unless $cpath eq $spath; # ADD my_print_defaults script path to path so that SST scripts can find it - my ($epath) = grep { -f "$_/my_print_defaults"; } "$bindir/extra", $path_client_bindir; + my $my_print_defaults_exe= + mtr_exe_maybe_exists( + "$bindir/extra/my_print_defaults", + "$path_client_bindir/my_print_defaults"); + my $epath= ""; + if ($my_print_defaults_exe ne "") { + $epath= dirname($my_print_defaults_exe); + } mtr_error("No my_print_defaults") unless $epath; - $ENV{PATH}="$epath:$ENV{PATH}" unless ($epath eq $spath) or - ($epath eq $cpath); + $ENV{PATH}="$epath$separator$ENV{PATH}" unless ($epath eq $spath) or + ($epath eq $cpath); $extra_path= $epath; - if (which("socat")) { - $ENV{MTR_GALERA_TFMT}="socat"; - } elsif (which("nc")) { - $ENV{MTR_GALERA_TFMT}="nc"; + if (!IS_WINDOWS) { + if (which("socat")) { + $ENV{MTR_GALERA_TFMT}="socat"; + } elsif (which("nc")) { + $ENV{MTR_GALERA_TFMT}="nc"; + } } # Check whether WSREP_PROVIDER environment variable is set. @@ -506,8 +516,9 @@ sub check_mariabackup_support() { "$bindir/extra/mariabackup$opt_vs_config/mariabackup", "$path_client_bindir/mariabackup"); if ($mariabackup_exe ne "") { - my ($bpath) = grep { -f "$_/mariabackup"; } "$bindir/extra/mariabackup$opt_vs_config", $path_client_bindir; - $ENV{PATH}="$bpath:$ENV{PATH}" unless $bpath eq $extra_path; + my $bpath= dirname($mariabackup_exe); + my $separator= (IS_WINDOWS) ? ';' : ':'; + $ENV{PATH}="$bpath$separator$ENV{PATH}" unless $bpath eq $extra_path; $mariabackup_path= $bpath; diff --git a/mysql-test/suite.pm b/mysql-test/suite.pm index ee1eac2794d..5fc6f00b460 100644 --- a/mysql-test/suite.pm +++ b/mysql-test/suite.pm @@ -62,17 +62,17 @@ sub skip_combinations { $skip{'include/have_mariabackup.inc'} = 'Need mariabackup' unless ::have_mariabackup(); - $skip{'include/have_mariabackup.inc'} = 'Need ss' - unless ::which("ss"); + $skip{'include/have_mariabackup.inc'} = 'Need socket statistics utility' + unless IS_WINDOWS || ::which("ss"); $skip{'include/have_mariabackup.inc'} = 'Need socat or nc' - unless $ENV{MTR_GALERA_TFMT}; + unless IS_WINDOWS || $ENV{MTR_GALERA_TFMT}; $skip{'include/have_xtrabackup.inc'} = 'Need innobackupex' - unless ::which(innobackupex); + unless IS_WINDOWS || ::which("innobackupex"); $skip{'include/have_xtrabackup.inc'} = 'Need socat or nc' - unless $ENV{MTR_GALERA_TFMT}; + unless IS_WINDOWS || $ENV{MTR_GALERA_TFMT}; $skip{'include/have_garbd.inc'} = 'Need garbd' unless ::have_garbd(); diff --git a/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.test b/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.test index 328b6b7d4de..839383ebfc1 100644 --- a/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.test +++ b/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.test @@ -6,6 +6,7 @@ --source include/big_test.inc --source include/galera_cluster.inc +--source include/have_innodb.inc --source include/have_xtrabackup.inc --source suite/galera/include/galera_st_kill_slave.inc