Branch Coverage

lib/Ubic/Daemon.pm
Criterion Covered Total %
branch 80 168 47.6


line true false branch
39 0 42 unless ($OS)
49 0 0 unless (@signame)
59 21 42 unless defined $fh
65 0 0 if ($code == 0)
71 0 0 if (my $signal = $? & 127) { }
0 0 elsif ($? & 128) { }
0 0 elsif (my $code = $? >> 8) { }
73 0 0 if (defined $signame) { }
94 90 0 if defined $options->{'timeout'}
98 11 79 if $pid_state->is_empty
101 0 79 unless ($piddata)
106 0 79 unless (check_daemon($pidfile))
115 76 165 unless (check_daemon($pidfile))
118 3 162 if $total_sleep >= $timeout
121 145 17 if $sleep < 1
125 0 3 unless (check_daemon($pidfile))
149 0 38 unless (defined $bin or defined $function)
152 0 182 if (defined $bin and defined $function)
155 144 38 unless (defined $name)
156 89 55 if (ref $bin) { }
164 13 169 if (check_daemon($pidfile))
171 0 169 unless pipe my $read_pipe, my $write_pipe
174 21 148 unless ($child = fork)
175 0 21 unless defined $child
180 0 0 if $ubic_fh
188 0 21 unless close $read_pipe
192 0 21 if my $tmp_pid = fork
193 0 21 unless defined $tmp_pid
199 19 2 if ($bin)
206 0 21 if $credentials
207 0 21 unless open STDOUT, '>>', $stdout
208 0 21 unless open STDERR, '>>', $stderr
211 14 7 if (defined $ubic_log)
212 0 14 unless open $ubic_fh, '>>', $ubic_log
218 0 21 unless open STDIN, '<', $stdin
231 0 21 unless $lock = $pid_state->lock(5)
237 2 19 if (defined $proxy_logs)
239 0 4 unless pipe my $read, my $write
244 0 21 if ($child = fork) { }
251 0 0 unless ($child_guid)
252 0 0 if ($OS->pid_exists($child))
256 0 0 unless (waitpid($child, 1) == $child)
267 0 0 if ($term_timeout)
279 0 0 if ($term_timeout > 0) { }
290 0 0 unless print {$write_pipe;} "pidfile written\n"
291 0 0 unless close $write_pipe
294 0 0 if (defined $proxy_logs)
297 0 0 if ($@) { }
307 0 0 unless (close $daemon_pipes{$handle}{'write'})
322 0 0 unless defined $bytes_read
323 0 0 if $bytes_read == 0
324 0 0 if (fileno $handle == fileno $daemon_pipes{'stdout'}{'read'})
327 0 0 if (fileno $handle == fileno $daemon_pipes{'stderr'}{'read'})
331 0 0 if $exhausted == @ready
339 0 0 if ($sigterm_sent and ($code & 127) == &POSIX::SIGTERM) { }
351 0 21 unless defined $child
357 1 20 if (defined $cwd)
358 0 1 unless chdir $cwd
360 1 20 if (defined $env)
365 1 20 if $start_hook
366 0 21 if $credentials
368 14 7 if defined $ubic_fh
371 0 21 unless print {$write_pipe;} "execing into daemon\n"
372 0 21 unless close $write_pipe
375 2 19 if (defined $proxy_logs)
378 0 2 unless open STDOUT, '>&=', $daemon_pipes{'stdout'}{'write'}
379 0 2 unless open STDERR, '>&=', $daemon_pipes{'stderr'}{'write'}
383 14 7 if (ref $bin) { }
5 2 elsif ($bin) { }
384 0 0 unless exec @$bin
387 0 0 unless exec $bin
394 0 0 if ($write_pipe)
401 0 148 unless close $write_pipe
407 0 148 unless close $read_pipe
408 136 12 if ($out =~ /^execing into daemon$/m and $out =~ /^pidfile written$/m)
422 0 10 unless $options->{'quiet'}
426 367 389 if $pid_state->is_empty
430 384 5 unless ($lock)
435 0 5 unless ($piddata)
441 0 5 if ($piddata->{'format'} and $piddata->{'format'} eq 'old')
444 0 5 unless ($piddata->{'daemon'})
448 0 5 unless ($OS->pid_exists($piddata->{'daemon'}))
458 0 5 unless ($guid)
462 5 0 if ($guid eq $piddata->{'guid'})