Branch Coverage

blib/lib/Test/Nginx/Socket.pm
Criterion Covered Total %
branch 112 574 19.5


line true false branch
91 0 22 unless ($first)
99 22 0 if ($first =~ /^(\s*)(\S+)( *)((\S+)( *))?((\S+)( *))?(\s*)$/) { }
100 22 0 defined $1 ? :
102 22 0 defined $3 ? :
104 21 1 defined $5 ? :
105 21 1 defined $6 ? :
107 18 4 if (not defined $8) { }
110 4 0 defined $8 ? :
112 18 4 if (not defined $9) { }
115 4 0 defined $9 ? :
117 22 0 defined $10 ? :
121 1 21 unless (defined $rel_url)
126 18 4 unless (defined $http_ver)
136 16 6 if (not defined $content) { }
197 20 145 if (not defined $current_move) { }
61 84 elsif (defined $current_move->{'d'}) { }
203 0 61 if ($current_move->{'d'} > length($current_packet) - $in_packet_cursor) { }
206 0 0 if ($in_packet_cursor > 0)
219 5 79 if ($current_move->{'s_s'} > length($current_packet) - $in_packet_cursor) { }
257 3 11 if (not $is_chunked and defined $parsed_req->{'content'} and $parsed_req->{'content'} ne '' and not $more_headers =~ /(?:^|\n)Content-Length:/)
272 14 0 unless ($more_headers =~ /(?:^|\n)Host:/ism)
276 14 0 unless ($more_headers =~ /(?:^|\n)Connection/ism)
299 0 0 if $header =~ /^\s*\#/
302 0 0 unless (defined $val)
305 0 0 if (lc $key eq 'transfer-encoding' and $val eq 'chunked')
327 2 7 if (defined $block->raw_request) { }
330 1 1 if (ref $block->raw_request and ref $block->raw_request eq 'ARRAY') { }
347 0 7 if (defined $block->request_eval) { }
351 0 0 if ($@)
357 6 1 if (defined $request)
367 1 6 if ($block->pipelined_requests) { }
369 0 1 if (not ref $reqs or ref $reqs ne 'ARRAY')
377 1 1 if ($i == @$reqs - 1) { }
385 0 2 if (ref $more_headers eq 'ARRAY') { }
388 0 0 unless (defined $hdr)
410 2 4 if (not ref $request) { }
4 0 elsif (ref $request eq 'ARRAY') { }
411 0 2 if (ref $more_headers eq 'ARRAY') { }
414 0 0 unless (defined $hdr)
435 0 10 if (ref $more_headers eq 'ARRAY') { }
438 0 0 unless (defined $hdr)
449 7 3 if (not ref $one_req) { }
3 0 elsif (ref $one_req eq 'ARRAY') { }
460 3 3 if (not ref $one_packet) { }
3 0 elsif (ref $one_packet eq 'HASH') { }
477 3 3 if (not ref $one_req->[$idx]) { }
508 0 0 if ($arg =~ m[^[- "&%;,|?*.+=\w:/()]*$])
509 0 0 if ($arg =~ /[ "&%;,|?*()]/)
529 4 16 if (ref $filter and ref $filter eq 'CODE') { }
16 0 elsif (not ref $filter) { }
535 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') { }
572 0 0 if ($#$r_req_list < 0)
576 0 0 if (defined $block->curl)
582 0 0 if ($Test::Nginx::Socket::CheckLeak)
586 0 0 if ($Test::Nginx::Socket::Benchmark)
590 0 0 if ($Test::Nginx::Socket::Benchmark and not defined $block->no_check_leak)
595 0 0 if ($Test::Nginx::Socket::Benchmark =~ /^\s*(\d+)(?:\s+(\d+))?\s*$/)
599 0 0 if ($Test::Nginx::Socket::BenchmarkWarmup)
612 0 0 if ($Test::Nginx::Socket::CheckLeak and not defined $block->no_check_leak)
620 0 0 if (not defined $pid) { }
0 0 elsif ($pid == 0) { }
634 0 0 if ($PrevNginxPid and $ngx_pid)
639 0 0 if (++$i > 1000)
649 0 0 if ($? != 0 and not &is_running($ngx_pid))
650 0 0 if (&is_running($pid))
666 0 0 if (@lines == 0)
670 0 0 if (@lines > 1)
683 0 0 if (@rss_list == 0) { }
695 0 0 if (&is_running($pid))
705 0 0 unless (defined $timeout)
716 0 0 if ($dry_run) { }
726 0 0 if ($block->pipelined_requests) { }
736 0 0 if ($Test::Nginx::Util::Verbose)
740 0 0 unless (defined $raw_resp)
746 0 0 unless (defined $block->ignore_response)
748 0 0 if ($Test::Nginx::Util::Verbose)
752 0 0 if (defined $block->http09) { }
761 0 0 if (not $n) { }
762 0 0 if ($left)
774 0 0 unless (defined $block->ignore_response)
782 0 0 if ($n or $req_idx < @$r_req_list - 1)
783 0 0 if ($block->wait)
792 0 0 if ($n)
797 0 0 if ($block->wait)
801 0 0 if ($Test::Nginx::Util::Verbose)
813 0 0 unless $block->{'stap'}
819 0 0 if ($dry_run)
823 0 0 unless ($Test::Nginx::Socket::UseStap)
830 0 0 if ($fname and $fname eq '/dev/stdout' || $fname eq '/dev/stderr')
840 0 0 if $dry_run
843 0 0 unless ($fh)
849 0 0 if (sleep_time() < 0.2) { }
860 0 0 if ($out)
865 0 0 if ($Test::Nginx::Util::Verbose)
869 0 0 if (defined $stap_out)
870 0 0 if ($Test::Nginx::Socket::NoLongString) { }
877 0 0 if (defined $stap_out_like)
882 0 0 if (defined $stap_out_unlike)
894 6 10 if ($need_array) { }
895 6 0 if (ref $value and ref $value eq 'ARRAY')
903 1 9 if (ref $value and ref $value eq 'ARRAY')
904 0 1 if ($req_idx != 0)
920 0 0 if $dry_run
922 0 0 if (defined $block->error_code_like) { }
0 0 elsif (defined $block->error_code) { }
943 0 0 if (defined $block->raw_response_headers_like)
945 0 0 if $dry_run
954 0 0 if (defined $block->raw_response_headers_unlike)
956 0 0 if $dry_run
969 0 0 if (defined $block->response_headers) { }
0 0 elsif (defined $block->response_headers_like) { }
975 0 0 unless (defined $val)
979 0 0 if $dry_run
989 0 0 $res ? :
990 0 0 unless (defined $actual_val)
995 0 0 if $dry_run
1007 0 0 unless (defined $expected_val)
1011 0 0 if $dry_run
1021 0 0 if (not ref $val or ref $val eq 'Regexp')
1025 0 0 if (ref $val eq 'ARRAY')
1027 0 0 if (&value_contains($v, $pat))
1047 0 0 if (defined $grep_pats)
1048 0 0 if (ref $grep_pats and ref $grep_pats eq 'ARRAY') { }
1056 0 0 if (defined $grep_pat)
1058 0 0 unless (defined $expected)
1064 0 0 if (ref $expected and ref $expected eq 'ARRAY')
1070 0 0 if $dry_run
1076 0 0 if (ref $grep_pat and $line =~ /$grep_pat/ or $line =~ /\Q$grep_pat\E/)
1078 0 0 unless ($matched =~ /\n/)
1084 0 0 if (ref $expected eq 'Regexp') { }
1088 0 0 if ($Test::Nginx::Socket::NoLongString) { }
1099 0 0 if (defined $block->error_log)
1102 0 0 if (&value_contains($pats, '[alert'))
1106 0 0 if (&value_contains($pats, '[crit'))
1110 0 0 if (&value_contains($pats, '[emerg'))
1114 0 0 if (not ref $pats) { }
0 0 elsif (ref $pats eq 'Regexp') { }
1131 0 0 unless defined $pat
1132 0 0 if (ref $pat and $line =~ /$pat/ or $line =~ /\Q$pat\E/)
1134 0 0 if $dry_run
1143 0 0 if (defined $pat)
1145 0 0 if $dry_run
1153 0 0 if (defined $block->no_error_log)
1157 0 0 if (&value_contains($pats, '[alert'))
1161 0 0 if (&value_contains($pats, '[crit'))
1165 0 0 if (&value_contains($pats, '[emerg'))
1169 0 0 if (not ref $pats) { }
0 0 elsif (ref $pats eq 'Regexp') { }
1186 0 0 unless defined $pat
1188 0 0 if (ref $pat and $line =~ /$pat/ or $line =~ /\Q$pat\E/)
1189 0 0 if ($found{$pat}) { }
1198 0 0 if $dry_run
1208 0 0 if $found{$pat}
1209 0 0 if (defined $pat)
1211 0 0 if $dry_run
1219 0 0 if ($check_alert_message and not $dry_run)
1223 0 0 if ($line =~ /\[alert\]/)
1230 0 0 if ($check_crit_message and not $dry_run)
1234 0 0 if ($line =~ /\[crit\]/)
1241 0 0 if ($check_emerg_message and not $dry_run)
1245 0 0 if ($line =~ /\[emerg\]/)
1254 0 0 if ($line =~ /\bAssertion .*? failed\.$/)
1276 0 15 unless defined $res
1279 0 15 unless defined $content
1285 15 0 if (defined $response_body_filters)
1287 4 11 if (not ref $response_body_filters) { }
1 10 elsif (ref $response_body_filters ne 'ARRAY') { }
1295 15 0 if (ref $response_body_filters eq 'ARRAY')
1297 8 7 if (ref $response_body_filters->[0] eq 'ARRAY')
1301 0 22 if (ref $elem ne 'ARRAY')
1312 8 7 if ($is_2d_array)
1315 0 8 unless defined $filter
1319 15 0 if (ref $filter and ref $filter eq 'ARRAY') { }
1337 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) { }
1340 9 0 $res ? :
1341 9 0 if (defined $content)
1347 0 9 if ($block->response_body_eval) { }
1353 0 0 if ($@)
1364 0 9 if ($block->charset)
1368 9 0 unless (not defined $expected or ref $expected)
1377 0 9 if $dry_run
1378 0 9 if (ref $expected) { }
1382 0 9 if ($Test::Nginx::Socket::NoLongString) { }
1399 7 0 if (defined $block->response_body_like) { }
1410 7 0 $res ? :
1411 7 0 if (defined $content)
1422 0 7 unless (defined $summary)
1427 0 7 if $dry_run
1445 16 0 if ($raw_resp =~ /(.*?\r\n)\r\n/s)
1460 0 16 if ($code and not $code =~ /^\d+$/)
1465 0 16 if ($code and $code == 304 || $code == 101)
1469 0 16 if (defined $enc and $enc eq 'chunked') { }
16 0 elsif (defined $len and $len ne '' and $len >= 0) { }
1473 0 0 unless (defined $raw)
1479 0 0 if ($raw =~ /\G 0 [\ \t]* \r\n \r\n /cgsx)
1480 0 0 if ($raw =~ /\G (.+) /cgsx)
1487 0 0 if ($raw =~ / \G [\ \t]* ( [A-Fa-f0-9]+ ) [\ \t]* \r\n /cgsx) { }
0 0 elsif ($raw =~ /\G.+/cgs) { }
1493 0 0 $rest < $bit_sz ? :
1496 0 0 if ($raw =~ /\G(.{$bit})/cgs) { }
1514 0 0 unless ($raw =~ /\G\r\n/cgs)
1545 0 16 if (length $raw < $len) { }
0 16 elsif (length $raw > $len) { }
1546 0 0 unless ($head_req)
1571 0 0 unless (defined $server_addr)
1585 0 0 unless (defined $sock)
1587 0 0 $TotalConnectingTimeouts ? :
1588 0 0 if ($tries <= $total_tries)
1590 0 0 if ($wait >= 1)
1594 0 0 if (defined $Test::Nginx::Util::ChildPid)
1596 0 0 if (waitpid($Test::Nginx::Util::ChildPid, 1) == -1)
1608 0 0 if ($wait >= 0.6)
1610 0 0 if ($tries + 1 <= $total_tries)
1623 0 0 if (++$TotalConnectingTimeouts < 3) { }
1637 0 0 ref $req ? :
1643 0 0 if ($req =~ /^\s*HEAD\s+/)
1672 0 0 if ($readable_hdls->count == 0 and $writable_hdls->count == 0 and $err_hdls->count == 0)
1685 0 0 unless (defined $new_err or defined $new_readable or defined $new_writable)
1696 0 0 unless defined $hdl
1700 0 0 if ($err_hdls->exists($hdl))
1704 0 0 if ($readable_hdls->exists($hdl))
1708 0 0 if ($writable_hdls->exists($hdl))
1713 0 0 unless defined $h
1714 0 0 if ($h eq $hdl)
1721 0 0 unless defined $h
1722 0 0 if ($h eq $hdl)
1732 0 0 unless defined $hdl
1735 0 0 unless ($res)
1738 0 0 if ($err_hdls->exists($hdl))
1742 0 0 if ($readable_hdls->exists($hdl))
1746 0 0 if ($writable_hdls->exists($hdl))
1751 0 0 unless defined $h
1752 0 0 if ($h eq $hdl)
1763 0 0 unless defined $hdl
1766 0 0 if (not $res) { }
0 0 elsif ($res == 2) { }
1769 0 0 if ($err_hdls->exists($hdl))
1773 0 0 if ($readable_hdls->exists($hdl))
1777 0 0 if ($writable_hdls->exists($hdl))
1787 0 0 if (defined $shutdown)
1788 0 0 if ($shutdown =~ /^$/s)
1796 0 0 if ($writable_hdls->exists($hdl))
1811 0 0 if (not defined $ctx->{'block'}->abort) { }
1830 0 0 unless defined $ctx->{'write_buf'}
1837 0 0 if ($rest > 0) { }
1846 0 0 if ($@)
1853 0 0 unless (defined $bytes)
1854 0 0 if ($! == 11)
1862 0 0 unless ($ctx->{'resp'})
1876 0 0 unless (defined $next_send)
1885 0 0 if (not defined $next_send->{'delay_before'}) { }
1886 0 0 if (defined $ctx->{'middle_delay'})
1894 0 0 if ($wait_time)
1911 0 0 unless (defined $bytes)
1912 0 0 if ($! == 11)
1922 0 0 if ($bytes == 0)
1946 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) { }
1959 0 0 if ($meth eq 'HEAD') { }
0 0 elsif ($meth ne 'GET') { }
1966 0 0 if ($http_ver ne '1.1')
1972 0 0 if ($http_ver ge '1.0')
1973 0 0 if ($req =~ /\G(.*?)\r?\n\r?\n/cgs) { }
1991 0 0 if ($h =~ /^\s*User-Agent\s*:\s*(.*\S)/i) { }
1999 0 0 if ($req =~ /\G.+/cgs)
2021 0 0 if ($nreqs < $concur)
2033 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) { }
2049 0 0 if ($http_ver eq '1.1' and $meth eq 'GET') { }
2059 0 0 if ($http_ver ge '1.0')
2060 0 0 if ($req =~ /\G(.*?)\r?\n\r?\n/cgs) { }
2078 0 0 if ($prog eq 'ab' and $h =~ /^\s*Content-Type\s*:\s*(.*\S)/i) { }
2089 0 0 if ($req =~ /\G.+/cgs or $meth eq 'POST' or $meth eq 'PUT')
2092 0 0 unless (defined $body)
2101 0 0 if ($meth eq 'PUT') { }
0 0 elsif ($meth eq 'POST') { }
0 0 elsif ($meth eq 'GET') { }
2117 0 0 if ($meth eq 'HEAD')
2130 0 0 if ($Test::Nginx::Util::Verbose)
2148 0 0 if ($denom == 0)