summaryrefslogtreecommitdiffstats
path: root/source3/script/tests
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2013-06-27 18:53:34 +0200
committerJim McDonough <jmcd@samba.org>2013-11-05 08:42:40 -0500
commit2ef7909dd0db75db64a611c57b33f103be07a940 (patch)
tree771f0c828b6f5bc84354cfc2099a36803aba8c5d /source3/script/tests
parentbe54395832f9c79180a2228c5d7099ddae0fa37f (diff)
downloadsamba-2ef7909dd0db75db64a611c57b33f103be07a940.tar.gz
samba-2ef7909dd0db75db64a611c57b33f103be07a940.tar.xz
samba-2ef7909dd0db75db64a611c57b33f103be07a940.zip
test_smbclient_tarmode.pl: add test for reset mode
add a new test for the reset mode which can be triggered via `-a` or `tarmode reset`. Signed-off-by: Aurélien Aptel <aurelien.aptel@gmail.com> Reviewed-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jim McDonough <jmcd@samba.org>
Diffstat (limited to 'source3/script/tests')
-rwxr-xr-xsource3/script/tests/test_smbclient_tarmode.pl58
1 files changed, 52 insertions, 6 deletions
diff --git a/source3/script/tests/test_smbclient_tarmode.pl b/source3/script/tests/test_smbclient_tarmode.pl
index db5df83dc3e..ffa0144558f 100755
--- a/source3/script/tests/test_smbclient_tarmode.pl
+++ b/source3/script/tests/test_smbclient_tarmode.pl
@@ -108,6 +108,8 @@ run_test(
[\&test_creation_normal],
[\&test_creation_incremental, '-g'],
[\&test_creation_incremental, 'tarmode inc'],
+ [\&test_creation_reset, '-a'],
+ [\&test_creation_reset, 'tarmode reset'],
);
#####
@@ -115,6 +117,38 @@ run_test(
# TEST DEFINITIONS
# each test must return the number of error
+sub test_creation_reset {
+ my ($mode) = @_;
+
+ say "TEST: creation -- reset archived files w/ $mode";
+
+ my %files;
+ my $n = 3;
+ for(1..$n) {
+ my $f = "file-$_";
+ my $md5 = create_file(localpath($f));
+ $files{"./$DIR/$f"} = $md5;
+ set_attr(remotepath($f), 'a');
+ }
+
+ if($mode =~ /reset/) {
+ smb_tar('tarmode full reset', '-Tc', $TAR, $DIR);
+ } else {
+ smb_tar('', '-Tca', $TAR, $DIR);
+ }
+ my $err = check_tar($TAR, \%files);
+ return $err if($err > 0);
+
+ for my $f (smb_ls($DIR)) {
+ if($f->{attr}{A}) {
+ my $attr = join('', map {$_ if $f->{attr}{$_}} qw/R H S A N D/);
+ printf " ! %s %s\n", $attr, $f->{path}.'/'.$f->{fn};
+ $err++;
+ }
+ }
+ return $err;
+}
+
sub test_creation_normal {
say "TEST: creation -- normal files (no attributes)";
@@ -174,6 +208,7 @@ sub run_test {
print_res($err);
print "\n";
}
+ reset_env();
}
sub print_res {
@@ -326,12 +361,14 @@ sub smb_ls {
'size' => int($size),
'date' => $date,
'attr' => {
- 'A' => ($attr =~ /A/),
- 'H' => ($attr =~ /H/),
- 'S' => ($attr =~ /S/),
- 'R' => ($attr =~ /R/),
- 'D' => ($attr =~ /D/),
- 'N' => ($attr =~ /N/),
+ # list context returns somehting different than the
+ # boolean matching result => force scalar context
+ 'A' => scalar ($attr =~ /A/),
+ 'H' => scalar ($attr =~ /H/),
+ 'S' => scalar ($attr =~ /S/),
+ 'R' => scalar ($attr =~ /R/),
+ 'D' => scalar ($attr =~ /D/),
+ 'N' => scalar ($attr =~ /N/),
},
};
}
@@ -407,6 +444,15 @@ sub set_attr {
}
}
+sub get_file {
+ my ($fullpath, @flags) = @_;
+ my ($file, $dir) = fileparse($fullpath);
+
+ my @files = smb_ls($dir);
+ my @res = grep {$_->{fn} eq $file} @files;
+ return @res ? $res[0] : undef;
+}
+
sub random {
my ($min, $max) = @_;
($min, $max) = ($max, $min) if($min > $max);