Branch Coverage

lib/Test/Nginx/Util.pm
Criterion Covered Total %
branch 10 742 1.3


line true false branch
188 0 0 if $used_ports->{$port}
197 0 0 if (defined $sock)
203 0 0 if ($Verbose)
218 0 0 if (ref $expected and ref $expected eq 'Regexp')
222 0 0 if ($NoLongString)
230 0 0 if (@_) { }
241 0 0 if (@_) { }
258 0 0 if (@_) { }
317 0 0 unless (@_)
321 0 0 if (not $v =~ /^[A-Za-z_]/ or $v =~ /\n/)
337 0 0 if (@_) { }
345 0 0 if (@_) { }
353 0 0 if (@_)
354 0 0 if ($CheckLeak or $Benchmark)
364 0 0 if (@_) { }
376 0 0 if (@_) { }
385 0 0 if (@_) { }
397 0 0 if ($CheckLeak)
408 0 0 if ($CheckLeak)
412 0 0 if (@_) { }
413 0 0 shift() ? :
535 0 0 if (defined $tm)
536 0 0 if ($tm =~ s/([^_a-zA-Z])ms$/$1/) { }
0 0 elsif ($tm =~ s/([^_a-zA-Z])s$/$1/) { }
568 0 0 if ($wait)
570 0 0 if (defined $pid)
571 0 0 if ($Verbose)
578 0 0 if ($Verbose)
588 0 0 if ($@)
589 0 0 if ($Verbose)
601 0 0 unless (&is_running($pid))
605 0 0 if ($Verbose)
609 0 0 if (kill(15, $pid) == 0)
614 0 0 if $step > 0.5
627 0 0 if (&is_running($pid))
636 0 5 if ($Verbose)
644 0 5 if (defined $UdpServerPid)
649 0 5 if (defined $TcpServerPid)
654 0 5 if (defined $ChildPid)
663 0 0 unless (open my $in, $AccLogFile)
664 0 0 if ($AccLogFile ne 'off')
681 0 0 unless open my $in, $ErrLogFile
684 0 0 if (not $CheckAccumErrLog and $ErrLogFilePos > 0)
690 0 0 unless ($CheckAccumErrLog)
701 5 0 unless (defined $block)
708 0 0 if (defined $block->shutdown_error_log)
709 0 0 if ($UseHup)
713 0 0 if ($ENV{'TEST_NGINX_NO_CLEAN'})
724 0 0 if (defined $NginxVersion)
728 0 0 unless (defined $ENV{'TEST_NGINX_SERVER_PORT'})
732 0 0 $NoShuffle ? :
748 0 0 if (-d $ServRoot)
754 0 0 if ($UseHup) { }
756 0 0 if (not -d $_)
757 0 0 if ($_ =~ /(?:\bnginx\.pid|\.sock|\.crt|\.key)$/)
758 0 0 unless $first_time
762 0 0 unless system("rm $_") == 0
769 0 0 unless rmdir $ServRoot
773 0 0 unless (-d $ServRoot)
774 0 0 unless mkdir $ServRoot
777 0 0 unless (-d $LogDir)
778 0 0 unless mkdir $LogDir
781 0 0 unless (-d $HtmlDir)
782 0 0 unless mkdir $HtmlDir
788 0 0 unless open my $out, ">$index_file"
795 0 0 unless mkdir $ConfDir
805 0 0 if ($files)
806 0 0 if (not ref $files) { }
0 0 elsif (ref $files ne 'ARRAY') { }
814 0 0 if (/>>> (\S+)(?:\s+(.+))?/) { }
815 0 0 if ($fname)
827 0 0 if ($fname)
840 0 0 unless (defined $body)
845 0 0 if (not $fname =~ m[^/]) { }
852 0 0 if ($path =~ m[(.*)/])
854 0 0 unless (-d $dir)
855 0 0 unless make_path($dir)
861 0 0 unless open my $out, ">$path"
868 0 0 if ($date)
870 0 0 unless system($cmd) == 0
887 0 0 if ($UseHup) { }
0 0 elsif ($UseValgrind) { }
0 0 elsif ($UseStap and defined $block->stap) { }
899 0 0 unless (defined $config)
903 0 0 unless (defined $http_config)
907 0 0 if ($FilterHttpConfig)
911 0 0 if ($http_config =~ /\bpostpone_output\b/)
917 0 0 if (defined $PostponeOutput)
918 0 0 unless ($PostponeOutput =~ /^\d+$/)
924 0 0 unless (defined $main_config)
928 0 0 if ($LoadModules)
930 0 0 if (@modules)
937 0 0 unless (defined $post_main_config)
943 0 0 if ($CheckLeak or $Benchmark)
948 0 0 unless ($err_log_file)
952 0 0 unless (defined $server_name)
959 0 0 unless open my $out, ">$ConfFile"
977 0 0 if ($v =~ /\s/)
985 0 0 if (&use_http2($block))
989 0 0 if ($ReusePort)
1025 0 0 unless ($NoRootLocation)
1036 0 0 if ($UseHup)
1064 0 0 if ($EventType)
1078 0 0 if (defined $WorkerUser) { }
0 0 elsif ($> == 0) { }
1093 0 0 if (defined $_[3])
1102 0 0 if (not defined $out or $? != 0)
1107 0 0 if ($out =~ /built with OpenSSL (\d+)\.(\d+)\.(\d+)([a-z])/s)
1111 0 0 if ($out =~ m[(?:nginx|openresty)[^/]*/(\d+)\.(\d+)\.(\d+)]s)
1116 0 0 if ($out =~ m[\w+/(\d+)\.(\d+)\.(\d+)]s)
1127 0 0 unless open my $in, $PidFile
1138 0 7 unless defined $s
1165 0 0 if (&use_http2($block))
1174 0 0 if ($Verbose)
1178 0 0 if ($ver eq $ConfigVersion) { }
1181 0 0 if ($nsucc == 5)
1185 0 0 if ($nsucc >= 20)
1194 0 0 if ($nsucc)
1195 0 0 if ($Verbose)
1204 0 0 if ($wait > 1)
1208 0 0 if ($wait > 0.5)
1230 0 0 if ($neg) { }
1244 0 0 unless (defined $text)
1256 0 0 if ($1 =~ /^(TEST_NGINX_RAND_PORT_[0-9]+)$/) { }
1257 0 0 if (not defined $rand_ports->{$1}) { }
1260 0 0 unless (defined $rand_port)
1272 0 0 unless (defined $ENV{$1})
1284 0 0 unless open my $in, $ErrLogFile
1289 0 0 if (/\[emerg\] \S+?: unknown directive "([^"]+)"/)
1307 0 0 if (defined $tcp_socket)
1309 0 0 if ($tcp_query_file)
1310 0 0 if (open my $in, $tcp_query_file)
1316 0 0 if (defined $block->tcp_query)
1320 0 0 if (defined $block->tcp_query_len)
1331 0 0 if (defined $udp_socket)
1333 0 0 if ($udp_query_file)
1334 0 0 if (not open(my $in, $udp_query_file)) { }
1343 0 0 if (defined $block->udp_query)
1352 0 0 if defined $block->SKIP
1357 0 0 if ($FirstTime)
1376 0 0 if ($block->log_level)
1386 0 0 if (defined $block->must_die)
1388 0 0 if (defined $block->stap)
1392 0 0 if ($UseStap)
1396 0 0 if ($UseValgrind)
1400 0 0 if ($UseHup)
1404 0 0 if ($Profiling)
1409 0 0 if (not defined $config) { }
0 0 elsif ($NoNginxManager) { }
1410 0 0 unless ($NoNginxManager)
1412 0 0 unless (defined $PrevConfig)
1434 0 0 if (not defined $PrevConfig or $config ne $PrevConfig) { }
1439 0 0 if ($should_reconfig or $ForceRestartOnTest) { }
1455 0 0 if (defined $block->reload_fails or defined $block->http2)
1459 0 0 if ($CheckLeak || $Benchmark and defined $block->no_check_leak)
1463 0 0 if (defined $skip_eval)
1464 0 0 if ($skip_eval =~ / ^ \s* (\d+) \s* : \s* (.*) /sx)
1472 0 0 if ($@)
1479 0 0 if (defined $skip_nginx) { }
0 0 elsif (defined $skip_nginx2) { }
0 0 elsif (defined $skip_slave and defined $BuildSlaveName) { }
1480 0 0 if ($skip_nginx =~ / ^ \s* (\d+) \s* : \s* ([<>]=?) \s* (\d+)\.(\d+)\.(\d+) (?: \s* : \s* (.*) )? \s*$/x) { }
1488 0 0 unless ($skip_reason)
1493 0 0 if (not defined $NginxVersion and $op =~ /^
1504 0 0 if ($skip_nginx2 =~ / ^ \s* (\d+) \s* : \s* ([<>]=?) \s* (\d+)\.(\d+)\.(\d+) \s* (or|and) \s* ([<>]=?) \s* (\d+)\.(\d+)\.(\d+) (?: \s* : \s* (.*) )? \s*$/x) { }
1519 0 0 if (not defined $NginxVersion or $opx eq 'or' and eval "$NginxVersion $opa $vera" || eval "$NginxVersion $opb $verb" or $opx eq 'and' and (eval "$NginxVersion $opa $vera" and eval "$NginxVersion $opb $verb"))
1533 0 0 if ($skip_slave =~ / ^ \s* (\d+) \s* : \s* (\w+) \s* (?: (\w+) \s* )? (?: (\w+) \s* )? (?: \s* : \s* (.*) )? \s*$/x) { }
1541 0 0 if (defined $slave1 and $slave1 eq 'all' or defined $slave1 and $slave1 eq $BuildSlaveName or defined $slave2 and $slave2 eq $BuildSlaveName or defined $slave3 and $slave3 eq $BuildSlaveName)
1556 0 0 if (defined $skip_openssl)
1557 0 0 if ($skip_openssl =~ / ^ \s* (\d+) \s* : \s* ([<>]=?) \s* (\d+)\.(\d+)\.(\d+)([a-z])? (?: \s* : \s* (.*) )? \s*$/x) { }
1565 0 0 unless ($skip_reason)
1566 0 0 if (not defined $OpenSSLVersion) { }
0 0 elsif (defined $ver4) { }
1578 0 0 if (not defined $OpenSSLVersion or eval "$OpenSSLVersion $op $ver")
1589 0 0 unless (defined $skip_reason)
1595 0 0 if (defined $todo_nginx)
1596 0 0 if ($todo_nginx =~ / ^ \s* ([<>]=?) \s* (\d+)\.(\d+)\.(\d+) (?: \s* : \s* (.*) )? \s*$/x) { }
1604 0 0 if (not defined $NginxVersion and $op =~ /^
1617 0 0 if (defined $todo)
1618 0 0 if ($todo =~ / ^ \s* (\d+) \s* : \s* (.*) /sx) { }
1632 0 0 unless (defined $todo_reason)
1638 0 0 if (not $NoNginxManager || $should_skip and $should_restart)
1641 0 0 if ($UseHup)
1645 0 0 if ($should_reconfig)
1653 0 0 if (-f $PidFile) { }
1659 0 0 if (not defined $pid or $pid eq '')
1667 0 0 if (&is_running($pid)) { }
1670 0 0 if ($UseHup)
1671 0 0 if ($first_time)
1682 0 0 if ($Verbose)
1685 0 0 if (system("kill -USR1 $pid") == 0) { }
1688 0 0 if ($Verbose)
1692 0 0 if (system("kill -HUP $pid") == 0) { }
1695 0 0 if ($Verbose)
1701 0 0 if ($UseValgrind)
1705 0 0 if (defined $block->reload_fails) { }
1717 0 0 if ($Verbose)
1732 0 0 if (-f $PidFile)
1733 0 0 unless unlink $PidFile
1748 0 0 unless ($nginx_is_running)
1749 0 0 if ($Verbose)
1760 0 0 unless (can_run($NginxBinary))
1768 0 0 unless (defined $NginxVersion)
1774 0 0 if ($NginxVersion >= 0.007053) { }
1780 0 0 if ($UseRr)
1784 0 0 if ($UseValgrind) { }
0 0 elsif ($UseStap) { }
1787 0 0 if ($UseValgrind =~ /^\d+$/) { }
1790 0 0 if (-f 'valgrind.suppress') { }
1808 0 0 if ($StapOutFileHandle)
1813 0 0 if ($block->stap)
1820 0 0 if ($stap =~ /\$LIB([_A-Z0-9]+)_PATH\b/)
1828 0 0 if ($line =~ m[\S+/$libname.*?\.so(?:\.\d+)*]) { }
1848 0 0 unless (defined $block->stap_out or defined $block->stap_out_like or defined $block->stap_out_unlike)
1855 0 0 if (not $StapOutFile) { }
1868 0 0 unless open $out, $outfile
1874 0 0 if (defined $ENV{'LD_PRELOAD'})
1878 0 0 if (defined $ENV{'LD_LIBRARY_PATH'})
1890 0 0 if ($Profiling or $UseValgrind or $UseStap) { }
1893 0 0 if (not defined $pid) { }
0 0 elsif ($pid == 0) { }
1905 0 0 if ($Verbose)
1931 0 0 if ($status == -1) { }
1937 0 0 if ($? > 32768) { }
1946 0 0 if (defined $must_die)
1948 0 0 if ($exec_failed) { }
0 0 elsif ($coredump) { }
0 0 elsif (&looks_like_number($must_die)) { }
1965 0 0 if ($status == 0)
1970 0 0 if (-f $PidFile)
1979 0 0 if ++$i < $RepeatEach
1983 0 0 if ($status != 0)
1984 0 0 if ($ENV{'TEST_NGINX_IGNORE_MISSING_DIRECTIVES'} and my $directive = &check_if_missing_directives()) { }
1992 0 0 if ($delay > 1)
1997 0 0 if $waited < 30
2009 0 0 if ($Verbose)
2013 0 0 if ($block->init)
2015 0 0 if ($@)
2025 0 0 if ($Verbose)
2029 0 0 if ($CheckLeak || $Benchmark and defined $block->tcp_listen)
2031 0 0 defined $block->tcp_query_len ? :
2032 0 0 defined $block->tcp_query ? :
2034 0 0 if ($n)
2043 0 0 if (not $CheckLeak || $Benchmark and defined $block->tcp_listen)
2048 0 0 unless (defined $reply or defined $block->tcp_shutdown)
2054 0 0 if (defined $block->tcp_query or defined $req_len)
2055 0 0 unless (defined $req_len)
2065 0 0 if ($target =~ /^\d+$/) { }
0 0 elsif ($target =~ /\S+\.sock$/) { }
2075 0 0 if (-e $target)
2076 0 0 unless unlink $target
2089 0 0 if ($tcp_socket)
2093 0 0 if ($!)
2095 0 0 if ($err =~ /address already in use/i)
2097 0 0 if ($i >= 20)
2099 0 0 if ($pids)
2103 0 0 if ($pid == $$)
2121 0 0 if (not $tcp_socket and $err)
2127 0 0 if (not defined $pid) { }
0 0 elsif ($pid == 0) { }
2140 0 0 if ($Verbose)
2150 0 0 if $client
2156 0 0 if (defined $block->tcp_shutdown)
2158 0 0 if ($block->tcp_shutdown_delay)
2162 0 0 if ($shutdown == 0 or $shutdown == 2) { }
2163 0 0 if ($Verbose)
2169 0 0 if ($Verbose)
2178 0 0 unless ($no_read)
2179 0 0 if ($Verbose)
2186 0 0 unless (defined $ret)
2190 0 0 if ($Verbose)
2199 0 0 if ($tcp_query_file)
2200 0 0 unless open my $out, ">$tcp_query_file"
2203 0 0 if ($Verbose)
2211 0 0 if (not $req_len or length $buf >= $req_len)
2212 0 0 if ($Verbose)
2221 0 0 if ($delay)
2222 0 0 if ($Verbose)
2228 0 0 unless ($no_write)
2229 0 0 if (defined $reply)
2230 0 0 if ($Verbose)
2235 0 0 if ($ref and $ref eq 'CODE')
2240 0 0 if (ref $reply) { }
2241 0 0 if ($ref ne 'ARRAY')
2246 0 0 if ($Verbose)
2250 0 0 unless (defined $bytes)
2257 0 0 unless (defined $bytes)
2264 0 0 if ($Verbose)
2268 0 0 if (defined $block->tcp_no_close)
2281 0 0 if ($Verbose)
2289 0 0 if ($CheckLeak || $Benchmark and defined $block->udp_listen)
2291 0 0 defined $block->udp_query ? :
2293 0 0 if ($n)
2302 0 0 if (not $CheckLeak || $Benchmark and defined $block->udp_listen)
2304 0 0 unless (defined $reply)
2308 0 0 if (defined $block->udp_query)
2313 0 0 if ($target =~ /^\d+$/) { }
0 0 elsif ($target =~ /\S+\.sock$/) { }
2316 0 0 unless $udp_socket = 'IO::Socket::INET'->new('LocalPort', $port, 'Proto', 'udp', 'Reuse', 1, 'Timeout', &timeout())
2324 0 0 if (-e $target)
2325 0 0 unless unlink $target
2328 0 0 unless $udp_socket = 'IO::Socket::UNIX'->new('Local', $target, 'Type', 2, 'Reuse', 1, 'Timeout', &timeout())
2345 0 0 if (not defined $pid) { }
0 0 elsif ($pid == 0) { }
2358 0 0 if ($Verbose)
2364 0 0 if ($Verbose)
2371 0 0 unless (defined $sender)
2375 0 0 if ($Verbose)
2379 0 0 if ($udp_query_file)
2380 0 0 unless open my $out, ">$udp_query_file"
2383 0 0 if ($Verbose)
2392 0 0 if ($delay)
2393 0 0 if ($Verbose)
2399 0 0 if (defined $reply)
2401 0 0 if ($ref and $ref eq 'CODE')
2406 0 0 if ($ref) { }
2407 0 0 if ($ref ne 'ARRAY')
2414 0 0 unless (defined $bytes)
2420 0 0 if ($reply =~ /syntax error at \(eval \d+\) line \d+, near/)
2425 0 0 unless (defined $bytes)
2431 0 0 if ($Verbose)
2439 0 0 if ($Verbose)
2447 0 0 if ($i > 1)
2451 0 0 if ($should_skip and defined $tests_to_skip) { }
0 0 elsif ($should_todo) { }
2475 0 0 if (defined $udp_socket)
2476 0 0 if (defined $UdpServerPid)
2485 0 0 if (defined $uds_socket_file)
2486 0 0 unless unlink $uds_socket_file
2490 0 0 if (defined $tcp_socket)
2491 0 0 if (defined $TcpServerPid)
2492 0 0 if ($Verbose)
2499 0 0 if ($Verbose)
2508 0 0 if ($StapOutFileHandle)
2513 0 0 if (my $total_errlog = $ENV{'TEST_NGINX_ERROR_LOG'})
2515 0 0 if (-s $errlog)
2516 0 0 unless open my $out, ">>$total_errlog"
2520 0 0 unless system("cat $errlog >> $total_errlog") == 0
2525 0 0 if ($Profiling || $UseValgrind || $UseStap and not $UseHup)
2527 0 0 if (-f $PidFile) { }
2532 0 0 if (&is_running($pid)) { }
2535 0 0 if ($Verbose)
2539 0 0 if (kill(3, $pid) == 0)
2545 0 0 if (-f $PidFile) { }
2546 0 0 if ($i++ < 20)
2547 0 0 if ($Verbose)
2554 0 0 if ($Verbose)
2561 0 0 if (not unlink($PidFile) and -f $PidFile)
2570 0 0 if (not unlink($PidFile) and -f $PidFile)
2581 0 5 if $InSubprocess
2585 5 0 if ($UseStap or $UseValgrind or not $ENV{'TEST_NGINX_NO_CLEAN'})
2587 0 5 if (defined $PidFile and -f $PidFile)
2589 0 0 unless ($pid)
2592 0 0 if (&is_running($pid)) { }
2603 0 5 if ($Randomize)
2604 0 0 if (defined $ServRoot and -d $ServRoot and $ServRoot =~ m[/t/servroot_\d+])
2615 0 0 if ($cmd =~ m([/\\]))
2616 0 0 if (-f $cmd and -x $cmd)
2624 0 0 if $dir eq ''
2627 0 0 if -f $abs and -x $abs
2637 0 0 if (defined $cached)
2641 0 0 if (defined $block->http2)
2642 0 0 if ($block->raw_request)
2646 0 0 if ($block->pipelined_requests)
2652 0 0 unless ($LoadedIPCRun)
2659 0 0 if ($UseHttp2)
2660 0 0 if ($block->raw_request)
2666 0 0 if ($block->pipelined_requests)
2672 0 0 unless (defined $block->request)
2677 0 0 if (not ref $block->request and $block->request =~ m[HTTP/1\.0]s)
2685 0 0 unless ($LoadedIPCRun)