From e5ff9ebcd8cde1c935199dc7a9dbcf611129289d Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 16:22:59 +0100 Subject: [PATCH] Add warnings and more error checks in the creation of vardirs --- mysql-test/mysql-test-run.pl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 34fbf9f1b66..84f884b3b4d 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1915,20 +1915,25 @@ sub remove_stale_vardir () { if ( -l $opt_vardir) { # var is a symlink - if ( readlink($opt_vardir) eq $opt_mem ) + + if ( $opt_mem and readlink($opt_vardir) eq $opt_mem ) { # Remove the directory which the link points at mtr_verbose("Removing " . readlink($opt_vardir)); rmtree(readlink($opt_vardir)); - # Remove the entire "var" dir - mtr_verbose("Removing $opt_vardir/"); - rmtree("$opt_vardir/"); - # Remove the "var" symlink mtr_verbose("unlink($opt_vardir)"); unlink($opt_vardir); } + elsif ( $opt_mem ) + { + # Just remove the "var" symlink + mtr_report("WARNING: Removing '$opt_vardir' symlink it's wrong"); + + mtr_verbose("unlink($opt_vardir)"); + unlink($opt_vardir); + } else { # Some users creates a soft link in mysql-test/var to another area @@ -1936,6 +1941,10 @@ sub remove_stale_vardir () { mtr_report("WARNING: Using the 'mysql-test/var' symlink"); + # Make sure the directory where it points exist + mtr_error("The destination for symlink $opt_vardir does not exist") + if ! -d readlink($opt_vardir); + my $dir= shift; foreach my $bin ( glob("$opt_vardir/*") ) {