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

Contents of /t/fs.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11 - (show annotations)
Mon Jul 9 08:39:58 2007 UTC (16 years, 8 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 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 my $debug = shift @ARGV;
6
7 use Test::More tests => 115;
8 use File::Slurp;
9
10 my ( $from, $to, $tmp ) = ( '/tmp/comp', '/tmp/no-comp', '/dev/shm/comp' );
11
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 if ( $op =~ m/>/ ) {
20 print $fh $content;
21 } else {
22 my $orig_content = $content;
23 local $/;
24 $content = <$fh>;
25 if ( defined( $content ) ) {
26 cmp_ok( $content, 'eq', $orig_content, 'content' );
27 } else {
28 ok( $content, 'has content' );
29 }
30 }
31 ok( close($fh), 'close' );
32
33 ok ( -e "$to/$path", 'exists' );
34
35 my $pack = "$from/${path}.gz";
36
37 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
44 return $content;
45 }
46
47 my $buff = '<<--just a chunk of data-->>';
48
49 for my $i ( 1 .. 3 ) {
50 my $content = $buff x int(3 + $i * rand(15));
51 $content =~ s/\s+/ /gs;
52
53 my $file = "test.$i";
54
55 file( '>', $file, $content );
56 file( '<', $file, $content );
57
58 file( '>>', $file, '+append' );
59 file( '<', $file, $content . '+append' );
60
61 file( '>', $file, '' );
62 file( '<', $file, '' );
63
64 file( '>', $file, $content );
65 file( '<', $file, $content );
66
67 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26