Branch Coverage

lib/Ubic/Daemon.pm
Criterion Covered Total %
branch 77 168 45.8


line true false branch
39 0 42 unless ($OS)
49 0 0 unless (@signame)
59 12 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 84 0 if defined $options->{'timeout'}
98 11 73 if $pid_state->is_empty
101 0 73 unless ($piddata)
106 0 73 unless (check_daemon($pidfile))
115 70 151 unless (check_daemon($pidfile))
118 3 148 if $total_sleep >= $timeout
121 133 15 if $sleep < 1
125 0 3 unless (check_daemon($pidfile))
149 0 38 unless (defined $bin or defined $function)
152 0 173 if (defined $bin and defined $function)
155 135 38 unless (defined $name)
156 81 54 if (ref $bin) { }
164 13 160 if (check_daemon($pidfile))
171 0 160 unless pipe my $read_pipe, my $write_pipe
174 18 142 unless ($child = fork)
175 0 18 unless defined $child
180 0 0 if $ubic_fh
188 0 18 unless close $read_pipe
192 0 18 if my $tmp_pid = fork
193 0 18 unless defined $tmp_pid
199 16 2 if ($bin)
206 0 18 if $credentials
207 0 18 unless open STDOUT, '>>', $stdout
208 0 18 unless open STDERR, '>>', $stderr
211 14 4 if (defined $ubic_log)
212 0 14 unless open $ubic_fh, '>>', $ubic_log
218 0 18 unless open STDIN, '<', $stdin
231 0 18 unless $lock = $pid_state->lock(5)
237 2 16 if (defined $proxy_logs)
239 0 4 unless pipe my $read, my $write
244 0 18 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 18 unless defined $child
357 0 18 if (defined $cwd)
358 0 0 unless chdir $cwd
360 0 18 if (defined $env)
365 1 17 if $start_hook
366 0 18 if $credentials
368 14 4 if defined $ubic_fh
371 0 18 unless print {$write_pipe;} "execing into daemon\n"
372 0 18 unless close $write_pipe
375 2 16 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 12 6 if (ref $bin) { }
4 2 elsif ($bin) { }
384 0 0 unless exec @$bin
387 0 0 unless exec $bin
394 0 0 if ($write_pipe)
401 0 142 unless close $write_pipe
407 0 142 unless close $read_pipe
408 130 12 if ($out =~ /^execing into daemon$/m and $out =~ /^pidfile written$/m)
422 0 10 unless $options->{'quiet'}
426 329 350 if $pid_state->is_empty
430 345 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'})