test_smbclient_tarmode.pl: add nested dirs test
authorAurélien Aptel <aurelien.aptel@gmail.com>
Fri, 28 Jun 2013 01:30:06 +0000 (03:30 +0200)
committerJim McDonough <jmcd@samba.org>
Tue, 5 Nov 2013 13:42:40 +0000 (08:42 -0500)
add a test to check that the backup handles nested directories.

Signed-off-by: Aurélien Aptel <aurelien.aptel@gmail.com>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jim McDonough <jmcd@samba.org>
source3/script/tests/test_smbclient_tarmode.pl

index b8143e357f6bcb0bb566c4458ebe065425456c24..fe6e7a2f4ec5c0ffe7c08b1147b8ccc179c3104d 100755 (executable)
@@ -103,7 +103,8 @@ my $TAR = "$TMP/tarmode.tar";
 # RUN TESTS
 
 run_test(
-    [\&test_creation_normal],
+    [\&test_creation_normal, 'normal'],
+    [\&test_creation_normal, 'nested'],
     [\&test_creation_incremental, '-g'],
     [\&test_creation_incremental, 'tarmode inc'],
     [\&test_creation_reset,       '-a'],
@@ -180,13 +181,15 @@ sub test_creation_reset {
 }
 
 sub test_creation_normal {
+    my ($mode) = @_;
 
-    say "TEST: creation -- normal files (no attributes)";
+    say "TEST: creation -- normal files $mode (no attributes)";
 
+    my $prefix = ($mode =~ /nest/) ? "/foo/bar/bar/" : '';
     my @files;
     my $n = 5;
     for(1..$n) {
-        my $f = File->new_remote("file-$_");
+        my $f = File->new_remote($prefix."file-$_");
         $f->set_attr();
         push @files, $f;
     }
@@ -195,7 +198,6 @@ sub test_creation_normal {
     return check_tar($TAR, \@files);
 }
 
-
 sub test_creation_incremental {
     my ($mode) = @_;
 
@@ -425,7 +427,7 @@ sub remotepath {
     return undef if !$s->{remote};
 
     if($s->{dir}) {
-        $main::DIR.'/'.$s->{dir}.'/'.$s->{name};
+        $main::DIR.'/'.$s->{dir}.$s->{name};
     } else {
         $main::DIR.'/'.$s->{name};
     }
@@ -508,6 +510,7 @@ sub new_remote {
     my ($file, $dir) = fileparse($path);
 
     $dir = '' if $dir eq './';
+    $dir =~ s{^/}{};
 
     my $loc = $main::LOCALPATH.'/'.$main::DIR.'/'.$dir;
     make_path($loc);