4 |
|
|
5 |
my $debug = shift @ARGV; |
my $debug = shift @ARGV; |
6 |
|
|
7 |
use Test::More tests => 250; |
use Test::More tests => 710; |
8 |
use File::Slurp; |
use File::Slurp; |
9 |
use IO::File; |
use IO::File; |
10 |
|
|
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 "$tmp/$path", '==', $size, "$tmp/$path = $size bytes" ); |
cmp_ok( -s $pack, '==', $size, "$tmp/$path = $size bytes" ); |
67 |
} |
} |
68 |
} else { |
} else { |
69 |
ok( -e "$from/$path", "on disk $from/$path" ); |
ok( -e "$from/$path", "on disk $from/$path" ); |
70 |
|
diag "$op curr_size: $orig_size size: $size"; |
71 |
|
$size += $orig_size if ( $op eq '>>' ); |
72 |
cmp_ok( -s "$from/$path", '==', $size, "$from/$path = $size bytes" ); |
cmp_ok( -s "$from/$path", '==', $size, "$from/$path = $size bytes" ); |
73 |
} |
} |
74 |
|
|
94 |
file( '>', $file, '' ); |
file( '>', $file, '' ); |
95 |
file( '<', $file, '' ); |
file( '<', $file, '' ); |
96 |
|
|
97 |
# file( '>', $file, $content ); |
file( '>', $file, $content ); |
98 |
# file( '<', $file, $content ); |
file( '<', $file, $content ); |
99 |
|
|
100 |
} |
} |
101 |
|
|
119 |
ok( close($fh2), 'close 2' ); |
ok( close($fh2), 'close 2' ); |
120 |
dump_debug 'closed'; |
dump_debug 'closed'; |
121 |
|
|
122 |
|
my @sizes; |
123 |
|
my $size = 65536; |
124 |
|
while ( $size > 1 ) { |
125 |
|
push @sizes, $size; |
126 |
|
$size /= 2; |
127 |
|
} |
128 |
|
|
129 |
|
foreach my $size ( @sizes ) { |
130 |
|
ok( my $fh1 = IO::File->new("> $to/m"), 'open 1' ); |
131 |
|
ok( truncate( $fh1, $size ), 'truncate' ); |
132 |
|
dump_debug 'truncate'; |
133 |
|
ok( close($fh1), 'close 1' ); |
134 |
|
cmp_ok( -s "$to/m", '==', $size, "truncated to $size" ); |
135 |
|
} |
136 |
|
|
137 |
|
|
138 |
|
foreach my $size ( sort @sizes ) { |
139 |
|
my $orig_size = -s "$to/m"; |
140 |
|
ok( my $fh1 = IO::File->new(">> $to/m"), 'open 1' ); |
141 |
|
ok( print($fh1 "x" x $size), "print $size bytes" ); |
142 |
|
dump_debug 'append'; |
143 |
|
ok( close($fh1), 'close 1' ); |
144 |
|
my $expected_size = $size + $orig_size; |
145 |
|
cmp_ok( -s "$to/m", '==', $expected_size, "appended upto $expected_size" ); |
146 |
|
} |
147 |
|
|
148 |
|
|
149 |
} |
} |
150 |
|
|
151 |
multiple_rw; |
multiple_rw; |