/[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

Annotation of /t/fs.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (hide annotations)
Sun Jul 8 21:03:26 2007 UTC (16 years, 8 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1240 byte(s)
cleanups and more strict tests
1 dpavlin 6 #!/usr/bin/perl
2     use strict;
3     use warnings;
4    
5     my $debug = shift @ARGV;
6    
7 dpavlin 10 use Test::More tests => 135;
8     use File::Slurp;
9 dpavlin 6
10 dpavlin 10 my ( $from, $to, $tmp ) = ( '/tmp/comp', '/tmp/no-comp', '/dev/shm/comp' );
11 dpavlin 6
12     ok( -e $from, 'from' );
13     ok( -e $to, 'to' );
14     ok( -e $tmp, 'tmp' );
15    
16     sub file {
17     my ( $op, $path, $content ) = @_;
18     ok( open( my $fh, $op, "$to/$path" ), "open( $op $path )");
19 dpavlin 10 if ( $op =~ m/>/ ) {
20 dpavlin 6 print $fh $content;
21     } else {
22     local $/;
23     $content = <$fh>;
24     ok( $content, 'has content' );
25     }
26     ok( close($fh), 'close' );
27    
28     ok ( -e "$to/$path", 'exists' );
29    
30     ok( -e "$from/$path" || -e "$from/${path}.gz", 'on disk' );
31    
32 dpavlin 10 ok( -e "$tmp/$path" , 'in tmp' ) if ( $op =~ m/</ );
33    
34 dpavlin 6 return $content;
35     }
36    
37 dpavlin 10 my $buff = '<<--just a chunk of data-->>';
38 dpavlin 6
39 dpavlin 10 for my $i ( 1 .. 3 ) {
40     my $content = $buff x int(3 + $i * rand(15));
41     $content =~ s/\s+/ /gs;
42 dpavlin 6
43 dpavlin 10 my $file = "test.$i";
44    
45     file( '>', $file, $content );
46     cmp_ok( file( '<', $file ), 'eq', $content, "$file content" );
47    
48     file( '>>', $file, '+append' );
49     cmp_ok( file( '<', $file ), 'eq', $content . '+append', "$file append" );
50    
51     file( '>', $file, '' );
52     cmp_ok( file( '<', $file ), 'eq', '', "$file empty" );
53    
54     file( '>', $file, $content );
55     cmp_ok( file( '<', $file ), 'eq', $content, "$file content" );
56    
57     }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26