Branch Coverage

lib/Test/Nginx/Util.pm
Criterion Covered Total %
branch 9 668 1.3


line true false branch
168 0 0 if (ref $expected and ref $expected eq 'Regexp')
172 0 0 if ($NoLongString)
180 0 0 if (@_) { }
191 0 0 if (@_) { }
208 0 0 if (@_) { }
284 0 0 unless (@_)
288 0 0 if (not $v =~ /^[A-Za-z_]/ or $v =~ /\n/)
304 0 0 if (@_) { }
312 0 0 if (@_) { }
320 0 0 if (@_)
321 0 0 if ($CheckLeak or $Benchmark)
331 0 0 if (@_) { }
343 0 0 if (@_) { }
352 0 0 if (@_) { }
364 0 0 if ($CheckLeak)
375 0 0 if ($CheckLeak)
379 0 0 if (@_) { }
380 0 0 shift() ? :
494 0 0 if (defined $tm)
495 0 0 if ($tm =~ s/([^_a-zA-Z])ms$/$1/) { }
0 0 elsif ($tm =~ s/([^_a-zA-Z])s$/$1/) { }
527 0 0 if ($wait)
529 0 0 if (defined $pid)
530 0 0 if ($Verbose)
537 0 0 if ($Verbose)
547 0 0 if ($@)
548 0 0 if ($Verbose)
560 0 0 unless (&is_running($pid))
564 0 0 if ($Verbose)
568 0 0 if (kill(15, $pid) == 0)
573 0 0 if $step > 0.5
586 0 0 if (&is_running($pid))
595 0 5 if ($Verbose)
603 0 5 if (defined $UdpServerPid)
608 0 5 if (defined $TcpServerPid)
613 0 5 if (defined $ChildPid)
623 0 0 unless open my $in, $ErrLogFile
626 0 0 if (not $CheckAccumErrLog and $ErrLogFilePos > 0)
632 0 0 unless ($CheckAccumErrLog)
643 0 0 if (defined $NginxVersion)
647 0 0 unless (defined $ENV{'TEST_NGINX_SERVER_PORT'})
651 0 0 $NoShuffle ? :
662 0 0 if (-d $ServRoot)
663 0 0 if ($UseHup) { }
665 0 0 if (-d $_) { }
666 0 0 if ($_ ne $ServRoot and $_ ne $LogDir)
668 0 0 unless rmdir $_
672 0 0 if ($_ =~ /\bnginx\.pid$/)
677 0 0 unless system("rm $_") == 0
687 0 0 if ($rc != 0)
688 0 0 if ($rc == -1) { }
696 0 0 unless system("rm -rf $HtmlDir > /dev/null") == 0
698 0 0 unless system("rm -rf $LogDir > /dev/null") == 0
700 0 0 unless system("rm -rf $ServRoot/*_temp > /dev/null") == 0
702 0 0 unless system("rmdir $ServRoot > /dev/null") == 0
706 0 0 unless (-d $ServRoot)
707 0 0 unless mkdir $ServRoot
710 0 0 unless (-d $LogDir)
711 0 0 unless mkdir $LogDir
714 0 0 unless mkdir $HtmlDir
719 0 0 unless open my $out, ">$index_file"
726 0 0 unless mkdir $ConfDir
736 0 0 if ($files)
737 0 0 if (not ref $files) { }
0 0 elsif (ref $files ne 'ARRAY') { }
745 0 0 if (/>>> (\S+)(?:\s+(.+))?/) { }
746 0 0 if ($fname)
758 0 0 if ($fname)
771 0 0 unless (defined $body)
776 0 0 if (not $fname =~ m[^/]) { }
783 0 0 if ($path =~ m[(.*)/])
785 0 0 unless (-d $dir)
786 0 0 unless make_path($dir)
790 0 0 unless open my $out, ">$path"
797 0 0 if ($date)
799 0 0 unless system($cmd) == 0
815 0 0 if ($UseHup) { }
0 0 elsif ($UseValgrind or $UseStap) { }
824 0 0 unless (defined $config)
828 0 0 unless (defined $http_config)
832 0 0 if ($FilterHttpConfig)
836 0 0 if ($http_config =~ /\bpostpone_output\b/)
842 0 0 if (defined $PostponeOutput)
843 0 0 unless ($PostponeOutput =~ /^\d+$/)
849 0 0 unless (defined $main_config)
853 0 0 if ($LoadModules)
855 0 0 if (@modules)
862 0 0 unless (defined $post_main_config)
868 0 0 if ($CheckLeak or $Benchmark)
873 0 0 unless ($err_log_file)
877 0 0 unless (defined $server_name)
884 0 0 unless open my $out, ">$ConfFile"
902 0 0 if ($v =~ /\s/)
940 0 0 unless ($NoRootLocation)
951 0 0 if ($UseHup)
979 0 0 if ($EventType)
1000 0 0 if (not defined $out or $? != 0)
1003 0 0 if ($out =~ m[(?:nginx|openresty)/(\d+)\.(\d+)\.(\d+)]s)
1007 0 0 if ($out =~ m[\w+/(\d+)\.(\d+)\.(\d+)]s)
1017 0 0 unless open my $in, $PidFile
1028 0 7 unless defined $s
1056 0 0 if ($Verbose)
1060 0 0 if ($ver eq $ConfigVersion) { }
1063 0 0 if ($nsucc == 5)
1067 0 0 if ($nsucc >= 10)
1076 0 0 if ($nsucc)
1077 0 0 if ($Verbose)
1086 0 0 if ($wait > 1)
1090 0 0 if ($wait > 0.5)
1111 0 0 if ($neg) { }
1125 0 0 unless (defined $config)
1130 0 0 unless (defined $ENV{$1})
1139 0 0 unless open my $in, $ErrLogFile
1144 0 0 if (/\[emerg\] \S+?: unknown directive "([^"]+)"/)
1162 0 0 if (defined $tcp_socket)
1164 0 0 if ($tcp_query_file)
1165 0 0 if (open my $in, $tcp_query_file)
1171 0 0 if (defined $block->tcp_query)
1175 0 0 if (defined $block->tcp_query_len)
1186 0 0 if (defined $udp_socket)
1188 0 0 if ($udp_query_file)
1189 0 0 if (not open(my $in, $udp_query_file)) { }
1198 0 0 if (defined $block->udp_query)
1207 0 0 if defined $block->SKIP
1212 0 0 if ($FirstTime)
1229 0 0 if ($block->log_level)
1239 0 0 if (defined $block->must_die)
1241 0 0 if (defined $block->stap)
1245 0 0 if ($UseStap)
1249 0 0 if ($UseValgrind)
1253 0 0 if ($UseHup)
1257 0 0 if ($Profiling)
1262 0 0 if (not defined $config) { }
0 0 elsif ($NoNginxManager) { }
1263 0 0 unless ($NoNginxManager)
1265 0 0 unless (defined $PrevConfig)
1287 0 0 if (not defined $PrevConfig or $config ne $PrevConfig) { }
1292 0 0 if ($should_reconfig or $ForceRestartOnTest) { }
1307 0 0 if ($CheckLeak || $Benchmark and defined $block->no_check_leak)
1311 0 0 if (defined $skip_eval)
1312 0 0 if ($skip_eval =~ / ^ \s* (\d+) \s* : \s* (.*) /sx)
1320 0 0 if ($@)
1327 0 0 if (defined $skip_nginx) { }
0 0 elsif (defined $skip_nginx2) { }
0 0 elsif (defined $skip_slave and defined $BuildSlaveName) { }
1328 0 0 if ($skip_nginx =~ / ^ \s* (\d+) \s* : \s* ([<>]=?) \s* (\d+)\.(\d+)\.(\d+) (?: \s* : \s* (.*) )? \s*$/x) { }
1336 0 0 unless ($skip_reason)
1341 0 0 if (not defined $NginxVersion and $op =~ /^
1352 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) { }
1367 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"))
1381 0 0 if ($skip_slave =~ / ^ \s* (\d+) \s* : \s* (\w+) \s* (?: (\w+) \s* )? (?: (\w+) \s* )? (?: \s* : \s* (.*) )? \s*$/x) { }
1389 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)
1404 0 0 unless (defined $skip_reason)
1410 0 0 if (defined $todo_nginx)
1411 0 0 if ($todo_nginx =~ / ^ \s* ([<>]=?) \s* (\d+)\.(\d+)\.(\d+) (?: \s* : \s* (.*) )? \s*$/x) { }
1419 0 0 if (not defined $NginxVersion and $op =~ /^
1432 0 0 if (defined $todo)
1433 0 0 if ($todo =~ / ^ \s* (\d+) \s* : \s* (.*) /sx) { }
1447 0 0 unless (defined $todo_reason)
1453 0 0 if (not $NoNginxManager || $should_skip and $should_restart)
1456 0 0 if ($UseHup)
1460 0 0 if ($should_reconfig)
1468 0 0 if (-f $PidFile) { }
1474 0 0 if (not defined $pid or $pid eq '')
1482 0 0 if (&is_running($pid)) { }
1485 0 0 if ($UseHup)
1486 0 0 if ($first_time)
1497 0 0 if ($Verbose)
1500 0 0 if (system("kill -USR1 $pid") == 0) { }
1503 0 0 if ($Verbose)
1507 0 0 if (system("kill -HUP $pid") == 0) { }
1510 0 0 if ($Verbose)
1516 0 0 if ($UseValgrind)
1525 0 0 if ($Verbose)
1540 0 0 if (-f $PidFile)
1541 0 0 unless unlink $PidFile
1554 0 0 unless ($nginx_is_running)
1555 0 0 if ($Verbose)
1566 0 0 unless (can_run($NginxBinary))
1574 0 0 unless (defined $NginxVersion)
1579 0 0 if ($NginxVersion >= 0.007053) { }
1585 0 0 if ($UseValgrind) { }
0 0 elsif ($UseStap) { }
1588 0 0 if ($UseValgrind =~ /^\d+$/) { }
1591 0 0 if (-f 'valgrind.suppress') { }
1609 0 0 if ($StapOutFileHandle)
1614 0 0 if ($block->stap)
1621 0 0 if ($stap =~ /\$LIB([_A-Z0-9]+)_PATH\b/)
1629 0 0 if ($line =~ m[\S+/$libname.*?\.so(?:\.\d+)*]) { }
1649 0 0 unless (defined $block->stap_out or defined $block->stap_out_like or defined $block->stap_out_unlike)
1656 0 0 if (not $StapOutFile) { }
1669 0 0 unless open $out, $outfile
1675 0 0 if (defined $ENV{'LD_PRELOAD'})
1679 0 0 if (defined $ENV{'LD_LIBRARY_PATH'})
1691 0 0 if ($Profiling or $UseValgrind or $UseStap) { }
1694 0 0 if (not defined $pid) { }
0 0 elsif ($pid == 0) { }
1706 0 0 if ($Verbose)
1729 0 0 if ($status == -1) { }
1735 0 0 if ($? > 32768) { }
1744 0 0 if (defined $must_die)
1746 0 0 if ($exec_failed) { }
0 0 elsif ($coredump) { }
0 0 elsif (&looks_like_number($must_die)) { }
1763 0 0 if ($status == 0)
1768 0 0 if (-f $PidFile)
1777 0 0 if ++$i < $RepeatEach
1781 0 0 if ($status != 0)
1782 0 0 if ($ENV{'TEST_NGINX_IGNORE_MISSING_DIRECTIVES'} and my $directive = &check_if_missing_directives()) { }
1799 0 0 if ($Verbose)
1803 0 0 if ($block->init)
1805 0 0 if ($@)
1815 0 0 if ($Verbose)
1819 0 0 if ($CheckLeak || $Benchmark and defined $block->tcp_listen)
1821 0 0 defined $block->tcp_query_len ? :
1822 0 0 defined $block->tcp_query ? :
1824 0 0 if ($n)
1833 0 0 if (not $CheckLeak || $Benchmark and defined $block->tcp_listen)
1838 0 0 unless (defined $reply or defined $block->tcp_shutdown)
1844 0 0 if (defined $block->tcp_query or defined $req_len)
1845 0 0 unless (defined $req_len)
1855 0 0 if ($target =~ /^\d+$/) { }
0 0 elsif ($target =~ /\S+\.sock$/) { }
1865 0 0 if (-e $target)
1866 0 0 unless unlink $target
1879 0 0 if ($tcp_socket)
1883 0 0 if ($!)
1885 0 0 if ($err =~ /address already in use/i)
1887 0 0 if ($i >= 20)
1889 0 0 if ($pids)
1893 0 0 if ($pid == $$)
1911 0 0 if (not $tcp_socket and $err)
1917 0 0 if (not defined $pid) { }
0 0 elsif ($pid == 0) { }
1930 0 0 if ($Verbose)
1940 0 0 if $client
1946 0 0 if (defined $block->tcp_shutdown)
1948 0 0 if ($block->tcp_shutdown_delay)
1952 0 0 if ($shutdown == 0 or $shutdown == 2) { }
1953 0 0 if ($Verbose)
1959 0 0 if ($Verbose)
1968 0 0 unless ($no_read)
1969 0 0 if ($Verbose)
1976 0 0 unless (defined $ret)
1980 0 0 if ($Verbose)
1989 0 0 if ($tcp_query_file)
1990 0 0 unless open my $out, ">$tcp_query_file"
1993 0 0 if ($Verbose)
2001 0 0 if (not $req_len or length $buf >= $req_len)
2002 0 0 if ($Verbose)
2011 0 0 if ($delay)
2012 0 0 if ($Verbose)
2018 0 0 unless ($no_write)
2019 0 0 if (defined $reply)
2020 0 0 if ($Verbose)
2025 0 0 if ($ref and $ref eq 'CODE')
2030 0 0 if (ref $reply) { }
2031 0 0 if ($ref ne 'ARRAY')
2036 0 0 if ($Verbose)
2040 0 0 unless (defined $bytes)
2047 0 0 unless (defined $bytes)
2054 0 0 if ($Verbose)
2058 0 0 if (defined $block->tcp_no_close)
2071 0 0 if ($Verbose)
2079 0 0 if ($CheckLeak || $Benchmark and defined $block->udp_listen)
2081 0 0 defined $block->udp_query ? :
2083 0 0 if ($n)
2092 0 0 if (not $CheckLeak || $Benchmark and defined $block->udp_listen)
2094 0 0 unless (defined $reply)
2098 0 0 if (defined $block->udp_query)
2103 0 0 if ($target =~ /^\d+$/) { }
0 0 elsif ($target =~ /\S+\.sock$/) { }
2106 0 0 unless $udp_socket = 'IO::Socket::INET'->new('LocalPort', $port, 'Proto', 'udp', 'Reuse', 1, 'Timeout', &timeout())
2114 0 0 if (-e $target)
2115 0 0 unless unlink $target
2118 0 0 unless $udp_socket = 'IO::Socket::UNIX'->new('Local', $target, 'Type', 2, 'Reuse', 1, 'Timeout', &timeout())
2135 0 0 if (not defined $pid) { }
0 0 elsif ($pid == 0) { }
2148 0 0 if ($Verbose)
2154 0 0 if ($Verbose)
2161 0 0 unless (defined $sender)
2165 0 0 if ($Verbose)
2169 0 0 if ($udp_query_file)
2170 0 0 unless open my $out, ">$udp_query_file"
2173 0 0 if ($Verbose)
2182 0 0 if ($delay)
2183 0 0 if ($Verbose)
2189 0 0 if (defined $reply)
2191 0 0 if ($ref and $ref eq 'CODE')
2196 0 0 if ($ref) { }
2197 0 0 if ($ref ne 'ARRAY')
2204 0 0 unless (defined $bytes)
2210 0 0 if ($reply =~ /syntax error at \(eval \d+\) line \d+, near/)
2215 0 0 unless (defined $bytes)
2221 0 0 if ($Verbose)
2229 0 0 if ($Verbose)
2237 0 0 if ($i > 1)
2241 0 0 if ($should_skip and defined $tests_to_skip) { }
0 0 elsif ($should_todo) { }
2265 0 0 if (defined $udp_socket)
2266 0 0 if (defined $UdpServerPid)
2275 0 0 if (defined $uds_socket_file)
2276 0 0 unless unlink $uds_socket_file
2280 0 0 if (defined $tcp_socket)
2281 0 0 if (defined $TcpServerPid)
2282 0 0 if ($Verbose)
2289 0 0 if ($Verbose)
2298 0 0 if ($StapOutFileHandle)
2303 0 0 if (my $total_errlog = $ENV{'TEST_NGINX_ERROR_LOG'})
2305 0 0 if (-s $errlog)
2306 0 0 unless open my $out, ">>$total_errlog"
2310 0 0 unless system("cat $errlog >> $total_errlog") == 0
2315 0 0 if ($Profiling || $UseValgrind || $UseStap and not $UseHup)
2317 0 0 if (-f $PidFile) { }
2322 0 0 if (&is_running($pid)) { }
2325 0 0 if ($Verbose)
2329 0 0 if (kill(3, $pid) == 0)
2335 0 0 if (-f $PidFile) { }
2336 0 0 if ($i++ < 5)
2337 0 0 if ($Verbose)
2344 0 0 if ($Verbose)
2351 0 0 if (not unlink($PidFile) and -f $PidFile)
2360 0 0 if (not unlink($PidFile) and -f $PidFile)
2371 0 5 if $InSubprocess
2375 5 0 if ($UseStap or $UseValgrind or not $ENV{'TEST_NGINX_NO_CLEAN'})
2377 0 5 if (defined $PidFile and -f $PidFile)
2379 0 0 unless ($pid)
2382 0 0 if (&is_running($pid)) { }
2391 0 5 if ($Randomize)
2392 0 0 if (defined $ServRoot and -d $ServRoot and $ServRoot =~ m[/t/servroot_\d+])
2403 0 0 if ($cmd =~ m([/\\]))
2404 0 0 if (-f $cmd and -x $cmd)
2412 0 0 if $dir eq ''
2415 0 0 if -f $abs and -x $abs