Branch Coverage

blib/lib/File/SmartTail.pm
Criterion Covered Total %
branch 56 318 17.6


line true false branch
135 1 0 if (exists $h{-'tietype'})
136 0 1 if ($h{-'tietype'} =~ /NDBM/) { }
143 0 1 if (exists $h{-'statuskey'})
144 0 0 if $h{-'statuskey'}
147 0 1 if (exists $h{-'bindir'})
159 1 0 unless $STATUSKEY
171 0 0 unless $self->OpenFile($file)
205 0 0 if ($File::SmartTail::DIRTY and not $File::SmartTail::COUNT++ % 10)
212 0 0 unless (@{$self->{'file_data'}{$file}{'array'};})
220 0 0 unless (defined $length)
221 0 0 if $! =~ /^Interrupted/
226 0 0 unless ($length)
231 0 0 if ($self->{'file_data'}{$file}{'inode'} != $inode or $self->{'file_data'}{$file}{'seek'} > $size)
237 0 0 unless $self->OpenFile($file)
257 0 0 if (substr($self->{'file_data'}{$file}{'array'}[$#{$$self{'file_data'}{$file}{'array'};}], -1, 1) ne "\n") { }
260 0 0 unless @{$self->{'file_data'}{$file}{'array'};}
272 0 0 if ($self->{'DB'}{'STATFILE'})
291 0 0 unless (-r $file)
293 0 0 unless (-r $file)
304 0 0 if ($self->{'DB'}{'STATFILE'})
305 0 0 unless ($self->{'file_data'}{$file}{'done'})
308 0 0 if ($self->{'file_data'}{$file}{'inode'} and $inode != $self->{'file_data'}{$file}{'inode'})
318 0 0 unless opendir DIR, $dir
321 0 0 unless (stat "$dir/$item")[1] == $self->{'file_data'}{$file}{'inode'}
337 0 0 unless $self->{'file_data'}{$file}{'FILE'}->open("< $foundfile")
348 0 0 if ($self->{'DB'}{'STATFILE'})
349 0 0 if ($inode == $self->{'file_data'}{$file}{'inode'})
353 0 0 if ($size >= $self->{'file_data'}{$file}{'seek'} and sysseek $self->{'file_data'}{$file}{'FILE'}, $self->{'file_data'}{$file}{'seek'}, 0)
382 0 1 unless (-r $filename)
384 0 0 unless (-r $filename)
397 0 1 if ($self->{'DB'}{'STATFILE'})
398 0 0 unless ($self->{'file_data'}{$key}{'done'})
407 0 0 if ($self->{'file_data'}{$key}{'inode'} and $inode != $self->{'file_data'}{$key}{'inode'})
418 0 0 unless opendir DIR, $dir
421 0 0 unless (stat "$dir/$item")[1] == $self->{'file_data'}{$key}{'inode'}
432 0 1 if (defined $self->{'file_data'}{$key}{'FILE'})
442 0 1 unless $self->{'file_data'}{$key}{'FILE'}->open("< $foundfile")
455 0 1 if ($self->{'DB'}{'STATFILE'})
457 0 0 if ($inode == $self->{'file_data'}{$key}{'inode'})
462 0 0 if ($size >= $self->{'file_data'}{$key}{'seek'} and sysseek $self->{'file_data'}{$key}{'FILE'}, $self->{'file_data'}{$key}{'seek'}, 0)
610 1 0 if ($opts{-'type'} eq 'UNIX') { }
0 0 elsif ($opts{-'type'} eq 'UNIX-REMOTE') { }
611 0 1 unless $self->OpenFileWithOpts($key)
615 0 0 unless $self->OpenRemote(%opts)
634 0 0 if ($opts{-'user'})
641 0 0 if (!$rmtopts =~ /\B-type\s+\w/)
646 0 0 if ($opts{-'rmtenv'})
653 0 0 unless $rmtopts =~ /\B-prefix\s+\S+/
659 0 0 unless $rmtopts =~ /\B-host\s+\w/
665 0 0 unless $rmtopts =~ /\B-heartbeat\s+send\b/
672 0 0 unless $rmtopts =~ /\B-statuskey\s+\w/
676 0 0 unless $opts{-'heartbeat'} and $opts{-'heartbeat'} eq 'recv'
688 0 0 unless ($self->{'file_data'}{$key}{'child'} = $tmpfile->open($cmd))
690 0 0 if ($! =~ /^Interrupted|^Resource|^Bad file/ and ++$ssh_try < 7) { }
696 0 0 if ($fallback_ssh) { }
700 0 0 if ($ssh eq 'ssh') { }
713 0 0 unless (fcntl $tmpfile, 4, fcntl($tmpfile, 3, 0) | 2048)
720 0 0 if (not defined $port) { }
0 0 elsif ($port == 0) { }
0 0 elsif ($port =~ /^\d+$/) { }
721 0 0 if ($! =~ /^Interrupted/ and $port_try < 20) { }
0 0 elsif ($! =~ /^Resource/ and $port_try < 20) { }
727 0 0 if ($fallback_ssh) { }
731 0 0 if ($ssh eq 'ssh') { }
744 0 0 if $port_try > 20
759 0 0 if (defined $self->{'file_data'}{$key}{'FILE'})
764 0 0 unless ($self->{'file_data'}{$key}{'FILE'} = 'IO::Socket::INET'->new('PeerAddr', $hostname, 'PeerPort', $port, 'Proto', 'tcp'))
770 0 0 if ($! =~ /^Interrupted|^Resource|^Bad file|^Connection/ and $conn_try < 6) { }
781 0 0 unless (fcntl $self->{'file_data'}{$key}{'FILE'}, 4, fcntl($self->{'file_data'}{$key}{'FILE'}, 3, 0) | 2048)
799 0 0 if ($self->{'DB'}{'STATFILE'})
846 1 3 if (not defined $self->{'KEYS'}) { }
856 0 5 if ($File::SmartTail::DIRTY and not $File::SmartTail::COUNT % 10)
877 0 5 if (exists $self->{'file_data'}{$key}{'opts'}{-'heartbeat'} and $self->{'file_data'}{$key}{'opts'}{-'heartbeat'} eq 'send') { }
0 10 elsif (exists $self->{'file_data'}{$key}{'opts'}{-'heartbeat'} and $self->{'file_data'}{$key}{'opts'}{-'heartbeat'} eq 'recv') { }
880 0 0 if (defined $msg)
890 0 0 if (defined $msg)
895 0 5 if (exists $self->{'file_data'}{$key}{'opts'}{-'timeout'})
897 0 0 if (defined $msg)
903 5 0 if (exists $self->{'file_data'}{$key}{'opts'}{-'request_timeout'})
905 1 4 if (defined $msg)
912 2 2 unless (@{$self->{'file_data'}{$key}{'array'};})
920 0 2 unless (defined $length)
921 0 0 if ($! =~ /^Interrupted/) { }
0 0 elsif ($self->{'file_data'}{$key}{'opts'}{-'type'} eq 'UNIX-REMOTE' and $! =~ /^Resource/) { }
935 1 1 unless ($length)
939 1 0 if ($self->{'file_data'}{$key}{'opts'}{-'type'} eq 'UNIX') { }
0 0 elsif ($self->{'file_data'}{$key}{'opts'}{-'type'} eq 'UNIX-REMOTE') { }
941 0 1 if ($self->{'file_data'}{$key}{'inode'} != $inode or $self->{'file_data'}{$key}{'seek'} > $size)
950 0 0 $self->{'file_data'}{$key}{'inode'} != $inode ? :
954 0 0 unless $self->OpenFileWithOpts($key)
967 0 1 if (exists $self->{'file_data'}{$key}{'opts'}{-'date'})
976 0 0 if ($self->{'file_data'}{$key}{'opts'}{-'date'} eq 'parsed') { }
991 0 0 if (defined $msg)
1005 0 0 if (defined $msg)
1038 0 1 if (exists $self->{'file_data'}{$key}{'opts'}{-'timeout'})
1041 0 1 if (defined $self->{'file_data'}{$key}{'heartbeat'})
1051 0 1 if (substr($self->{'file_data'}{$key}{'array'}[$#{$$self{'file_data'}{$key}{'array'};}], -1, 1) ne "\n") { }
1054 0 0 unless @{$self->{'file_data'}{$key}{'array'};}
1067 0 3 if ($return =~ /(_heartbeat_)(\d+)/)
1074 0 3 if ($self->{'file_data'}{$key}{'opts'}{-'type'} eq 'UNIX-REMOTE') { }
1080 0 0 if ($roll[1])
1084 0 0 if ($self->{'DB'}{'STATFILE'})
1092 0 3 if ($self->{'DB'}{'STATFILE'})
1105 0 1 unless ($File::SmartTail::COUNT % $File::SmartTail::BATCHLIM)
1106 0 0 if (%doitfn)
1113 1 0 unless $donefiles
1124 0 0 if ($self->{'file_data'}{$key}{'heartbeat'} eq undef or $self->{'file_data'}{$key}{'heartbeat'} < $now - $File::SmartTail::BEAT + $File::SmartTail::SLEEP) { }
1145 0 0 if ($self->{'file_data'}{$key}{'opts'}{-'heartbeat'} eq 'recv')
1160 0 0 if ($self->{'file_data'}{$key}{'heartbeat'} and $now - $self->{'file_data'}{$key}{'heartbeat'} > $File::SmartTail::BEATOUT)
1162 0 0 if ($self->{'file_data'}{$key}{'retries'}++ > $File::SmartTail::MAX_RETRIES) { }
1185 0 0 unless $self->{'file_data'}{$key}{'filetime'}
1186 0 0 if ($now - $self->{'file_data'}{$key}{'filetime'} > $self->{'file_data'}{$key}{'opts'}{-'timeout'} - $File::SmartTail::SLEEP)
1205 1 4 if ($now - $request_mark > $self->{'file_data'}{$key}{'opts'}{-'request_timeout'})
1217 0 0 if ($self->{'file_data'}{$key}{'child'})
1237 0 0 if (-r $archname)
1243 0 0 if ($self->OpenFileWithOpts($key))
1264 0 0 if ($base =~ m[(^[/A-Za-z]*)([0-9]+)$])
1268 0 0 if (defined $monthdir)
1272 0 0 if ($curym ne $newym)
1279 0 0 if $i < 0 or $i > $#arr
1285 0 0 if (-r $newname)
1289 0 0 if ($self->{'file_data'}{$key}{'timedout'})
1293 0 0 if ($self->{'file_data'}{$key}{'done'})
1299 0 0 unless $self->OpenFileWithOpts($key)
1321 0 5 if ($yr < 100)
1322 0 0 if ($yr < 50) { }
1342 0 0 if (exists $self->{'file_data'}{$key}{'seek'}) { }
1360 0 10 unless $yrfmt and $yrfmt ge 2 and $yrfmt lt 5
1393 0 0 if ($line =~ /(_timeout_)(\d+)/)
1409 0 0 if ($line =~ /(_timeout_request_)(\d+)/)
1429 0 0 if ($line =~ /(_rollover_)(\d+)(_)(.*)_$/)
1445 0 0 if ($line =~ /(_archived_)(\d+)/)
1465 0 0 if ($line =~ /(_heartfailure_)(\d+)/)
1480 0 0 if (%opts)
1481 0 0 if ($opts{-'date'} eq 'gz' or $opts{-'rmtopts'} =~ /-date\s+gz/)
1504 0 1 if (defined $tmpb) { }
1507 0 0 if (exists $opts{-'host'}) { }
1508 0 0 if ($opts{-'host'} ne $tmpa)
1517 1 0 unless exists $opts{-'host'}
1523 1 0 unless (exists $opts{-'current'})
1527 1 0 unless (exists $opts{-'type'})
1531 1 0 unless (exists $opts{-'rmtsh'})
1546 0 1 if (exists $opts{'-clear'})
1547 0 0 if (-f $self->{'DB'}{'STATFILE'})
1552 1 0 if (exists $opts{'-reset'})
1556 1 0 if (exists $opts{'-request_timeout'})
1557 0 1 if ($opts{'-request_timeout'} < 1)
1569 0 0 if (%opts)
1580 0 0 if (%opts)
1593 0 0 if (%opts)
1604 0 0 if (%opts)
1615 0 0 if (%opts)
1625 0 0 if (%opts)
1649 0 1 unless -e $prefix
1653 0 1 unless $name
1654 0 1 unless $path
1655 1 0 unless $suffix
1657 0 1 unless $path = Cwd::abs_path($path)
1659 1 0 unless $path =~ m[/$]