Branch Coverage

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


line true false branch
39 0 41 unless ($OS)
49 0 0 unless (@signame)
59 12 39 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 80 0 if defined $options->{'timeout'}
98 10 70 if $pid_state->is_empty
101 0 70 unless ($piddata)
106 0 70 unless (check_daemon($pidfile))
115 67 145 unless (check_daemon($pidfile))
118 3 142 if $total_sleep >= $timeout
121 127 15 if $sleep < 1
125 0 3 unless (check_daemon($pidfile))
151 0 36 unless (defined $bin or defined $function)
154 0 162 if (defined $bin and defined $function)
157 126 36 unless (defined $name)
158 76 50 if (ref $bin) { }
166 12 150 if (check_daemon($pidfile))
173 0 150 unless pipe my $read_pipe, my $write_pipe
176 17 133 unless ($child = fork)
177 0 17 unless defined $child
182 0 0 if $ubic_fh
190 0 17 unless close $read_pipe
194 0 17 if my $tmp_pid = fork
195 0 17 unless defined $tmp_pid
201 15 2 if ($bin)
208 0 17 if $credentials
209 0 17 unless open STDOUT, '>>', $stdout
210 0 17 unless open STDERR, '>>', $stderr
213 13 4 if (defined $ubic_log)
214 0 13 unless open $ubic_fh, '>>', $ubic_log
220 0 17 unless open STDIN, '<', $stdin
233 0 17 unless $lock = $pid_state->lock(5)
239 2 15 if (defined $proxy_logs)
241 0 4 unless pipe my $read, my $write
246 0 17 if ($child = fork) { }
253 0 0 unless ($child_guid)
254 0 0 if ($OS->pid_exists($child))
258 0 0 unless (waitpid($child, 1) == $child)
269 0 0 if ($term_timeout)
281 0 0 if ($term_timeout > 0) { }
292 0 0 unless print {$write_pipe;} "pidfile written\n"
293 0 0 unless close $write_pipe
296 0 0 if (defined $proxy_logs)
299 0 0 if ($@) { }
309 0 0 unless (close $daemon_pipes{$handle}{'write'})
324 0 0 unless defined $bytes_read
325 0 0 if $bytes_read == 0
326 0 0 if (fileno $handle == fileno $daemon_pipes{'stdout'}{'read'})
329 0 0 if (fileno $handle == fileno $daemon_pipes{'stderr'}{'read'})
333 0 0 if $exhausted == @ready
341 0 0 if ($sigterm_sent and ($code & 127) == &POSIX::SIGTERM) { }
353 0 17 unless defined $child
359 0 17 if (defined $cwd)
360 0 0 unless chdir $cwd
362 0 17 if (defined $env)
367 1 16 if $start_hook
368 0 17 if $credentials
370 13 4 if defined $ubic_fh
373 0 17 unless print {$write_pipe;} "execing into daemon\n"
374 0 17 unless close $write_pipe
377 2 15 if (defined $proxy_logs)
380 0 2 unless open STDOUT, '>&=', $daemon_pipes{'stdout'}{'write'}
381 0 2 unless open STDERR, '>&=', $daemon_pipes{'stderr'}{'write'}
385 12 5 if (ref $bin) { }
3 2 elsif ($bin) { }
386 0 0 unless exec @$bin
389 0 0 unless exec $bin
396 0 0 if ($write_pipe)
403 0 133 unless close $write_pipe
409 0 133 unless close $read_pipe
410 122 11 if ($out =~ /^execing into daemon$/m and $out =~ /^pidfile written$/m)
424 0 10 unless $options->{'quiet'}
428 313 336 if $pid_state->is_empty
432 331 5 unless ($lock)
437 0 5 unless ($piddata)
443 0 5 if ($piddata->{'format'} and $piddata->{'format'} eq 'old')
446 0 5 unless ($piddata->{'daemon'})
450 0 5 unless ($OS->pid_exists($piddata->{'daemon'}))
460 0 5 unless ($guid)
464 5 0 if ($guid eq $piddata->{'guid'})