Branch Coverage

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


line true false branch
184 0 0 if (ref $expected and ref $expected eq 'Regexp')
188 0 0 if ($NoLongString)
196 0 0 if (@_) { }
207 0 0 if (@_) { }
224 0 0 if (@_) { }
304 0 0 unless (@_)
308 0 0 if (not $v =~ /^[A-Za-z_]/ or $v =~ /\n/)
324 0 0 if (@_) { }
332 0 0 if (@_) { }
340 0 0 if (@_)
341 0 0 if ($CheckLeak or $Benchmark)
351 0 0 if (@_) { }
363 0 0 if (@_) { }
372 0 0 if (@_) { }
384 0 0 if ($CheckLeak)
395 0 0 if ($CheckLeak)
399 0 0 if (@_) { }
400 0 0 shift() ? :
522 0 0 if (defined $tm)
523 0 0 if ($tm =~ s/([^_a-zA-Z])ms$/$1/) { }
0 0 elsif ($tm =~ s/([^_a-zA-Z])s$/$1/) { }
555 0 0 if ($wait)
557 0 0 if (defined $pid)
558 0 0 if ($Verbose)
565 0 0 if ($Verbose)
575 0 0 if ($@)
576 0 0 if ($Verbose)
588 0 0 unless (&is_running($pid))
592 0 0 if ($Verbose)
596 0 0 if (kill(15, $pid) == 0)
601 0 0 if $step > 0.5
614 0 0 if (&is_running($pid))
623 0 5 if ($Verbose)
631 0 5 if (defined $UdpServerPid)
636 0 5 if (defined $TcpServerPid)
641 0 5 if (defined $ChildPid)
650 0 0 unless (open my $in, $AccLogFile)
651 0 0 if ($AccLogFile ne 'off')
668 0 0 unless open my $in, $ErrLogFile
671 0 0 if (not $CheckAccumErrLog and $ErrLogFilePos > 0)
677 0 0 unless ($CheckAccumErrLog)
688 5 0 unless (defined $block)
695 0 0 if (defined $block->shutdown_error_log)
696 0 0 if ($UseHup)
700 0 0 if ($ENV{'TEST_NGINX_NO_CLEAN'})
711 0 0 if (defined $NginxVersion)
715 0 0 unless (defined $ENV{'TEST_NGINX_SERVER_PORT'})
719 0 0 $NoShuffle ? :
735 0 0 if (-d $ServRoot)
741 0 0 if ($UseHup) { }
743 0 0 if (not -d $_)
744 0 0 if ($_ =~ /(?:\bnginx\.pid|\.sock|\.crt|\.key)$/)
745 0 0 unless $first_time
749 0 0 unless system("rm $_") == 0
756 0 0 unless rmdir $ServRoot
760 0 0 unless (-d $ServRoot)
761 0 0 unless mkdir $ServRoot
764 0 0 unless (-d $LogDir)
765 0 0 unless mkdir $LogDir
768 0 0 unless (-d $HtmlDir)
769 0 0 unless mkdir $HtmlDir
775 0 0 unless open my $out, ">$index_file"
782 0 0 unless mkdir $ConfDir
792 0 0 if ($files)
793 0 0 if (not ref $files) { }
0 0 elsif (ref $files ne 'ARRAY') { }
801 0 0 if (/>>> (\S+)(?:\s+(.+))?/) { }
802 0 0 if ($fname)
814 0 0 if ($fname)
827 0 0 unless (defined $body)
832 0 0 if (not $fname =~ m[^/]) { }
839 0 0 if ($path =~ m[(.*)/])
841 0 0 unless (-d $dir)
842 0 0 unless make_path($dir)
848 0 0 unless open my $out, ">$path"
855 0 0 if ($date)
857 0 0 unless system($cmd) == 0
873 0 0 if ($UseHup) { }
0 0 elsif ($UseValgrind) { }
0 0 elsif ($UseStap and defined $block->stap) { }
885 0 0 unless (defined $config)
889 0 0 unless (defined $http_config)
893 0 0 if ($FilterHttpConfig)
897 0 0 if ($http_config =~ /\bpostpone_output\b/)
903 0 0 if (defined $PostponeOutput)
904 0 0 unless ($PostponeOutput =~ /^\d+$/)
910 0 0 unless (defined $main_config)
914 0 0 if ($LoadModules)
916 0 0 if (@modules)
923 0 0 unless (defined $post_main_config)
929 0 0 if ($CheckLeak or $Benchmark)
934 0 0 unless ($err_log_file)
938 0 0 unless (defined $server_name)
945 0 0 unless open my $out, ">$ConfFile"
963 0 0 if ($v =~ /\s/)
971 0 0 if (&use_http2($block))
975 0 0 if ($ReusePort)
1011 0 0 unless ($NoRootLocation)
1022 0 0 if ($UseHup)
1050 0 0 if ($EventType)
1064 0 0 if (defined $WorkerUser) { }
0 0 elsif ($> == 0) { }
1079 0 0 if (defined $_[3])
1088 0 0 if (not defined $out or $? != 0)
1093 0 0 if ($out =~ /built with OpenSSL (\d+)\.(\d+)\.(\d+)([a-z])/s)
1097 0 0 if ($out =~ m[(?:nginx|openresty)[^/]*/(\d+)\.(\d+)\.(\d+)]s)
1102 0 0 if ($out =~ m[\w+/(\d+)\.(\d+)\.(\d+)]s)
1113 0 0 unless open my $in, $PidFile
1124 0 7 unless defined $s
1151 0 0 if (&use_http2($block))
1160 0 0 if ($Verbose)
1164 0 0 if ($ver eq $ConfigVersion) { }
1167 0 0 if ($nsucc == 5)
1171 0 0 if ($nsucc >= 20)
1180 0 0 if ($nsucc)
1181 0 0 if ($Verbose)
1190 0 0 if ($wait > 1)
1194 0 0 if ($wait > 0.5)
1216 0 0 if ($neg) { }
1230 0 0 unless (defined $text)
1235 0 0 unless (defined $ENV{$1})
1244 0 0 unless open my $in, $ErrLogFile
1249 0 0 if (/\[emerg\] \S+?: unknown directive "([^"]+)"/)
1267 0 0 if (defined $tcp_socket)
1269 0 0 if ($tcp_query_file)
1270 0 0 if (open my $in, $tcp_query_file)
1276 0 0 if (defined $block->tcp_query)
1280 0 0 if (defined $block->tcp_query_len)
1291 0 0 if (defined $udp_socket)
1293 0 0 if ($udp_query_file)
1294 0 0 if (not open(my $in, $udp_query_file)) { }
1303 0 0 if (defined $block->udp_query)
1312 0 0 if defined $block->SKIP
1317 0 0 if ($FirstTime)
1334 0 0 if ($block->log_level)
1344 0 0 if (defined $block->must_die)
1346 0 0 if (defined $block->stap)
1350 0 0 if ($UseStap)
1354 0 0 if ($UseValgrind)
1358 0 0 if ($UseHup)
1362 0 0 if ($Profiling)
1367 0 0 if (not defined $config) { }
0 0 elsif ($NoNginxManager) { }
1368 0 0 unless ($NoNginxManager)
1370 0 0 unless (defined $PrevConfig)
1392 0 0 if (not defined $PrevConfig or $config ne $PrevConfig) { }
1397 0 0 if ($should_reconfig or $ForceRestartOnTest) { }
1413 0 0 if (defined $block->reload_fails or defined $block->http2)
1417 0 0 if ($CheckLeak || $Benchmark and defined $block->no_check_leak)
1421 0 0 if (defined $skip_eval)
1422 0 0 if ($skip_eval =~ / ^ \s* (\d+) \s* : \s* (.*) /sx)
1430 0 0 if ($@)
1437 0 0 if (defined $skip_nginx) { }
0 0 elsif (defined $skip_nginx2) { }
0 0 elsif (defined $skip_slave and defined $BuildSlaveName) { }
1438 0 0 if ($skip_nginx =~ / ^ \s* (\d+) \s* : \s* ([<>]=?) \s* (\d+)\.(\d+)\.(\d+) (?: \s* : \s* (.*) )? \s*$/x) { }
1446 0 0 unless ($skip_reason)
1451 0 0 if (not defined $NginxVersion and $op =~ /^
1462 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) { }
1477 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"))
1491 0 0 if ($skip_slave =~ / ^ \s* (\d+) \s* : \s* (\w+) \s* (?: (\w+) \s* )? (?: (\w+) \s* )? (?: \s* : \s* (.*) )? \s*$/x) { }
1499 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)
1514 0 0 if (defined $skip_openssl)
1515 0 0 if ($skip_openssl =~ / ^ \s* (\d+) \s* : \s* ([<>]=?) \s* (\d+)\.(\d+)\.(\d+)([a-z])? (?: \s* : \s* (.*) )? \s*$/x) { }
1523 0 0 unless ($skip_reason)
1524 0 0 if (not defined $OpenSSLVersion) { }
0 0 elsif (defined $ver4) { }
1536 0 0 if (not defined $OpenSSLVersion or eval "$OpenSSLVersion $op $ver")
1547 0 0 unless (defined $skip_reason)
1553 0 0 if (defined $todo_nginx)
1554 0 0 if ($todo_nginx =~ / ^ \s* ([<>]=?) \s* (\d+)\.(\d+)\.(\d+) (?: \s* : \s* (.*) )? \s*$/x) { }
1562 0 0 if (not defined $NginxVersion and $op =~ /^
1575 0 0 if (defined $todo)
1576 0 0 if ($todo =~ / ^ \s* (\d+) \s* : \s* (.*) /sx) { }
1590 0 0 unless (defined $todo_reason)
1596 0 0 if (not $NoNginxManager || $should_skip and $should_restart)
1599 0 0 if ($UseHup)
1603 0 0 if ($should_reconfig)
1611 0 0 if (-f $PidFile) { }
1617 0 0 if (not defined $pid or $pid eq '')
1625 0 0 if (&is_running($pid)) { }
1628 0 0 if ($UseHup)
1629 0 0 if ($first_time)
1640 0 0 if ($Verbose)
1643 0 0 if (system("kill -USR1 $pid") == 0) { }
1646 0 0 if ($Verbose)
1650 0 0 if (system("kill -HUP $pid") == 0) { }
1653 0 0 if ($Verbose)
1659 0 0 if ($UseValgrind)
1663 0 0 if (defined $block->reload_fails) { }
1675 0 0 if ($Verbose)
1690 0 0 if (-f $PidFile)
1691 0 0 unless unlink $PidFile
1706 0 0 unless ($nginx_is_running)
1707 0 0 if ($Verbose)
1718 0 0 unless (can_run($NginxBinary))
1726 0 0 unless (defined $NginxVersion)
1732 0 0 if ($NginxVersion >= 0.007053) { }
1738 0 0 if ($UseRr)
1742 0 0 if ($UseValgrind) { }
0 0 elsif ($UseStap) { }
1745 0 0 if ($UseValgrind =~ /^\d+$/) { }
1748 0 0 if (-f 'valgrind.suppress') { }
1766 0 0 if ($StapOutFileHandle)
1771 0 0 if ($block->stap)
1778 0 0 if ($stap =~ /\$LIB([_A-Z0-9]+)_PATH\b/)
1786 0 0 if ($line =~ m[\S+/$libname.*?\.so(?:\.\d+)*]) { }
1806 0 0 unless (defined $block->stap_out or defined $block->stap_out_like or defined $block->stap_out_unlike)
1813 0 0 if (not $StapOutFile) { }
1826 0 0 unless open $out, $outfile
1832 0 0 if (defined $ENV{'LD_PRELOAD'})
1836 0 0 if (defined $ENV{'LD_LIBRARY_PATH'})
1848 0 0 if ($Profiling or $UseValgrind or $UseStap) { }
1851 0 0 if (not defined $pid) { }
0 0 elsif ($pid == 0) { }
1863 0 0 if ($Verbose)
1889 0 0 if ($status == -1) { }
1895 0 0 if ($? > 32768) { }
1904 0 0 if (defined $must_die)
1906 0 0 if ($exec_failed) { }
0 0 elsif ($coredump) { }
0 0 elsif (&looks_like_number($must_die)) { }
1923 0 0 if ($status == 0)
1928 0 0 if (-f $PidFile)
1937 0 0 if ++$i < $RepeatEach
1941 0 0 if ($status != 0)
1942 0 0 if ($ENV{'TEST_NGINX_IGNORE_MISSING_DIRECTIVES'} and my $directive = &check_if_missing_directives()) { }
1950 0 0 if ($delay > 1)
1955 0 0 if $waited < 30
1967 0 0 if ($Verbose)
1971 0 0 if ($block->init)
1973 0 0 if ($@)
1983 0 0 if ($Verbose)
1987 0 0 if ($CheckLeak || $Benchmark and defined $block->tcp_listen)
1989 0 0 defined $block->tcp_query_len ? :
1990 0 0 defined $block->tcp_query ? :
1992 0 0 if ($n)
2001 0 0 if (not $CheckLeak || $Benchmark and defined $block->tcp_listen)
2006 0 0 unless (defined $reply or defined $block->tcp_shutdown)
2012 0 0 if (defined $block->tcp_query or defined $req_len)
2013 0 0 unless (defined $req_len)
2023 0 0 if ($target =~ /^\d+$/) { }
0 0 elsif ($target =~ /\S+\.sock$/) { }
2033 0 0 if (-e $target)
2034 0 0 unless unlink $target
2047 0 0 if ($tcp_socket)
2051 0 0 if ($!)
2053 0 0 if ($err =~ /address already in use/i)
2055 0 0 if ($i >= 20)
2057 0 0 if ($pids)
2061 0 0 if ($pid == $$)
2079 0 0 if (not $tcp_socket and $err)
2085 0 0 if (not defined $pid) { }
0 0 elsif ($pid == 0) { }
2098 0 0 if ($Verbose)
2108 0 0 if $client
2114 0 0 if (defined $block->tcp_shutdown)
2116 0 0 if ($block->tcp_shutdown_delay)
2120 0 0 if ($shutdown == 0 or $shutdown == 2) { }
2121 0 0 if ($Verbose)
2127 0 0 if ($Verbose)
2136 0 0 unless ($no_read)
2137 0 0 if ($Verbose)
2144 0 0 unless (defined $ret)
2148 0 0 if ($Verbose)
2157 0 0 if ($tcp_query_file)
2158 0 0 unless open my $out, ">$tcp_query_file"
2161 0 0 if ($Verbose)
2169 0 0 if (not $req_len or length $buf >= $req_len)
2170 0 0 if ($Verbose)
2179 0 0 if ($delay)
2180 0 0 if ($Verbose)
2186 0 0 unless ($no_write)
2187 0 0 if (defined $reply)
2188 0 0 if ($Verbose)
2193 0 0 if ($ref and $ref eq 'CODE')
2198 0 0 if (ref $reply) { }
2199 0 0 if ($ref ne 'ARRAY')
2204 0 0 if ($Verbose)
2208 0 0 unless (defined $bytes)
2215 0 0 unless (defined $bytes)
2222 0 0 if ($Verbose)
2226 0 0 if (defined $block->tcp_no_close)
2239 0 0 if ($Verbose)
2247 0 0 if ($CheckLeak || $Benchmark and defined $block->udp_listen)
2249 0 0 defined $block->udp_query ? :
2251 0 0 if ($n)
2260 0 0 if (not $CheckLeak || $Benchmark and defined $block->udp_listen)
2262 0 0 unless (defined $reply)
2266 0 0 if (defined $block->udp_query)
2271 0 0 if ($target =~ /^\d+$/) { }
0 0 elsif ($target =~ /\S+\.sock$/) { }
2274 0 0 unless $udp_socket = 'IO::Socket::INET'->new('LocalPort', $port, 'Proto', 'udp', 'Reuse', 1, 'Timeout', &timeout())
2282 0 0 if (-e $target)
2283 0 0 unless unlink $target
2286 0 0 unless $udp_socket = 'IO::Socket::UNIX'->new('Local', $target, 'Type', 2, 'Reuse', 1, 'Timeout', &timeout())
2303 0 0 if (not defined $pid) { }
0 0 elsif ($pid == 0) { }
2316 0 0 if ($Verbose)
2322 0 0 if ($Verbose)
2329 0 0 unless (defined $sender)
2333 0 0 if ($Verbose)
2337 0 0 if ($udp_query_file)
2338 0 0 unless open my $out, ">$udp_query_file"
2341 0 0 if ($Verbose)
2350 0 0 if ($delay)
2351 0 0 if ($Verbose)
2357 0 0 if (defined $reply)
2359 0 0 if ($ref and $ref eq 'CODE')
2364 0 0 if ($ref) { }
2365 0 0 if ($ref ne 'ARRAY')
2372 0 0 unless (defined $bytes)
2378 0 0 if ($reply =~ /syntax error at \(eval \d+\) line \d+, near/)
2383 0 0 unless (defined $bytes)
2389 0 0 if ($Verbose)
2397 0 0 if ($Verbose)
2405 0 0 if ($i > 1)
2409 0 0 if ($should_skip and defined $tests_to_skip) { }
0 0 elsif ($should_todo) { }
2433 0 0 if (defined $udp_socket)
2434 0 0 if (defined $UdpServerPid)
2443 0 0 if (defined $uds_socket_file)
2444 0 0 unless unlink $uds_socket_file
2448 0 0 if (defined $tcp_socket)
2449 0 0 if (defined $TcpServerPid)
2450 0 0 if ($Verbose)
2457 0 0 if ($Verbose)
2466 0 0 if ($StapOutFileHandle)
2471 0 0 if (my $total_errlog = $ENV{'TEST_NGINX_ERROR_LOG'})
2473 0 0 if (-s $errlog)
2474 0 0 unless open my $out, ">>$total_errlog"
2478 0 0 unless system("cat $errlog >> $total_errlog") == 0
2483 0 0 if ($Profiling || $UseValgrind || $UseStap and not $UseHup)
2485 0 0 if (-f $PidFile) { }
2490 0 0 if (&is_running($pid)) { }
2493 0 0 if ($Verbose)
2497 0 0 if (kill(3, $pid) == 0)
2503 0 0 if (-f $PidFile) { }
2504 0 0 if ($i++ < 20)
2505 0 0 if ($Verbose)
2512 0 0 if ($Verbose)
2519 0 0 if (not unlink($PidFile) and -f $PidFile)
2528 0 0 if (not unlink($PidFile) and -f $PidFile)
2539 0 5 if $InSubprocess
2543 5 0 if ($UseStap or $UseValgrind or not $ENV{'TEST_NGINX_NO_CLEAN'})
2545 0 5 if (defined $PidFile and -f $PidFile)
2547 0 0 unless ($pid)
2550 0 0 if (&is_running($pid)) { }
2561 0 5 if ($Randomize)
2562 0 0 if (defined $ServRoot and -d $ServRoot and $ServRoot =~ m[/t/servroot_\d+])
2573 0 0 if ($cmd =~ m([/\\]))
2574 0 0 if (-f $cmd and -x $cmd)
2582 0 0 if $dir eq ''
2585 0 0 if -f $abs and -x $abs
2595 0 0 if (defined $cached)
2599 0 0 if (defined $block->http2)
2600 0 0 if ($block->raw_request)
2604 0 0 if ($block->pipelined_requests)
2610 0 0 unless ($LoadedIPCRun)
2617 0 0 if ($UseHttp2)
2618 0 0 if ($block->raw_request)
2624 0 0 if ($block->pipelined_requests)
2630 0 0 unless (defined $block->request)
2635 0 0 if (not ref $block->request and $block->request =~ m[HTTP/1\.0]s)
2643 0 0 unless ($LoadedIPCRun)