Branch Coverage

blib/lib/Test/Nginx/Socket.pm
Criterion Covered Total %
branch 112 658 17.0


line true false branch
96 0 22 unless ($first)
104 22 0 if ($first =~ /^(\s*)(\S+)( *)((\S+)( *))?((\S+)( *))?(\s*)$/) { }
105 22 0 defined $1 ? :
107 22 0 defined $3 ? :
109 21 1 defined $5 ? :
110 21 1 defined $6 ? :
112 18 4 if (not defined $8) { }
115 4 0 defined $8 ? :
117 18 4 if (not defined $9) { }
120 4 0 defined $9 ? :
122 22 0 defined $10 ? :
126 1 21 unless (defined $rel_url)
131 18 4 unless (defined $http_ver)
141 16 6 if (not defined $content) { }
202 20 145 if (not defined $current_move) { }
61 84 elsif (defined $current_move->{'d'}) { }
208 0 61 if ($current_move->{'d'} > length($current_packet) - $in_packet_cursor) { }
211 0 0 if ($in_packet_cursor > 0)
224 5 79 if ($current_move->{'s_s'} > length($current_packet) - $in_packet_cursor) { }
262 3 11 if (not $is_chunked and defined $parsed_req->{'content'} and $parsed_req->{'content'} ne '' and not $more_headers =~ /(?:^|\n)Content-Length:/)
277 14 0 unless ($more_headers =~ /(?:^|\n)Host:/ism)
281 14 0 unless ($more_headers =~ /(?:^|\n)Connection/ism)
304 0 0 if $header =~ /^\s*\#/
307 0 0 unless (defined $val)
310 0 0 if (lc $key eq 'transfer-encoding' and $val eq 'chunked')
332 2 7 if (defined $block->raw_request) { }
335 1 1 if (ref $block->raw_request and ref $block->raw_request eq 'ARRAY') { }
352 0 7 if (defined $block->request_eval) { }
356 0 0 if ($@)
362 6 1 if (defined $request)
372 1 6 if ($block->pipelined_requests) { }
374 0 1 if (not ref $reqs or ref $reqs ne 'ARRAY')
382 1 1 if ($i == @$reqs - 1) { }
390 0 2 if (ref $more_headers eq 'ARRAY') { }
393 0 0 unless (defined $hdr)
415 2 4 if (not ref $request) { }
4 0 elsif (ref $request eq 'ARRAY') { }
416 0 2 if (ref $more_headers eq 'ARRAY') { }
419 0 0 unless (defined $hdr)
440 0 10 if (ref $more_headers eq 'ARRAY') { }
443 0 0 unless (defined $hdr)
454 7 3 if (not ref $one_req) { }
3 0 elsif (ref $one_req eq 'ARRAY') { }
465 3 3 if (not ref $one_packet) { }
3 0 elsif (ref $one_packet eq 'HASH') { }
482 3 3 if (not ref $one_req->[$idx]) { }
513 0 0 if ($arg =~ m[^[- "&%;,|?*.+=\w:/()]*$])
514 0 0 if ($arg =~ /[ "&%;,|?*()]/)
534 4 16 if (ref $filter and ref $filter eq 'CODE') { }
16 0 elsif (not ref $filter) { }
540 3 13 if ($_ eq 'md5_hex') { }
4 9 elsif ($_ eq 'sha1_hex') { }
6 3 elsif ($_ eq 'uc') { }
3 0 elsif ($_ eq 'lc') { }
0 0 elsif ($_ eq 'ucfirst') { }
0 0 elsif ($_ eq 'lcfirst') { }
0 0 elsif ($_ eq 'length') { }
577 0 0 if ($#$r_req_list < 0)
581 0 0 if (defined $block->curl)
587 0 0 if ($Test::Nginx::Socket::CheckLeak)
591 0 0 if ($Test::Nginx::Socket::Benchmark)
595 0 0 if ($Test::Nginx::Socket::Benchmark and not defined $block->no_check_leak)
600 0 0 if ($Test::Nginx::Socket::Benchmark =~ /^\s*(\d+)(?:\s+(\d+))?\s*$/)
604 0 0 if ($Test::Nginx::Socket::BenchmarkWarmup)
617 0 0 if ($Test::Nginx::Socket::CheckLeak and not defined $block->no_check_leak)
625 0 0 if (not defined $pid) { }
0 0 elsif ($pid == 0) { }
639 0 0 if ($PrevNginxPid and $ngx_pid)
644 0 0 if (++$i > 1000)
654 0 0 if ($? != 0 and not &is_running($ngx_pid))
655 0 0 if (&is_running($pid))
671 0 0 if (@lines == 0)
675 0 0 if (@lines > 1)
688 0 0 if (@rss_list == 0) { }
700 0 0 if (&is_running($pid))
710 0 0 unless (defined $timeout)
721 0 0 if ($dry_run) { }
731 0 0 if ($block->pipelined_requests) { }
741 0 0 if ($Test::Nginx::Util::Verbose)
745 0 0 unless (defined $raw_resp)
751 0 0 unless (defined $block->ignore_response)
753 0 0 if ($Test::Nginx::Util::Verbose)
757 0 0 if (defined $block->http09) { }
766 0 0 if (not $n) { }
767 0 0 if ($left)
779 0 0 unless (defined $block->ignore_response)
787 0 0 if ($n or $req_idx < @$r_req_list - 1)
788 0 0 if ($block->wait)
794 0 0 unless (defined $block->ignore_response)
801 0 0 if ($n)
806 0 0 if ($block->wait)
810 0 0 if ($Test::Nginx::Util::Verbose)
818 0 0 if (not defined $block->ignore_response)
826 0 0 unless $block->{'stap'}
832 0 0 if ($dry_run)
836 0 0 unless ($Test::Nginx::Socket::UseStap)
843 0 0 if ($fname and $fname eq '/dev/stdout' || $fname eq '/dev/stderr')
853 0 0 if $dry_run
856 0 0 unless ($fh)
862 0 0 if (sleep_time() < 0.2) { }
873 0 0 if ($out)
878 0 0 if ($Test::Nginx::Util::Verbose)
882 0 0 if (defined $stap_out)
883 0 0 if ($Test::Nginx::Socket::NoLongString) { }
890 0 0 if (defined $stap_out_like)
895 0 0 if (defined $stap_out_unlike)
907 6 10 if ($need_array) { }
908 6 0 if (ref $value and ref $value eq 'ARRAY')
916 1 9 if (ref $value and ref $value eq 'ARRAY')
917 0 1 if ($req_idx != 0)
933 0 0 if $dry_run
935 0 0 if (defined $block->error_code_like) { }
0 0 elsif (defined $block->error_code) { }
956 0 0 if (defined $block->raw_response_headers_like)
958 0 0 if $dry_run
967 0 0 if (defined $block->raw_response_headers_unlike)
969 0 0 if $dry_run
982 0 0 if (defined $block->response_headers) { }
0 0 elsif (defined $block->response_headers_like) { }
988 0 0 unless (defined $val)
992 0 0 if $dry_run
1002 0 0 $res ? :
1003 0 0 unless (defined $actual_val)
1008 0 0 if $dry_run
1020 0 0 unless (defined $expected_val)
1024 0 0 if $dry_run
1034 0 0 if (not ref $val or ref $val eq 'Regexp')
1038 0 0 if (ref $val eq 'ARRAY')
1040 0 0 if (&value_contains($v, $pat))
1054 0 0 if (defined $block->access_log)
1057 0 0 if (not ref $pats) { }
0 0 elsif (ref $pats eq 'Regexp') { }
1073 0 0 unless defined $pat
1074 0 0 if (ref $pat and $line =~ /$pat/ or $line =~ /\Q$pat\E/)
1076 0 0 if $dry_run
1085 0 0 if (defined $pat)
1087 0 0 if $dry_run
1108 0 0 if (defined $grep_pats)
1109 0 0 if (ref $grep_pats and ref $grep_pats eq 'ARRAY') { }
1117 0 0 if (defined $grep_pat)
1119 0 0 unless (defined $expected)
1125 0 0 if (ref $expected and ref $expected eq 'ARRAY')
1131 0 0 if $dry_run
1137 0 0 if (ref $grep_pat and $line =~ /$grep_pat/ or $line =~ /\Q$grep_pat\E/)
1139 0 0 unless ($matched =~ /\n/)
1145 0 0 if (ref $expected eq 'Regexp') { }
1149 0 0 if ($Test::Nginx::Socket::NoLongString) { }
1160 0 0 if (defined $block->error_log)
1163 0 0 if (&value_contains($pats, 'writing a global lua variable'))
1169 0 0 if (&value_contains($pats, '[alert'))
1173 0 0 if (&value_contains($pats, '[crit'))
1177 0 0 if (&value_contains($pats, '[emerg'))
1181 0 0 if (not ref $pats) { }
0 0 elsif (ref $pats eq 'Regexp') { }
1198 0 0 unless defined $pat
1199 0 0 if (ref $pat and $line =~ /$pat/ or $line =~ /\Q$pat\E/)
1201 0 0 if $dry_run
1210 0 0 if (defined $pat)
1212 0 0 if $dry_run
1220 0 0 if (defined $block->no_error_log)
1224 0 0 if (&value_contains($pats, 'writing a global lua variable'))
1230 0 0 if (&value_contains($pats, '[alert'))
1234 0 0 if (&value_contains($pats, '[crit'))
1238 0 0 if (&value_contains($pats, '[emerg'))
1242 0 0 if (not ref $pats) { }
0 0 elsif (ref $pats eq 'Regexp') { }
1260 0 0 unless defined $pat
1262 0 0 if (ref $pat and $line =~ /$pat/ or $line =~ /\Q$pat\E/)
1263 0 0 if ($found{$pat}) { }
1272 0 0 if $dry_run
1291 0 0 if $found{$pat}
1292 0 0 if (defined $pat)
1294 0 0 if $dry_run
1302 0 0 if ($check_write_guard_message and not $dry_run)
1306 0 0 if ($line =~ /writing a global lua variable/)
1313 0 0 if ($check_alert_message and not $dry_run)
1317 0 0 if ($line =~ /\[alert\]/)
1324 0 0 if ($check_crit_message and not $dry_run)
1328 0 0 if ($line =~ /\[crit\]/)
1335 0 0 if ($check_emerg_message and not $dry_run)
1339 0 0 if ($line =~ /\[emerg\]/)
1348 0 0 if ($line =~ /\bAssertion .*?failed\b/)
1365 0 0 if (not ref $pats) { }
0 0 elsif (ref $pats eq 'Regexp') { }
1378 0 0 if (defined $block->no_shutdown_error_log)
1382 0 0 if (not ref $pats) { }
0 0 elsif (ref $pats eq 'Regexp') { }
1400 0 0 unless defined $pat
1402 0 0 if (ref $pat and $line =~ /$pat/ or $line =~ /\Q$pat\E/)
1403 0 0 if ($found{$pat}) { }
1412 0 0 if $dry_run
1422 0 0 if $found{$pat}
1423 0 0 if (defined $pat)
1425 0 0 if $dry_run
1437 0 0 unless defined $pat
1439 0 0 if (ref $pat and $line =~ /$pat/ or $line =~ /\Q$pat\E/)
1441 0 0 if $dry_run
1450 0 0 if (defined $pat)
1452 0 0 if $dry_run
1461 0 0 if ($line =~ /\bAssertion .*? failed\.$/)
1483 0 15 unless defined $res
1486 0 15 unless defined $content
1492 15 0 if (defined $response_body_filters)
1494 4 11 if (not ref $response_body_filters) { }
1 10 elsif (ref $response_body_filters ne 'ARRAY') { }
1502 15 0 if (ref $response_body_filters eq 'ARRAY')
1504 8 7 if (ref $response_body_filters->[0] eq 'ARRAY')
1508 0 22 if (ref $elem ne 'ARRAY')
1519 8 7 if ($is_2d_array)
1522 0 8 unless defined $filter
1526 15 0 if (ref $filter and ref $filter eq 'ARRAY') { }
1544 9 7 if (defined $block->response_body or defined $block->response_body_eval) { }
7 0 elsif (defined $block->response_body_like or defined $block->response_body_unlike) { }
1547 9 0 $res ? :
1548 9 0 if (defined $content)
1554 0 9 if ($block->response_body_eval) { }
1560 0 0 if ($@)
1571 0 9 if ($block->charset)
1575 9 0 unless (not defined $expected or ref $expected)
1584 0 9 if $dry_run
1585 0 9 if (ref $expected) { }
1589 0 9 if ($Test::Nginx::Socket::NoLongString) { }
1606 7 0 if (defined $block->response_body_like) { }
1617 7 0 $res ? :
1618 7 0 if (defined $content)
1629 0 7 unless (defined $summary)
1634 0 7 if $dry_run
1652 16 0 if ($raw_resp =~ /(.*?\r\n)\r\n/s)
1667 0 16 if ($code and not $code =~ /^\d+$/)
1672 0 16 if ($code and $code == 304 || $code == 101)
1676 0 16 if (defined $enc and $enc eq 'chunked') { }
16 0 elsif (defined $len and $len ne '' and $len >= 0) { }
1680 0 0 unless (defined $raw)
1686 0 0 if ($raw =~ /\G 0 [\ \t]* \r\n \r\n /cgsx)
1687 0 0 if ($raw =~ /\G (.+) /cgsx)
1694 0 0 if ($raw =~ / \G [\ \t]* ( [A-Fa-f0-9]+ ) [\ \t]* \r\n /cgsx) { }
0 0 elsif ($raw =~ /\G.+/cgs) { }
1700 0 0 $rest < $bit_sz ? :
1703 0 0 if ($raw =~ /\G(.{$bit})/cgs) { }
1721 0 0 unless ($raw =~ /\G\r\n/cgs)
1752 0 16 if (length $raw < $len) { }
0 16 elsif (length $raw > $len) { }
1753 0 0 unless ($head_req)
1776 0 0 if ($Test::Nginx::Util::Verbose)
1783 0 0 unless (defined $ok)
1788 0 0 unless ($out)
1789 0 0 if ($err)
1798 0 0 if ($err)
1814 0 0 unless (defined $server_addr)
1828 0 0 unless (defined $sock)
1830 0 0 $TotalConnectingTimeouts ? :
1831 0 0 if ($tries <= $total_tries)
1833 0 0 if ($wait >= 1)
1837 0 0 if (defined $Test::Nginx::Util::ChildPid)
1839 0 0 if (waitpid($Test::Nginx::Util::ChildPid, 1) == -1)
1851 0 0 if ($wait >= 0.6)
1853 0 0 if ($tries + 1 <= $total_tries)
1866 0 0 if (++$TotalConnectingTimeouts < 3) { }
1880 0 0 ref $req ? :
1886 0 0 if ($req =~ /^\s*HEAD\s+/)
1892 0 0 if (&use_http2($block))
1919 0 0 if ($readable_hdls->count == 0 and $writable_hdls->count == 0 and $err_hdls->count == 0)
1932 0 0 unless (defined $new_err or defined $new_readable or defined $new_writable)
1943 0 0 unless defined $hdl
1947 0 0 if ($err_hdls->exists($hdl))
1951 0 0 if ($readable_hdls->exists($hdl))
1955 0 0 if ($writable_hdls->exists($hdl))
1960 0 0 unless defined $h
1961 0 0 if ($h eq $hdl)
1968 0 0 unless defined $h
1969 0 0 if ($h eq $hdl)
1979 0 0 unless defined $hdl
1982 0 0 unless ($res)
1985 0 0 if ($err_hdls->exists($hdl))
1989 0 0 if ($readable_hdls->exists($hdl))
1993 0 0 if ($writable_hdls->exists($hdl))
1998 0 0 unless defined $h
1999 0 0 if ($h eq $hdl)
2010 0 0 unless defined $hdl
2013 0 0 if (not $res) { }
0 0 elsif ($res == 2) { }
2016 0 0 if ($err_hdls->exists($hdl))
2020 0 0 if ($readable_hdls->exists($hdl))
2024 0 0 if ($writable_hdls->exists($hdl))
2034 0 0 if (defined $shutdown)
2035 0 0 if ($shutdown =~ /^$/s)
2043 0 0 if ($writable_hdls->exists($hdl))
2058 0 0 if (not defined $ctx->{'block'}->abort) { }
2077 0 0 unless defined $ctx->{'write_buf'}
2084 0 0 if ($rest > 0) { }
2093 0 0 if ($@)
2100 0 0 unless (defined $bytes)
2101 0 0 if ($! == 11)
2109 0 0 unless ($ctx->{'resp'})
2123 0 0 unless (defined $next_send)
2132 0 0 if (not defined $next_send->{'delay_before'}) { }
2133 0 0 if (defined $ctx->{'middle_delay'})
2141 0 0 if ($wait_time)
2158 0 0 unless (defined $bytes)
2159 0 0 if ($! == 11)
2169 0 0 if ($bytes == 0)
2193 0 0 if ($req =~ m[^\s*(\w+)\s+(\S+)\s+HTTP/(\S+)\r?\n]gims) { }
0 0 elsif ($req =~ /^\s*(\w+)\s+(.*\S)\r?\n/gims) { }
2206 0 0 if ($Test::Nginx::Util::Verbose) { }
2213 0 0 if (&use_http2($block))
2217 0 0 if ($meth eq 'HEAD') { }
2224 0 0 if ($http_ver ne '1.1')
2230 0 0 if ($http_ver ge '1.0')
2231 0 0 if ($req =~ /\G(.*?)\r?\n\r?\n/cgs) { }
2251 0 0 if ($h =~ /^\s*User-Agent\s*:\s*(.*\S)/i) { }
2255 0 0 if ($h =~ /^\s*Content-Type\s*:/i)
2263 0 0 if ($req =~ /\G(.+)/cgms)
2265 0 0 unless ($found_content_type)
2272 0 0 unless ($timeout)
2296 0 0 if ($nreqs < $concur)
2308 0 0 if ($req =~ m[^\s*(\w+)\s+(\S+)\s+HTTP/(\S+)\r?\n]gims) { }
0 0 elsif ($req =~ /^\s*(\w+)\s+(.*\S)\r?\n/gims) { }
2324 0 0 if ($http_ver eq '1.1' and $meth eq 'GET') { }
2334 0 0 if ($http_ver ge '1.0')
2335 0 0 if ($req =~ /\G(.*?)\r?\n\r?\n/cgs) { }
2353 0 0 if ($prog eq 'ab' and $h =~ /^\s*Content-Type\s*:\s*(.*\S)/i) { }
2364 0 0 if ($req =~ /\G.+/cgs or $meth eq 'POST' or $meth eq 'PUT')
2367 0 0 unless (defined $body)
2376 0 0 if ($meth eq 'PUT') { }
0 0 elsif ($meth eq 'POST') { }
0 0 elsif ($meth eq 'GET') { }
2392 0 0 if ($meth eq 'HEAD')
2405 0 0 if ($Test::Nginx::Util::Verbose)
2423 0 0 if ($denom == 0)