/[fuse-comp]/t/fs.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /t/fs.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 13 by dpavlin, Mon Jul 9 11:12:48 2007 UTC revision 27 by dpavlin, Tue Jul 10 00:22:00 2007 UTC
# Line 4  use warnings; Line 4  use warnings;
4    
5  my $debug = shift @ARGV;  my $debug = shift @ARGV;
6    
7  use Test::More tests => 250;  use Test::More tests => 766;
8  use File::Slurp;  use File::Slurp;
9  use IO::File;  use IO::File;
10    
# Line 63  sub file { Line 63  sub file {
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    
# Line 75  sub file { Line 77  sub file {
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 ) {
# Line 92  for my $i ( 1 .. 3 ) { Line 102  for my $i ( 1 .. 3 ) {
102          file( '>', $file, '' );          file( '>', $file, '' );
103          file( '<', $file, '' );          file( '<', $file, '' );
104    
105  #       file( '>', $file, $content );          file( '>', $file, $content );
106  #       file( '<', $file, $content );          file( '<', $file, $content );
107    
108  }  }
109    
# Line 117  sub multiple_rw { Line 127  sub multiple_rw {
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            ok( link("$to/m", "$to/l"), 'link' );
133            cmp_ok( (stat("$to/l"))[3], '==', 2, 'l has 2 links' );
134            cmp_ok( (stat("$to/m"))[3], '==', 2, 'm has 2 links' );
135    
136            my $size = -s "$to/m";
137            cmp_ok( length(read_file("$to/s")), '==', $size, "$to/s size $size" );
138            cmp_ok( length(read_file("$to/l")), '==', $size, "$to/l size $size" );
139    
140            ok( unlink("$to/s"), 'unlink s' );
141            ok( ! -e "$to/s", 'gone' );
142            ok( unlink("$to/l"), 'unlink l' );
143            cmp_ok( (stat("$to/m"))[3], '==', 1, 'no links' );
144    
145            my @sizes;
146            my $size = 65536;
147            while ( $size > 1 ) {
148                    push @sizes, $size;
149                    $size /= 2;
150            }
151    
152            foreach my $size ( @sizes ) {
153                    ok( my $fh1 = IO::File->new("> $to/m"), 'open 1' );
154                    ok( truncate( $fh1, $size ), 'truncate' );
155                    dump_debug 'truncate';
156                    ok( close($fh1), 'close 1' );
157                    cmp_ok( -s "$to/m", '==', $size, "truncated to $size" );
158            }
159    
160    
161            foreach my $size ( sort @sizes ) {
162                    my $orig_size = -s "$to/m";
163                    ok( my $fh1 = IO::File->new(">> $to/m"), 'open 1' );
164                    ok( print($fh1 "x" x $size), "print $size bytes" );
165                    dump_debug 'append';
166                    ok( close($fh1), 'close 1' );
167                    my $expected_size = $size + $orig_size;
168                    cmp_ok( -s "$to/m", '==', $expected_size, "appended upto $expected_size" );
169            }
170    
171            ok( $size = -s "$to/m", 'size' );
172            ok( my $md5sum = md5sum("$to/m"), 'md5sum m' );
173            ok( rename("$to/m", "$to/n"), 'rename' );
174            ok( -e "$to/n", "$to/n exists" );
175            ok( ! -e "$to/m", "$to/m gone" );
176            cmp_ok( -s "$to/n", '==', $size, 'size' );
177            cmp_ok( $md5sum, 'eq', md5sum("$to/n"), 'md5sums same' );
178    
179            ok( unlink("$to/n"), "$to/n unlink" );
180            ok( ! -e "$to/n", "$to/n gone" );
181    
182            {
183                    ok( my $fh1 = IO::File->new(">> $to/h"), "open $to/h" );
184                    ok( print($fh1 "foobar"), "print" );
185                    ok( unlink("$to/h"), 'create .fuse_hidden' );
186                    ok( ! -e "$to/h", "$to/h gone" );
187                    dump_debug 'hidden';
188                    ok( print($fh1 "foobar"), "print to hidden" );
189                    ok( close($fh1), "close $to/h" );
190            }
191  }  }
192    
193  multiple_rw;  multiple_rw;
194  multiple_rw;  multiple_rw;
195    
   

Legend:
Removed from v.13  
changed lines
  Added in v.27

  ViewVC Help
Powered by ViewVC 1.1.26