summaryrefslogtreecommitdiffstats
path: root/source3/script
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2013-07-01 18:01:50 +0200
committerJim McDonough <jmcd@samba.org>2013-11-05 08:42:41 -0500
commitaaf59c9db6e571b8d05f0e62a717be995c16285f (patch)
treee056c707ad3d2d2d6f40d1ef538b1fd097373c62 /source3/script
parentfa067e8e2d469fcead649cf8a761e5c66f0768e5 (diff)
downloadsamba-aaf59c9db6e571b8d05f0e62a717be995c16285f.tar.gz
samba-aaf59c9db6e571b8d05f0e62a717be995c16285f.tar.xz
samba-aaf59c9db6e571b8d05f0e62a717be995c16285f.zip
test_smbclient_tarmode.pl: add test for creation w/ filelist
* add test_creation_list() * add parameter to File::new_local() to provide file content 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.pl41
1 files changed, 39 insertions, 2 deletions
diff --git a/source3/script/tests/test_smbclient_tarmode.pl b/source3/script/tests/test_smbclient_tarmode.pl
index 16ef16340c8..41c2b2fbe1c 100755
--- a/source3/script/tests/test_smbclient_tarmode.pl
+++ b/source3/script/tests/test_smbclient_tarmode.pl
@@ -141,6 +141,7 @@ my @all_tests = (
[\&test_creation_newer],
[\&test_creation_include,],
[\&test_creation_exclude,],
+ [\&test_creation_list,],
[\&test_extraction_normal],
[\&test_extraction_include],
[\&test_extraction_exclude],
@@ -377,6 +378,22 @@ sub test_creation_exclude {
return check_tar($TAR, \@files);
}
+sub test_creation_list {
+ say "TEST: creation -- filelist";
+
+ my @inc_files;
+
+ for(qw(file_inc inc/b inc/c inc/dir/foo foo/bar zob)) {
+ my $f = File->new_remote($_);
+ $f->set_attr();
+ push @inc_files, $f if /inc/;
+ }
+
+ my $flist = File->new_local("$TMP/list", file_list(@inc_files));
+ smb_tar('', '-TcF', $TAR, $flist->localpath);
+ return check_tar($TAR, \@inc_files);
+}
+
#####
# IMPLEMENTATION
@@ -416,6 +433,15 @@ sub reset_env {
reset_remote();
}
+sub file_list {
+ my @files = @_;
+ my $s = '';
+ for(@files) {
+ $s .= $_->remotepath."\n";
+ }
+ return $s;
+}
+
sub check_remote {
my ($files) = @_;
my (%done, %expected);
@@ -770,17 +796,28 @@ sub new_remote {
}
sub new_local {
- my ($class, $path) = @_;
+ my ($class, $path, $data) = @_;
my ($file, $dir) = fileparse($path);
$dir =~ s{/$}{};
make_path($dir);
+ my $md5;
+
+ if(defined $data) {
+ open my $f, '>', $path or die "can't write in $path: $!";
+ print $f $data;
+ close $f;
+ $md5 = md5_hex($data);
+ } else {
+ $md5 = create_file($path);
+ }
+
my $self = {
'attr' => {qw/r 0 s 0 h 0 a 0 d 0 n 0/},
'dir' => $dir,
'name' => $file,
- 'md5' => create_file($path),
+ 'md5' => $md5,
'remote' => 0,
};