Branch Coverage

blib/lib/Feersum/Runner.pm
Criterion Covered Total %
branch 94 372 25.2


line true false branch
12 0 10 unless (eval { do { "Socket"->import("AF_INET6", "inet_pton", "pack_sockaddr_in6"); 1 } })
21 0 10 unless eval { do { "Socket"->import("SO_REUSEPORT"); 1 } }
38 2 20 if ($INSTANCE)
40 0 2 if $Feersum::Runner::INSTANCE->{'running'}
51 2 21 if $self->{'_cleaned_up'}
53 6 15 if (my $f = $self->{'endjinn'})
59 0 21 if (my $file = $self->{'pid_file'})
60 0 0 if -f $file
75 0 13 if ($listen =~ m[^[/\.]+\w]) { }
77 0 0 if (-S $listen)
78 0 0 unless unlink $listen
89 0 0 if $err
90 0 0 unless $sock
91 0 0 unless ($sock->blocking(0))
96 0 13 if ($use_reuseport and defined 15) { }
99 0 0 if ($listen =~ /^\[([^\]]+)\]:(\d*)$/) { }
0 0 elsif ($listen =~ /^\[([^\]]+)\]$/) { }
0 0 elsif ($listen =~ /:.*:/) { }
107 0 0 if ($listen =~ /:(\d{1,5})$/)
110 0 0 if ($maybe_port <= 65535 and length $maybe_port == 5 || $maybe_port >= 1024)
125 0 0 if (not $port =~ /^\d+$/ or $port > 65535)
130 0 0 if ($is_ipv6) { }
131 0 0 unless defined 10
133 0 0 unless my $addr = inet_pton(10, $host)
138 0 0 unless my $addr = inet_aton($host)
145 0 0 unless socket $sock, $domain, 1, 0
148 0 0 unless (setsockopt $sock, 1, 2, "\1\0\0\0")
150 0 0 unless (setsockopt $sock, 1, 15, "\1\0\0\0")
152 0 0 unless (bind $sock, $sockaddr)
154 0 0 unless (listen $sock, $backlog)
160 0 0 unless ($sock->blocking(0))
164 13 0 if ($listen =~ /:(\d+)$/) { }
0 0 elsif ($listen =~ /:(\S+)$/) { }
166 0 13 if $port > 65535
169 0 0 unless $port =~ /^\d+$/
178 0 13 unless $sock
186 0 3 if (my $opts = $self->{'options'})
232 170 0 $consume ? :
233 2 168 if defined $val
235 10 0 if ($f->can("max_h2_concurrent_streams"))
237 10 0 $consume ? :
238 0 10 if defined $v
248 0 0 unless my $max = $self->{'max_requests_per_worker'}
250 0 0 if ($f->total_requests >= $max)
263 0 0 if ($sni)
264 0 0 unless ref $sni eq "ARRAY"
275 0 13 if (defined $self->{'listen'} and not ref $self->{'listen'})
281 0 13 if ref $self->{'listen'} ne "ARRAY"
283 0 13 if @{$self->{'listen'};} == 0
295 10 3 if (not $self->{'tls'}) { }
296 2 8 if (my $cert = delete $self->{'tls_cert_file'}) { }
1 7 elsif (delete $self->{'tls_key_file'}) { }
298 1 1 unless my $key = delete $self->{'tls_key_file'}
308 4 7 if (my $tls = $self->{'tls'}) { }
1 6 elsif (delete $self->{'h2'}) { }
309 0 4 unless ref $tls eq "HASH"
310 0 4 unless $tls->{'cert_file'}
311 0 4 unless $tls->{'key_file'}
313 1 3 if delete $self->{'h2'}
326 3 10 if ($self->{'pre_fork'})
328 0 3 if (not $n =~ /^\d+$/ or $n < 1)
331 0 3 if ($n > 1000)
344 2 0 if ($self->{'epoll_exclusive'} and $self->{'pre_fork'} and $^O eq "linux")
351 1 12 if (defined $self->{'accept_priority'} and $f->can("accept_priority"))
353 0 1 unless $val =~ /^-?\d+$/
354 1 0 if $val < -2 or $val > 2
370 29 4 unless defined $val
371 0 4 unless $val =~ /^-?\d+$/
372 2 2 if $val < -2 or $val > 2
374 0 10 if (defined(my $val = $self->{'max_accept_per_loop'}))
375 0 0 unless $val =~ /^\d+$/ and $val > 0
378 0 10 if (defined(my $val = $self->{'max_connections'}))
379 0 0 unless $val =~ /^\d+$/
389 2 6 if (my $tls = delete $self->{'tls'})
390 2 0 unless -f $tls->{'cert_file'} and -r _
392 0 0 unless -f $tls->{'key_file'} and -r _
395 0 0 if ($f->has_tls) { }
398 0 0 unless $self->{'quiet'}
412 0 3 if (my $log_cb = $self->{'access_log'})
434 0 3 unless $self->{'quiet'}
440 0 3 if ($self->{'hot_restart'})
441 0 0 unless $self->{'app_file'}
453 0 3 if ($self->{'pre_fork'} and defined $self->{'preload_app'} and not $self->{'preload_app'}) { }
456 0 0 if (not $a and $self->{'app_file'})
459 0 0 if $@ or not $a
461 0 0 unless $a
469 0 0 if $self
473 3 0 if (not $app and $self->{'app_file'})
476 0 3 if $@
477 0 3 if $! and not defined $app
478 0 3 unless $app
481 0 3 unless $app
485 6 0 if $self
487 3 0 if $self->{'pre_fork'}
490 0 3 unless $self->{'quiet'}
502 0 0 unless $quiet
540 0 0 unless defined $pid
542 0 0 if ($pid == 0)
545 0 0 unless $quiet
554 0 0 if ($self->{'epoll_exclusive'} and $self->{'pre_fork'} and $^O eq "linux" and $f->can("set_epoll_exclusive"))
560 0 0 if (defined $self->{'accept_priority'} and $f->can("accept_priority"))
576 0 0 if ($@ or not $app or ref $app ne "CODE")
587 0 0 if ($self->{'pre_fork'})
599 0 0 if ($self->{'pre_fork'})
605 0 0 unless POSIX::setsid()
613 0 0 unless ($self->{'pre_fork'})
614 0 0 if $self->{'after_fork'}
622 0 0 $self->{'pre_fork'} ? :
0 0 unless $quiet
632 0 0 unless (_wait_for_ready($pending_pid, $quiet, $gen, \$shutting_down, $startup_timeout))
633 0 0 if kill 0, $pending_pid
640 0 0 unless $quiet
643 0 0 if $shutting_down or $pending_pid
644 0 0 unless $quiet
649 0 0 if (_wait_for_ready($pending_pid, $quiet, $gen, \$shutting_down, $startup_timeout)) { }
650 0 0 unless $quiet
653 0 0 if $old_pid
656 0 0 if kill 0, $pending_pid
663 0 0 if $shutting_down
665 0 0 unless $quiet
666 0 0 if $current_pid
669 0 0 if $pending_pid
673 0 0 if $shutting_down
675 0 0 unless $quiet
676 0 0 if $current_pid
677 0 0 if $pending_pid
684 0 0 unless $quiet
686 0 0 if $pending_pid and $kid == $pending_pid
687 0 0 if ($current_pid and $kid == $current_pid)
689 0 0 if $shutting_down
690 0 0 unless ($shutting_down or $pending_pid)
693 0 0 if (_wait_for_ready($pending_pid, $quiet, $gen, \$shutting_down, $startup_timeout)) { }
698 0 0 if kill 0, $pending_pid
711 0 0 unless $quiet
743 0 0 $self->{'epoll_exclusive'} && $self->{'pre_fork'} ? :
0 0 if defined $self->{'epoll_exclusive'} and $f->can("set_epoll_exclusive")
746 0 0 if (my $tls = $self->{'tls'})
747 0 0 if ($f->has_tls) { }
748 0 0 unless $self->{'_master_socks'}
765 0 20 unless defined $pid
766 0 20 unless ($pid)
768 0 0 unless $self->{'quiet'}
775 0 0 if ($self->{'_use_reuseport'})
777 0 0 unless $self->{'_socks'}
779 0 0 unless (close $old_sock)
789 0 0 unless (eval { do { foreach my $listen (@{$$self{"_listen_addrs"};}) { my $sock = $self->_create_socket($listen, 1); push @new_socks, $sock; $self->{'endjinn'}->use_socket($sock); } ; 1 } })
797 0 0 if (my $tls = $self->{'_tls_config'})
804 0 0 if (my $loader = $self->{'_app_loader'})
806 0 0 if ($@)
812 0 0 if (my $cb = $self->{'after_fork'})
817 0 0 if $@
818 0 0 $@ ? :
825 0 20 unless $self
826 0 20 unless $self->{'quiet'}
829 20 0 if ($self->{'_shutdown'})
830 3 17 unless ($self->{'_n_kids'})
837 0 0 if ($self->{'_use_reuseport'}) { }
839 0 0 unless $self->{'_socks'}
842 0 0 unless (defined fileno $sock)
847 0 0 if ($all_valid) { }
871 0 3 unless POSIX::setsid()
882 0 3 if ($self->{'_use_reuseport'})
883 0 0 unless $self->{'_socks'}
884 0 0 unless close $sock
896 0 3 if ($self->{'daemonize'}) { }
0 3 elsif (my $file = $self->{'pid_file'}) { }
898 0 0 unless defined $pid
899 0 0 if ($pid)
900 0 0 if (my $file = $self->{'pid_file'})
901 0 0 unless open my $fh, ">", $file
908 0 0 unless open STDIN, "<", "/dev/null"
909 0 0 unless open STDOUT, ">", "/dev/null"
911 0 0 unless $ENV{'FEERSUM_DEBUG'}
913 0 0 unless open my $fh, ">", $file
921 1 4 if (my $group = $self->{'group'})
923 1 0 unless defined $gid
928 0 0 if $!
929 0 0 unless POSIX::setgid($gid)
933 0 0 unless @rg == 1 and $rg[0] == $gid
936 1 3 if (my $user = $self->{'user'})
938 1 0 unless defined $uid
939 0 0 unless POSIX::setuid($uid)
941 0 0 unless $< == $uid and $> == $uid
948 3 3 if $self->{'_shutdown'}
951 0 3 unless $self->{'quiet'}
956 3 0 if ($self->{'_n_kids'}) { }