summaryrefslogtreecommitdiff
path: root/mysql-test/lib
diff options
context:
space:
mode:
authorunknown <msvensson@pilot.(none)>2007-08-29 11:53:36 +0200
committerunknown <msvensson@pilot.(none)>2007-08-29 11:53:36 +0200
commit60f812db877537d48175ccf374157db1c529abf1 (patch)
tree932d790fd0988cc311874b523c4d6deb63da8b2c /mysql-test/lib
parent991773decab2da8ad8bda0146371cbfae394020c (diff)
parentf60837cbbdb1009dd5b388eb2cebc5a4ddb46e5e (diff)
downloadmariadb-git-60f812db877537d48175ccf374157db1c529abf1.tar.gz
Merge pilot.(none):/data/msvensson/mysql/mysql-4.1-maint
into pilot.(none):/data/msvensson/mysql/mysql-5.0-maint mysql-test/lib/mtr_misc.pl: Auto merged mysql-test/mysql-test-run.pl: Auto merged
Diffstat (limited to 'mysql-test/lib')
-rw-r--r--mysql-test/lib/mtr_misc.pl60
1 files changed, 60 insertions, 0 deletions
diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl
index e54cb326ade..0d4534f2803 100644
--- a/mysql-test/lib/mtr_misc.pl
+++ b/mysql-test/lib/mtr_misc.pl
@@ -19,6 +19,7 @@
# same name.
use strict;
+use File::Find;
sub mtr_native_path($);
sub mtr_init_args ($);
@@ -29,6 +30,7 @@ sub mtr_file_exists(@);
sub mtr_exe_exists(@);
sub mtr_exe_maybe_exists(@);
sub mtr_copy_dir($$);
+sub mtr_rmtree($$);
sub mtr_same_opts($$);
sub mtr_cmp_opts($$);
@@ -200,6 +202,64 @@ sub mtr_copy_dir($$) {
}
+sub mtr_rmtree($) {
+ my ($dir)= @_;
+ my $need_file_find= 0;
+ mtr_verbose("mtr_rmtree: $dir");
+
+ {
+ # Try to use File::Path::rmtree. Recent versions
+ # handles removal of directories and files that don't
+ # have full permissions, while older versions
+ # may have a problem with that and we use our own version
+
+ local $SIG{__WARN__}= sub {
+ $need_file_find= 1;
+ mtr_warning($_[0]);
+ };
+ rmtree($dir);
+ }
+ if ( $need_file_find ) {
+ mtr_warning("rmtree($dir) failed, trying with File::Find...");
+
+ my $errors= 0;
+
+ # chmod
+ find( {
+ no_chdir => 1,
+ wanted => sub {
+ chmod(0777, $_)
+ or mtr_warning("couldn't chmod(0777, $_): $!") and $errors++;
+ }
+ },
+ $dir
+ );
+
+ # rm
+ finddepth( {
+ no_chdir => 1,
+ wanted => sub {
+ my $file= $_;
+ # Use special underscore (_) filehandle, caches stat info
+ if (!-l $file and -d _ ) {
+ rmdir($file) or
+ mtr_warning("couldn't rmdir($file): $!") and $errors++;
+ } else {
+ unlink($file)
+ or mtr_warning("couldn't unlink($file): $!") and $errors++;
+ }
+ }
+ },
+ $dir
+ );
+
+ mtr_error("Failed to remove '$dir'") if $errors;
+
+ mtr_report("OK, that worked!");
+ }
+}
+
+
sub mtr_same_opts ($$) {
my $l1= shift;
my $l2= shift;