summaryrefslogtreecommitdiffstats
path: root/source3/script
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2013-06-27 20:30:44 +0200
committerJim McDonough <jmcd@samba.org>2013-11-05 08:42:40 -0500
commite70b6dead7ae52ce12f7534221a8fcee4651c89e (patch)
tree64ca30d588a577be6b1a4dcd90ede65ea8db1849 /source3/script
parent2ef7909dd0db75db64a611c57b33f103be07a940 (diff)
downloadsamba-e70b6dead7ae52ce12f7534221a8fcee4651c89e.tar.gz
samba-e70b6dead7ae52ce12f7534221a8fcee4651c89e.tar.xz
samba-e70b6dead7ae52ce12f7534221a8fcee4651c89e.zip
test_smbclient_tarmode.pl: add test for "newer than" (`N` flag)
add test for the N FILE flag which makes smbclient only backup files newer or as new as FILE. 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')
-rwxr-xr-xsource3/script/tests/test_smbclient_tarmode.pl46
1 files changed, 45 insertions, 1 deletions
diff --git a/source3/script/tests/test_smbclient_tarmode.pl b/source3/script/tests/test_smbclient_tarmode.pl
index ffa0144558f..c75d4d5cec7 100755
--- a/source3/script/tests/test_smbclient_tarmode.pl
+++ b/source3/script/tests/test_smbclient_tarmode.pl
@@ -110,6 +110,7 @@ run_test(
[\&test_creation_incremental, 'tarmode inc'],
[\&test_creation_reset, '-a'],
[\&test_creation_reset, 'tarmode reset'],
+ [\&test_creation_newer],
);
#####
@@ -117,6 +118,43 @@ run_test(
# TEST DEFINITIONS
# each test must return the number of error
+sub test_creation_newer {
+
+ say "TEST: creation -- backup files newer than a file";
+
+ my %files;
+ my $dt = 3000;
+
+ # create oldest file at - DT
+ my $oldest_file = "oldest";
+ my $oldest_md5 = create_file(localpath($oldest_file));
+ set_attr(remotepath($oldest_file));
+ set_time(localpath($oldest_file), time - $dt);
+
+ # create limit file
+ my $limit_file = "$TMP/limit";
+ create_file($limit_file);
+
+ # create newA file at + DT
+ my $newA_file = "newA";
+ my $newA_md5 = create_file(localpath($newA_file));
+ set_attr(remotepath($newA_file));
+ set_time(localpath($newA_file), time + $dt);
+
+ # create newB file at + DT
+ my $newB_file = "newB";
+ my $newB_md5 = create_file(localpath($newB_file));
+ set_attr(remotepath($newB_file));
+ set_time(localpath($newB_file), time + $dt);
+
+ # get files newer than limit_file
+ $files{"./$DIR/$newA_file"} = $newA_md5;
+ $files{"./$DIR/$newB_file"} = $newB_md5;
+
+ smb_tar('', '-TcN', $limit_file, $TAR, $DIR);
+ return check_tar($TAR, \%files);
+}
+
sub test_creation_reset {
my ($mode) = @_;
@@ -322,6 +360,7 @@ sub smb_client {
if($DEBUG) {
$cmd =~ s{\\([/+-])}{$1}g;
say $cmd;
+ say $out;
}
if($err) {
@@ -456,5 +495,10 @@ sub get_file {
sub random {
my ($min, $max) = @_;
($min, $max) = ($max, $min) if($min > $max);
- $min + int(rand($max - $min));
+ $min + int(rand($max - $min));
+}
+
+sub set_time {
+ my ($fn, $t) = @_;
+ utime $t, $t, $fn;
}