From e70b6dead7ae52ce12f7534221a8fcee4651c89e Mon Sep 17 00:00:00 2001 From: Aurélien Aptel Date: Thu, 27 Jun 2013 20:30:44 +0200 Subject: test_smbclient_tarmode.pl: add test for "newer than" (`N` flag) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: David Disseldorp Reviewed-by: Jim McDonough --- source3/script/tests/test_smbclient_tarmode.pl | 46 +++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'source3/script/tests') 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; } -- cgit