diff --git a/Build.PL b/Build.PL new file mode 100644 index 0000000..10dd602 --- /dev/null +++ b/Build.PL @@ -0,0 +1,12 @@ +use Module::Build; +my $build = Module::Build->new + ( + module_name => 'Simba', + license => 'perl', + requires => { + }, + script_files => [ + 'da', + ], + ); +$build->create_build_script; diff --git a/lib/Simba/DA.pm b/lib/Simba/DA.pm index 5fd7bed..b43f52b 100644 --- a/lib/Simba/DA.pm +++ b/lib/Simba/DA.pm @@ -82,6 +82,8 @@ sub list { $fn = quote($fn); print $fn; + print metastr($fn, $st); + print "\n"; }, no_chdir => 1, @@ -178,6 +180,8 @@ sub metastr { $s .= " " . 'setgid=1' if $mode & 02000; $s .= " " . 'sticky=1' if $mode & 01000; $s .= " " . 'rdev=' . $st->rdev if ($mode & 0120000) == 0020000; + + return $s; } 1; diff --git a/t/00_da.t b/t/00_da.t new file mode 100644 index 0000000..72a3184 --- /dev/null +++ b/t/00_da.t @@ -0,0 +1,49 @@ +#!/usr/bin/perl +use warnings; +use strict; + +use Test::More 'no_plan'; + +BEGIN { use_ok( 'Simba::DA' ); } + +my $da = Simba::DA->new(); +ok($da, 'new DA'); +my $list; +open(my $fh, '>', \$list); +select $fh; +$da->list('list', 't/root'); +ok($list); +cmp_ok($list, '=~', qr{t/root .* t=d }, 'root is a directory'); +cmp_ok($list, '=~', qr{t/root/test.txt .* t=f s=14 }, 'text file found'); +cmp_ok($list, '=~', qr{t/root/test.bin .* t=f s=1024 }, 'binary file found'); + +my $content; +open($fh, '>', \$content); +select $fh; +$da->get('get', 't/root/test.txt'); +my ($header, $trailer); +($header, $content, $trailer) + = $content =~ /\A ([^\n]*) \n (.*) \n ([^\n]*) \n \Z/xs; + +ok($header, 'header found'); +cmp_ok($header, '=~', qr{t/root/test.txt .* t=f s=14 }, 'text file found'); + +ok($content, 'content found'); +cmp_ok($header, '==', 14, 'text file is 14 bytes long'); + +ok($trailer, 'trailer found'); +is($trailer, 'chk sha1 e3b9312f5f7afbe0bfff5c49ab5e9a160b2b04f4', 'trailer contains correct checksum'); + +$content=""; +$da->get('get', 't/root/test.txt'); +($header, $content, $trailer) + = $content =~ /\A ([^\n]*) \n (.*) \n ([^\n]*) \n \Z/xs; + +ok($header, 'header found'); +cmp_ok($header, '=~', qr{t/root/test.bin .* t=f s=1024 }, 'binary file found'); + +ok($content, 'content found'); +cmp_ok($header, '==', 1024, 'binary file is 1024 bytes long'); + +ok($trailer, 'trailer found'); +is($trailer, 'chk sha1 97253f25fc3945cd6293e3dfad2a322041b14164', 'trailer contains correct checksum'); diff --git a/t/root/test.bin b/t/root/test.bin new file mode 100644 index 0000000..c81b942 Binary files /dev/null and b/t/root/test.bin differ diff --git a/t/root/test.txt b/t/root/test.txt new file mode 100644 index 0000000..30896fc --- /dev/null +++ b/t/root/test.txt @@ -0,0 +1,3 @@ +test +123 +test