4 |
|
|
5 |
my $debug = shift @ARGV; |
my $debug = shift @ARGV; |
6 |
|
|
7 |
use Test::More tests => 710; |
use Test::More tests => 770; |
8 |
use File::Slurp; |
use File::Slurp; |
9 |
use IO::File; |
use IO::File; |
10 |
|
|
30 |
my $orig_size = -s "$to/$path"; |
my $orig_size = -s "$to/$path"; |
31 |
ok( open( my $fh, $op, "$to/$path" ), "open( $op $path )"); |
ok( open( my $fh, $op, "$to/$path" ), "open( $op $path )"); |
32 |
if ( $op eq '>' ) { |
if ( $op eq '>' ) { |
33 |
cmp_ok( -s "$to/$path", '==', 0, "truncate $to/$path" ); |
cmp_ok( -s "$to/$path", '==', 0, "truncated $to/$path" ); |
34 |
print $fh $content; |
print $fh $content; |
35 |
} elsif ( $op eq '>>' ) { |
} elsif ( $op eq '>>' ) { |
36 |
cmp_ok( -s "$to/$path", '==', $orig_size, "no truncate $to/$path" ); |
cmp_ok( -s "$to/$path", '==', $orig_size, "no truncate $to/$path" ); |
63 |
ok( -e "$tmp/$path" , "in tmp $tmp/$path" ) if ( $op eq '<' ); |
ok( -e "$tmp/$path" , "in tmp $tmp/$path" ) if ( $op eq '<' ); |
64 |
# check total size if not append |
# check total size if not append |
65 |
if ( $op ne '>>' ) { |
if ( $op ne '>>' ) { |
66 |
cmp_ok( -s $pack, '==', $size, "$tmp/$path = $size bytes" ); |
cmp_ok( -s $pack, '<', $size, "$pack < $size bytes" ); |
67 |
} |
} |
68 |
} else { |
} else { |
69 |
ok( -e "$from/$path", "on disk $from/$path" ); |
ok( -e "$from/$path", "on disk $from/$path" ); |
77 |
return $content; |
return $content; |
78 |
} |
} |
79 |
|
|
80 |
|
sub md5sum { |
81 |
|
my $path = shift; |
82 |
|
my $md5sum = `md5sum $path`; |
83 |
|
$md5sum =~ s/\s+.*$//s; |
84 |
|
warn "## md5sum($path) = $md5sum\n" if $debug; |
85 |
|
return $md5sum; |
86 |
|
} |
87 |
|
|
88 |
my $buff = '<<--just a chunk of data-->>'; |
my $buff = '<<--just a chunk of data-->>'; |
89 |
|
|
90 |
for my $i ( 1 .. 3 ) { |
for my $i ( 1 .. 3 ) { |
127 |
ok( close($fh2), 'close 2' ); |
ok( close($fh2), 'close 2' ); |
128 |
dump_debug 'closed'; |
dump_debug 'closed'; |
129 |
|
|
130 |
|
ok( symlink("$to/m", "$to/s"), 'symlink' ); |
131 |
|
ok( -l "$to/s", 'is symlink' ); |
132 |
|
|
133 |
|
ok( !symlink("fake", "$to/s"), 'symlink' ); |
134 |
|
ok( !symlink("$to/m", "fake"), 'symlink' ); |
135 |
|
|
136 |
|
ok( link("$to/m", "$to/l"), 'link' ); |
137 |
|
cmp_ok( (stat("$to/l"))[3], '==', 2, 'l has 2 links' ); |
138 |
|
cmp_ok( (stat("$to/m"))[3], '==', 2, 'm has 2 links' ); |
139 |
|
|
140 |
|
my $size = -s "$to/m"; |
141 |
|
cmp_ok( length(read_file("$to/s")), '==', $size, "$to/s size $size" ); |
142 |
|
cmp_ok( length(read_file("$to/l")), '==', $size, "$to/l size $size" ); |
143 |
|
|
144 |
|
ok( unlink("$to/s"), 'unlink s' ); |
145 |
|
ok( ! -e "$to/s", 'gone' ); |
146 |
|
ok( unlink("$to/l"), 'unlink l' ); |
147 |
|
cmp_ok( (stat("$to/m"))[3], '==', 1, 'no links' ); |
148 |
|
|
149 |
my @sizes; |
my @sizes; |
150 |
my $size = 65536; |
$size = 65536; |
151 |
while ( $size > 1 ) { |
while ( $size > 1 ) { |
152 |
push @sizes, $size; |
push @sizes, $size; |
153 |
$size /= 2; |
$size /= 2; |
172 |
cmp_ok( -s "$to/m", '==', $expected_size, "appended upto $expected_size" ); |
cmp_ok( -s "$to/m", '==', $expected_size, "appended upto $expected_size" ); |
173 |
} |
} |
174 |
|
|
175 |
|
ok( $size = -s "$to/m", 'size' ); |
176 |
|
ok( my $md5sum = md5sum("$to/m"), 'md5sum m' ); |
177 |
|
ok( rename("$to/m", "$to/n"), 'rename' ); |
178 |
|
ok( -e "$to/n", "$to/n exists" ); |
179 |
|
ok( ! -e "$to/m", "$to/m gone" ); |
180 |
|
cmp_ok( -s "$to/n", '==', $size, 'size' ); |
181 |
|
cmp_ok( $md5sum, 'eq', md5sum("$to/n"), 'md5sums same' ); |
182 |
|
|
183 |
|
ok( unlink("$to/n"), "$to/n unlink" ); |
184 |
|
ok( ! -e "$to/n", "$to/n gone" ); |
185 |
|
|
186 |
|
{ |
187 |
|
ok( my $fh1 = IO::File->new(">> $to/h"), "open $to/h" ); |
188 |
|
ok( print($fh1 "foobar"), "print" ); |
189 |
|
ok( unlink("$to/h"), 'create .fuse_hidden' ); |
190 |
|
ok( ! -e "$to/h", "$to/h gone" ); |
191 |
|
dump_debug 'hidden'; |
192 |
|
ok( print($fh1 "foobar"), "print to hidden" ); |
193 |
|
ok( close($fh1), "close $to/h" ); |
194 |
|
} |
195 |
} |
} |
196 |
|
|
197 |
multiple_rw; |
multiple_rw; |
198 |
multiple_rw; |
multiple_rw; |
199 |
|
|
|
|
|