use Data::Dumper;
-our $VERSION = '0.04';
+our $VERSION = '0.05';
=head1 NAME
my $pid;
if ($arg->{'fork'}) {
+ $self->{'mounted'} = 1;
$pid = fork();
die "fork() failed: $!" unless defined $pid;
# child will return to caller
$self->{'read_filenames'} = sub { $self->read_filenames };
$self->read_filenames;
- $self->{'mounted'} = 1;
+ $self->{'mounted'} = 1 unless ($arg->{'fork'});
$fuse_self = \$self;
my $self = shift;
if ($self->{'mounted'}) {
- system "fusermount -u ".$self->{'mount'} || croak "umount error: $!";
+ system "fusermount -u ".$self->{'mount'} || warn "umount error: $!" && return 0;
}
return 1;
use warnings;
use Test::More;
+use File::Find;
use blib;
eval "use DBD::SQLite";
plan skip_all => "DBD::SQLite required for testing" if $@;
-plan tests => 15;
+plan tests => 36;
use_ok('DBI');
use_ok('Fuse::DBI');
insert into files (name,data) values (?,?)
}), "prepare");
-foreach my $file (qw(file dir/file dir/subdir/file)) {
- my $data = "this is test data\n" x length($file);
- ok($sth->execute($file,$data), "insert $file");
+my @files = qw(file dir/file dir/subdir/file);
+my %file_data;
+
+foreach my $file (@files) {
+ $file_data{$file} = ("this is test data on ".localtime()."\n") x length($file);
+ ok($sth->execute($file,$file_data{$file}), "insert $file");
}
ok($dbh->disconnect, "disconnect after insert");
ok($mnt, "mount");
-diag "press enter to continue";
-my $foo = <STDIN>;
+sub test_file {
+ my $f = $File::Find::name;
+
+ ok($f, "file $f");
+
+ return unless (-f $f);
+
+ ok(open(F, $f), "open");
+ my $tmp = '';
+ while(<F>) {
+ $tmp .= $_;
+ }
+ ok(close(F), "close");
+
+ # strip mountpoint
+ $f =~ s#^\Q$mount\E/##;
+
+ ok($file_data{$f}, "$f exists");
+
+ cmp_ok(length($file_data{$f}), '==', length($tmp), "size");
+ cmp_ok($file_data{$f}, 'eq', $tmp, "content");
+}
+
+# small delay so that filesystem could mount
+sleep(1);
+
+find({ wanted => \&test_file, no_chdir => 1 }, $mount);
ok($mnt->umount,"umount");