/[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 11 - (hide annotations)
Mon Jul 9 08:39:58 2007 UTC (14 years, 5 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1340 byte(s)
correct testing of created files for various operations, all tests pass now
1 dpavlin 6 #!/usr/bin/perl
2     use strict;
3     use warnings;
4    
5     my $debug = shift @ARGV;
6    
7 dpavlin 11 use Test::More tests => 115;
8 dpavlin 10 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 dpavlin 11 my $orig_content = $content;
23 dpavlin 6 local $/;
24     $content = <$fh>;
25 dpavlin 11 if ( defined( $content ) ) {
26     cmp_ok( $content, 'eq', $orig_content, 'content' );
27     } else {
28     ok( $content, 'has content' );
29     }
30 dpavlin 6 }
31     ok( close($fh), 'close' );
32    
33     ok ( -e "$to/$path", 'exists' );
34    
35 dpavlin 11 my $pack = "$from/${path}.gz";
36 dpavlin 6
37 dpavlin 11 if ( -e $pack ) {
38     ok( -s $pack, 'on disk packed' );
39     ok( -e "$tmp/$path" , 'in tmp unpacked' ) if ( $op =~ m/</ );
40     } else {
41     ok( -e "$from/$path", 'on disk unpacked' );
42     }
43 dpavlin 10
44 dpavlin 6 return $content;
45     }
46    
47 dpavlin 10 my $buff = '<<--just a chunk of data-->>';
48 dpavlin 6
49 dpavlin 10 for my $i ( 1 .. 3 ) {
50     my $content = $buff x int(3 + $i * rand(15));
51     $content =~ s/\s+/ /gs;
52 dpavlin 6
53 dpavlin 10 my $file = "test.$i";
54    
55     file( '>', $file, $content );
56 dpavlin 11 file( '<', $file, $content );
57 dpavlin 10
58     file( '>>', $file, '+append' );
59 dpavlin 11 file( '<', $file, $content . '+append' );
60 dpavlin 10
61     file( '>', $file, '' );
62 dpavlin 11 file( '<', $file, '' );
63 dpavlin 10
64     file( '>', $file, $content );
65 dpavlin 11 file( '<', $file, $content );
66 dpavlin 10
67     }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26