--- t/fs.t 2007/07/09 13:45:45 16 +++ t/fs.t 2007/09/02 12:03:52 39 @@ -4,7 +4,7 @@ my $debug = shift @ARGV; -use Test::More tests => 710; +use Test::More tests => 770; use File::Slurp; use IO::File; @@ -30,7 +30,7 @@ my $orig_size = -s "$to/$path"; ok( open( my $fh, $op, "$to/$path" ), "open( $op $path )"); if ( $op eq '>' ) { - cmp_ok( -s "$to/$path", '==', 0, "truncate $to/$path" ); + cmp_ok( -s "$to/$path", '==', 0, "truncated $to/$path" ); print $fh $content; } elsif ( $op eq '>>' ) { cmp_ok( -s "$to/$path", '==', $orig_size, "no truncate $to/$path" ); @@ -63,7 +63,7 @@ ok( -e "$tmp/$path" , "in tmp $tmp/$path" ) if ( $op eq '<' ); # check total size if not append if ( $op ne '>>' ) { - cmp_ok( -s $pack, '==', $size, "$tmp/$path = $size bytes" ); + cmp_ok( -s $pack, '<', $size, "$pack < $size bytes" ); } } else { ok( -e "$from/$path", "on disk $from/$path" ); @@ -77,6 +77,14 @@ return $content; } +sub md5sum { + my $path = shift; + my $md5sum = `md5sum $path`; + $md5sum =~ s/\s+.*$//s; + warn "## md5sum($path) = $md5sum\n" if $debug; + return $md5sum; +} + my $buff = '<<--just a chunk of data-->>'; for my $i ( 1 .. 3 ) { @@ -119,8 +127,27 @@ ok( close($fh2), 'close 2' ); dump_debug 'closed'; + ok( symlink("$to/m", "$to/s"), 'symlink' ); + ok( -l "$to/s", 'is symlink' ); + + ok( !symlink("fake", "$to/s"), 'symlink' ); + ok( !symlink("$to/m", "fake"), 'symlink' ); + + ok( link("$to/m", "$to/l"), 'link' ); + cmp_ok( (stat("$to/l"))[3], '==', 2, 'l has 2 links' ); + cmp_ok( (stat("$to/m"))[3], '==', 2, 'm has 2 links' ); + + my $size = -s "$to/m"; + cmp_ok( length(read_file("$to/s")), '==', $size, "$to/s size $size" ); + cmp_ok( length(read_file("$to/l")), '==', $size, "$to/l size $size" ); + + ok( unlink("$to/s"), 'unlink s' ); + ok( ! -e "$to/s", 'gone' ); + ok( unlink("$to/l"), 'unlink l' ); + cmp_ok( (stat("$to/m"))[3], '==', 1, 'no links' ); + my @sizes; - my $size = 65536; + $size = 65536; while ( $size > 1 ) { push @sizes, $size; $size /= 2; @@ -145,10 +172,28 @@ cmp_ok( -s "$to/m", '==', $expected_size, "appended upto $expected_size" ); } - + ok( $size = -s "$to/m", 'size' ); + ok( my $md5sum = md5sum("$to/m"), 'md5sum m' ); + ok( rename("$to/m", "$to/n"), 'rename' ); + ok( -e "$to/n", "$to/n exists" ); + ok( ! -e "$to/m", "$to/m gone" ); + cmp_ok( -s "$to/n", '==', $size, 'size' ); + cmp_ok( $md5sum, 'eq', md5sum("$to/n"), 'md5sums same' ); + + ok( unlink("$to/n"), "$to/n unlink" ); + ok( ! -e "$to/n", "$to/n gone" ); + + { + ok( my $fh1 = IO::File->new(">> $to/h"), "open $to/h" ); + ok( print($fh1 "foobar"), "print" ); + ok( unlink("$to/h"), 'create .fuse_hidden' ); + ok( ! -e "$to/h", "$to/h gone" ); + dump_debug 'hidden'; + ok( print($fh1 "foobar"), "print to hidden" ); + ok( close($fh1), "close $to/h" ); + } } multiple_rw; multiple_rw; -