fixed fork option and tests
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 2 Oct 2004 16:30:16 +0000 (16:30 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 2 Oct 2004 16:30:16 +0000 (16:30 +0000)
git-svn-id: svn://svn.rot13.org/fuse_dbi/trunk@22 17f4e80c-d0e0-0310-8903-bfc3ae804c12

DBI.pm
t/02sqlite.t
t/03pgsql.t

diff --git a/DBI.pm b/DBI.pm
index 8caecd3..c7942d5 100755 (executable)
--- a/DBI.pm
+++ b/DBI.pm
@@ -85,12 +85,13 @@ sub mount {
 
        $ctime_start = time();
 
+       my $pid;
        if ($arg->{'fork'}) {
-               my $pid = fork();
+               $pid = fork();
                die "fork() failed: $!" unless defined $pid;
                # child will return to caller
                if ($pid) {
-                       $self ? return $self : return undef;
+                       return $self;
                }
        }
 
@@ -103,7 +104,7 @@ sub mount {
 
        $self->read_filenames;
 
-       my $mount = Fuse::main(
+       Fuse::main(
                mountpoint=>$arg->{'mount'},
                getattr=>\&e_getattr,
                getdir=>\&e_getdir,
@@ -117,10 +118,10 @@ sub mount {
                debug=>0,
        );
 
-       if (! $mount) {
-               warn "mount on ",$arg->{'mount'}," failed!\n";
-               return undef;
-       }
+       exit(0) if ($arg->{'fork'});
+
+       return 1;
+
 };
 
 =head2 umount
index a0df6f0..28a58c4 100755 (executable)
@@ -8,7 +8,7 @@ use blib;
 
 eval "use DBD::SQLite";
 plan skip_all => "DBD::SQLite required for testing" if $@;
-plan tests => 14;
+plan tests => 15;
 
 use_ok('DBI');
 use_ok('Fuse::DBI');
@@ -43,6 +43,8 @@ foreach my $file (qw(file dir/file dir/subdir/file)) {
        ok($sth->execute($file,$data), "insert $file");
 }
 
+ok($dbh->disconnect, "disconnect after insert");
+
 my $sql_filenames = qq{
        select
                name as id,
@@ -72,6 +74,7 @@ my $mnt = Fuse::DBI->mount({
        update => $sql_update,
        dsn => $dsn,
        mount => $mount,
+       fork => 1,
 });
 
 ok($mnt, "mount");
index fd987b6..accb1a4 100755 (executable)
@@ -73,6 +73,7 @@ my $mnt = Fuse::DBI->mount({
        update => $sql_update,
        dsn => $dsn,
        mount => $mount,
+       fork => 1,
 });
 
 ok($mnt, "mount");