/[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 6 by dpavlin, Sun Jul 8 17:03:12 2007 UTC revision 10 by dpavlin, Sun Jul 8 21:03:26 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 => 23;  use Test::More tests => 135;
8    use File::Slurp;
9    
10  my ( $from, $to, $tmp ) = ( '/tmp/comp', '/tmp/no-comp', '/dev/shm' );  my ( $from, $to, $tmp ) = ( '/tmp/comp', '/tmp/no-comp', '/dev/shm/comp' );
11    
12  ok( -e $from, 'from' );  ok( -e $from, 'from' );
13  ok( -e $to, 'to' );  ok( -e $to, 'to' );
# Line 15  ok( -e $tmp, 'tmp' ); Line 16  ok( -e $tmp, 'tmp' );
16  sub file {  sub file {
17          my ( $op, $path, $content ) = @_;          my ( $op, $path, $content ) = @_;
18          ok( open( my $fh, $op, "$to/$path" ), "open( $op $path )");          ok( open( my $fh, $op, "$to/$path" ), "open( $op $path )");
19          if ( $content ) {          if ( $op =~ m/>/ ) {
20                  print $fh $content;                  print $fh $content;
21          } else {          } else {
22                  local $/;                  local $/;
# Line 28  sub file { Line 29  sub file {
29    
30          ok( -e "$from/$path" || -e "$from/${path}.gz", 'on disk' );          ok( -e "$from/$path" || -e "$from/${path}.gz", 'on disk' );
31    
32            ok( -e "$tmp/$path" , 'in tmp' ) if ( $op =~ m/</ );
33    
34          return $content;          return $content;
35  }  }
36    
37  file( '>', 'foo', 'content' );  my $buff = '<<--just a chunk of data-->>';
38  cmp_ok( file( '<', 'foo' ), 'eq', 'content', 'check content' );  
39    for my $i ( 1 .. 3 ) {
40            my $content = $buff x int(3 + $i * rand(15));
41            $content =~ s/\s+/ /gs;
42    
43            my $file = "test.$i";
44    
45            file( '>', $file, $content );
46            cmp_ok( file( '<', $file ), 'eq', $content, "$file content" );
47    
48  file( '>>', 'foo', '+more' );          file( '>>', $file, '+append' );
49  cmp_ok( file( '<', 'foo' ), 'eq', 'content+more', 'check content' );          cmp_ok( file( '<', $file ), 'eq', $content . '+append', "$file append" );
50    
51  file( '>', 'foo', 'new' );          file( '>', $file, '' );
52  cmp_ok( file( '<', 'foo' ), 'eq', 'new', 'check content' );          cmp_ok( file( '<', $file ), 'eq', '', "$file empty" );
53    
54            file( '>', $file, $content );
55            cmp_ok( file( '<', $file ), 'eq', $content, "$file content" );
56    
57    }

Legend:
Removed from v.6  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26