Branch Coverage

blib/lib/Test/Nginx/Socket.pm
Criterion Covered Total %
branch 114 728 15.6


line true false branch
98 0 22 unless ($first)
106 22 0 if ($first =~ /^(\s*)(\S+)( *)((\S+)( *))?((\S+)( *))?(\s*)$/) { }
107 22 0 defined $1 ? :
109 22 0 defined $3 ? :
111 21 1 defined $5 ? :
112 21 1 defined $6 ? :
114 18 4 if (not defined $8) { }
117 4 0 defined $8 ? :
119 18 4 if (not defined $9) { }
122 4 0 defined $9 ? :
124 22 0 defined $10 ? :
128 1 21 unless (defined $rel_url)
133 18 4 unless (defined $http_ver)
143 16 6 if (not defined $content) { }
204 20 145 if (not defined $current_move) { }
61 84 elsif (defined $current_move->{'d'}) { }
210 0 61 if ($current_move->{'d'} > length($current_packet) - $in_packet_cursor) { }
213 0 0 if ($in_packet_cursor > 0)
226 5 79 if ($current_move->{'s_s'} > length($current_packet) - $in_packet_cursor) { }
264 3 11 if (not $is_chunked and defined $parsed_req->{'content'} and $parsed_req->{'content'} ne "" and not $more_headers =~ /(?:^|\n)Content-Length:/)
279 14 0 unless ($more_headers =~ /(?:^|\n)Host:/ism)
283 14 0 unless ($more_headers =~ /(?:^|\n)Connection/ism)
306 0 0 if $header =~ /^\s*\#/
309 0 0 unless (defined $val)
312 0 0 if (lc $key eq "transfer-encoding" and $val eq "chunked")
334 2 7 if (defined $block->raw_request) { }
337 1 1 if (ref $block->raw_request and ref $block->raw_request eq 'ARRAY') { }
354 0 7 if (defined $block->request_eval) { }
358 0 0 if ($@)
364 6 1 if (defined $request)
374 1 6 if ($block->pipelined_requests) { }
376 0 1 if (not ref $reqs or ref $reqs ne "ARRAY")
386 1 1 if ($i == @$reqs - 1) { }
394 0 2 if (ref $more_headers eq 'ARRAY') { }
397 0 0 unless (defined $hdr)
419 2 4 if (not ref $request) { }
4 0 elsif (ref $request eq 'ARRAY') { }
420 0 2 if (ref $more_headers eq 'ARRAY') { }
423 0 0 unless (defined $hdr)
444 0 10 if (ref $more_headers eq 'ARRAY') { }
447 0 0 unless (defined $hdr)
458 7 3 if (not ref $one_req) { }
3 0 elsif (ref $one_req eq 'ARRAY') { }
469 3 3 if (not ref $one_packet) { }
3 0 elsif (ref $one_packet eq 'HASH') { }
486 3 3 if (not ref $one_req->[$idx]) { }
517 0 0 if ($arg =~ m[^[- "&%;,|?*.+=\w:/()]*$])
518 0 0 if ($arg =~ /[ "&%;,|?*()]/)
538 4 16 if (ref $filter and ref $filter eq 'CODE') { }
16 0 elsif (not ref $filter) { }
544 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') { }
581 0 0 if ($r_req_list->$#* < 0)
585 0 0 if (defined $block->curl)
591 0 0 if ($Test::Nginx::Socket::CheckLeak)
595 0 0 if ($Test::Nginx::Socket::Benchmark)
599 0 0 if ($Test::Nginx::Socket::Benchmark and not defined $block->no_check_leak)
604 0 0 if ($Test::Nginx::Socket::Benchmark =~ /^\s*(\d+)(?:\s+(\d+))?\s*$/)
608 0 0 if ($Test::Nginx::Socket::BenchmarkWarmup)
621 0 0 if ($Test::Nginx::Socket::CheckLeak and not defined $block->no_check_leak)
629 0 0 if (not defined $pid) { }
0 0 elsif ($pid == 0) { }
643 0 0 if ($PrevNginxPid and $ngx_pid)
648 0 0 if (++$i > 1000)
658 0 0 if ($? != 0 and not &is_running($ngx_pid))
659 0 0 if (&is_running($pid))
675 0 0 if (@lines == 0)
679 0 0 if (@lines > 1)
692 0 0 if (@rss_list == 0) { }
704 0 0 if (&is_running($pid))
714 0 0 unless (defined $timeout)
725 0 0 if ($dry_run) { }
735 0 0 if ($block->pipelined_requests) { }
745 0 0 if ($Test::Nginx::Util::Verbose)
749 0 0 unless (defined $raw_resp)
755 0 0 unless (defined $block->ignore_response)
757 0 0 if ($Test::Nginx::Util::Verbose)
761 0 0 if (defined $block->http09) { }
770 0 0 if (not $n) { }
771 0 0 if ($left)
783 0 0 unless (defined $block->ignore_response)
791 0 0 if ($n or $req_idx < @$r_req_list - 1)
792 0 0 if ($block->wait)
798 0 0 unless (defined $block->ignore_response)
805 0 0 if ($n)
810 0 0 if ($block->wait)
814 0 0 if ($Test::Nginx::Util::Verbose)
822 0 0 if (not defined $block->ignore_response)
830 0 0 unless $block->{'stap'}
836 0 0 if ($dry_run)
840 0 0 unless ($Test::Nginx::Socket::UseStap)
847 0 0 if ($fname and $fname eq '/dev/stdout' || $fname eq '/dev/stderr')
857 0 0 if $dry_run
860 0 0 unless ($fh)
866 0 0 if (sleep_time() < 0.2) { }
877 0 0 if ($out)
882 0 0 if ($Test::Nginx::Util::Verbose)
886 0 0 if (defined $stap_out)
887 0 0 if ($Test::Nginx::Socket::NoLongString) { }
894 0 0 if (defined $stap_out_like)
899 0 0 if (defined $stap_out_unlike)
911 6 10 if ($need_array) { }
912 6 0 if (ref $value and ref $value eq "ARRAY")
920 1 9 if (ref $value and ref $value eq "ARRAY")
921 0 1 if ($req_idx != 0)
937 0 0 if $dry_run
939 0 0 if (defined $block->error_code_like) { }
0 0 elsif (defined $block->error_code) { }
960 0 0 if (defined $block->raw_response_headers_like)
962 0 0 if $dry_run
971 0 0 if (defined $block->raw_response_headers_unlike)
973 0 0 if $dry_run
986 0 0 if (defined $block->response_headers) { }
0 0 elsif (defined $block->response_headers_like) { }
992 0 0 unless (defined $val)
996 0 0 if $dry_run
1006 0 0 $res ? :
1007 0 0 unless (defined $actual_val)
1012 0 0 if $dry_run
1024 0 0 unless (defined $expected_val)
1028 0 0 if $dry_run
1038 0 0 if (not ref $val or ref $val eq "Regexp")
1042 0 0 if (ref $val eq "ARRAY")
1044 0 0 if (&value_contains($v, $pat))
1058 0 0 if (defined $block->access_log)
1061 0 0 if (not ref $pats) { }
0 0 elsif (ref $pats eq 'Regexp') { }
1077 0 0 unless defined $pat
1078 0 0 if (ref $pat and $line =~ /$pat/ or $line =~ /\Q$pat\E/)
1080 0 0 if $dry_run
1089 0 0 if (defined $pat)
1091 0 0 if $dry_run
1099 0 0 if (defined $block->no_access_log)
1103 0 0 if (not ref $pats) { }
0 0 elsif (ref $pats eq 'Regexp') { }
1121 0 0 unless defined $pat
1123 0 0 if (ref $pat and $line =~ /$pat/ or $line =~ /\Q$pat\E/)
1124 0 0 if ($found{$pat}) { }
1133 0 0 if $dry_run
1152 0 0 if $found{$pat}
1153 0 0 if (defined $pat)
1155 0 0 if $dry_run
1176 0 0 if (defined $grep_pats) { }
1177 0 0 if (ref $grep_pats and ref $grep_pats eq 'ARRAY') { }
1186 0 0 if (defined $grep_error_log_out)
1191 0 0 if (defined $grep_pat)
1193 0 0 unless (defined $expected)
1201 0 0 if (ref $expected and ref $expected eq "ARRAY")
1207 0 0 if $dry_run
1213 0 0 if (ref $grep_pat and $line =~ /$grep_pat/ or $line =~ /\Q$grep_pat\E/)
1215 0 0 unless ($matched =~ /\n/)
1221 0 0 if (ref $expected eq 'Regexp') { }
1225 0 0 if ($Test::Nginx::Socket::NoLongString) { }
1236 0 0 if (defined $block->error_log)
1239 0 0 if (&value_contains($pats, "writing a global lua variable"))
1245 0 0 if (&value_contains($pats, "[alert"))
1249 0 0 if (&value_contains($pats, "[crit"))
1253 0 0 if (&value_contains($pats, "[emerg"))
1257 0 0 if (not ref $pats) { }
0 0 elsif (ref $pats eq 'Regexp') { }
1274 0 0 unless defined $pat
1275 0 0 if (ref $pat and $line =~ /$pat/ or $line =~ /\Q$pat\E/)
1277 0 0 if $dry_run
1286 0 0 if (defined $pat)
1288 0 0 if $dry_run
1296 0 0 if (defined $block->no_error_log)
1300 0 0 if (&value_contains($pats, "writing a global lua variable"))
1306 0 0 if (&value_contains($pats, "[alert"))
1310 0 0 if (&value_contains($pats, "[crit"))
1314 0 0 if (&value_contains($pats, "[emerg"))
1318 0 0 if (not ref $pats) { }
0 0 elsif (ref $pats eq 'Regexp') { }
1336 0 0 unless defined $pat
1338 0 0 if (ref $pat and $line =~ /$pat/ or $line =~ /\Q$pat\E/)
1339 0 0 if ($found{$pat}) { }
1348 0 0 if $dry_run
1367 0 0 if $found{$pat}
1368 0 0 if (defined $pat)
1370 0 0 if $dry_run
1378 0 0 if ($check_write_guard_message and not $dry_run)
1382 0 0 if ($line =~ /writing a global lua variable/)
1389 0 0 if ($check_alert_message and not $dry_run)
1393 0 0 if ($line =~ /\[alert\]/)
1400 0 0 if ($check_crit_message and not $dry_run)
1404 0 0 if ($line =~ /\[crit\]/)
1411 0 0 if ($check_emerg_message and not $dry_run)
1415 0 0 if ($line =~ /\[emerg\]/)
1424 0 0 if ($line =~ /\bAssertion .*?failed\b/)
1440 0 0 if (defined $pats)
1441 0 0 if (not ref $pats) { }
0 0 elsif (ref $pats eq 'Regexp') { }
1458 0 0 unless defined $pat
1460 0 0 if (ref $pat and $line =~ /$pat/ or $line =~ /\Q$pat\E/)
1462 0 0 if $dry_run
1471 0 0 if (defined $pat)
1473 0 0 if $dry_run
1482 0 0 if ($line =~ /\bAssertion .*? failed\.$/)
1492 0 0 if (defined $block->no_shutdown_error_log)
1496 0 0 if (not ref $pats) { }
0 0 elsif (ref $pats eq 'Regexp') { }
1514 0 0 unless defined $pat
1516 0 0 if (ref $pat and $line =~ /$pat/ or $line =~ /\Q$pat\E/)
1517 0 0 if ($found{$pat}) { }
1526 0 0 if $dry_run
1536 0 0 if $found{$pat}
1537 0 0 if (defined $pat)
1539 0 0 if $dry_run
1560 0 15 unless defined $res
1563 0 15 unless defined $content
1569 15 0 if (defined $response_body_filters)
1571 4 11 if (not ref $response_body_filters) { }
1 10 elsif (ref $response_body_filters ne 'ARRAY') { }
1579 15 0 if (ref $response_body_filters eq "ARRAY")
1581 8 7 if (ref $response_body_filters->[0] eq "ARRAY")
1585 0 22 if (ref $elem ne "ARRAY")
1596 8 7 if ($is_2d_array)
1599 0 8 unless defined $filter
1603 15 0 if (ref $filter and ref $filter eq 'ARRAY') { }
1622 0 16 if (defined $write_resp_body_file and defined $res)
1624 0 0 unless open my $out, ">$write_resp_body_file"
1629 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) { }
1632 9 0 $res ? :
1633 9 0 if (defined $content)
1638 0 9 if (defined $block->response_body_json_sort)
1643 0 0 if ($rc)
1649 0 9 if ($block->response_body_eval) { }
1655 0 0 if ($@)
1666 0 9 if ($block->charset)
1670 9 0 unless (not defined $expected or ref $expected)
1680 0 9 if $dry_run
1681 0 9 if (ref $expected) { }
1685 0 9 if ($Test::Nginx::Socket::NoLongString) { }
1702 7 0 if (defined $block->response_body_like) { }
1713 7 0 $res ? :
1714 7 0 if (defined $content)
1725 0 7 unless (defined $summary)
1730 0 7 if $dry_run
1748 16 0 if ($raw_resp =~ /(.*?\r\n)\r\n/s)
1765 0 16 if ($code and not $code =~ /^\d+$/)
1770 0 16 if ($code and $code == 304 || $code == 101)
1774 0 16 if (defined $enc and $enc eq 'chunked') { }
16 0 elsif (defined $len and $len ne '' and $len >= 0) { }
1778 0 0 unless (defined $raw)
1784 0 0 if (@trailers == 0 and $raw =~ /\G 0 [\ \t]* \r\n \r\n /cgsx) { }
0 0 elsif (@trailers > 0 and $raw =~ /\G 0 [\ \t]* \r\n /cgsx) { }
1785 0 0 if ($raw =~ /\G (.+) /cgsx)
1794 0 0 unless ($raw =~ /\G($trailer:\ [^\n]*\r\n)/cgs)
1805 0 0 unless ($raw =~ /\G\r\n/cgs)
1815 0 0 if ($raw =~ /\G (.+) /cgsx)
1822 0 0 if ($raw =~ / \G [\ \t]* ( [A-Fa-f0-9]+ ) [\ \t]* \r\n /cgsx) { }
0 0 elsif ($raw =~ /\G.+/cgs) { }
1828 0 0 $rest < $bit_sz ? :
1831 0 0 if ($raw =~ /\G(.{$bit})/cgs) { }
1849 0 0 unless ($raw =~ /\G\r\n/cgs)
1880 0 16 if (length $raw < $len) { }
0 16 elsif (length $raw > $len) { }
1881 0 0 unless ($head_req)
1904 0 0 if ($Test::Nginx::Util::Verbose)
1908 0 0 if (&use_http2($block))
1909 0 0 $TotalConnectingTimeouts ? :
1911 0 0 if (&is_tcp_port_used($Test::Nginx::Socket::ServerPortForClient))
1921 0 0 if (&use_http3($block))
1922 0 0 $TotalConnectingTimeouts ? :
1924 0 0 if (&is_udp_port_used($Test::Nginx::Socket::ServerPortForClient))
1940 0 0 unless (defined $ok)
1945 0 0 unless ($out)
1946 0 0 if ($err)
1948 0 0 if (defined $curl_err)
1949 0 0 if (ref $curl_err and $err =~ /$curl_err/) { }
0 0 elsif ($err =~ /\Q$curl_err\E/) { }
1968 0 0 if ($err)
1980 0 0 ref $req ? :
1986 0 0 if ($req =~ /^\s*HEAD\s+/)
1992 0 0 if (&use_http2($block) or &use_http3($block))
1998 0 0 unless (defined $server_addr)
2013 0 0 unless (defined $sock)
2015 0 0 $TotalConnectingTimeouts ? :
2016 0 0 if ($tries <= $total_tries)
2018 0 0 if ($wait >= 1)
2022 0 0 if (defined $Test::Nginx::Util::ChildPid)
2024 0 0 if (waitpid($Test::Nginx::Util::ChildPid, 1) == -1)
2036 0 0 if ($wait >= "0.6")
2038 0 0 if ($tries + 1 <= $total_tries)
2051 0 0 if (++$TotalConnectingTimeouts < 3) { }
2088 0 0 if ($readable_hdls->count == 0 and $writable_hdls->count == 0 and $err_hdls->count == 0)
2101 0 0 unless (defined $new_err or defined $new_readable or defined $new_writable)
2112 0 0 unless defined $hdl
2116 0 0 if ($err_hdls->exists($hdl))
2120 0 0 if ($readable_hdls->exists($hdl))
2124 0 0 if ($writable_hdls->exists($hdl))
2129 0 0 unless defined $h
2130 0 0 if ($h eq $hdl)
2137 0 0 unless defined $h
2138 0 0 if ($h eq $hdl)
2148 0 0 unless defined $hdl
2151 0 0 unless ($res)
2154 0 0 if ($err_hdls->exists($hdl))
2158 0 0 if ($readable_hdls->exists($hdl))
2162 0 0 if ($writable_hdls->exists($hdl))
2167 0 0 unless defined $h
2168 0 0 if ($h eq $hdl)
2179 0 0 unless defined $hdl
2182 0 0 if (not $res) { }
0 0 elsif ($res == 2) { }
2185 0 0 if ($err_hdls->exists($hdl))
2189 0 0 if ($readable_hdls->exists($hdl))
2193 0 0 if ($writable_hdls->exists($hdl))
2203 0 0 if (defined $shutdown)
2204 0 0 if ($shutdown =~ /^$/s)
2212 0 0 if ($writable_hdls->exists($hdl))
2227 0 0 if (not defined $ctx->{'block'}->abort) { }
2246 0 0 unless defined $ctx->{'write_buf'}
2253 0 0 if ($rest > 0) { }
2262 0 0 if ($@)
2269 0 0 unless (defined $bytes)
2270 0 0 if ($! == 11)
2278 0 0 unless ($ctx->{'resp'})
2292 0 0 unless (defined $next_send)
2301 0 0 if (not defined $next_send->{'delay_before'}) { }
2302 0 0 if (defined $ctx->{'middle_delay'})
2310 0 0 if ($wait_time)
2327 0 0 unless (defined $bytes)
2328 0 0 if ($! == 11)
2338 0 0 if ($bytes == 0)
2362 0 0 if ($req =~ m[^\s*(\w+)\s+(\S+)\s+HTTP/(\S+)\r?\n]gims) { }
0 0 elsif ($req =~ /^\s*(\w+)\s+(.*\S)\s*\r?\n/gims) { }
2381 0 0 unless (defined $curl_protocol)
2385 0 0 if ($Test::Nginx::Util::Verbose) { }
2392 0 0 if (&use_http3($block)) { }
0 0 elsif (&use_http2($block)) { }
2401 0 0 if ($meth eq 'HEAD') { }
2405 0 0 if ($meth ne "GET")
2410 0 0 if ($http_ver ne "1.1")
2416 0 0 if ($http_ver ge "1.0")
2417 0 0 if ($req =~ /\G(.*?)\r?\n\r?\n/cgs) { }
2435 0 0 if ($h =~ /^\s*Content-Type\s*:/i)
2442 0 0 if ($req =~ /\G(.+)/cgms)
2444 0 0 unless ($found_content_type)
2450 0 0 unless open my $fh, ">", $filename
2456 0 0 unless ($timeout)
2470 0 0 unless (defined $server_addr)
2481 0 0 if (defined $curl_options)
2496 0 0 if ($nreqs < $concur)
2508 0 0 if ($req =~ m[^\s*(\w+)\s+(\S+)\s+HTTP/(\S+)\r?\n]gims) { }
0 0 elsif ($req =~ /^\s*(\w+)\s+(.*\S)\s*\r?\n/gims) { }
2526 0 0 if ($http_ver eq '1.1' and $meth eq 'GET') { }
2536 0 0 if ($http_ver ge "1.0")
2537 0 0 if ($req =~ /\G(.*?)\r?\n\r?\n/cgs) { }
2555 0 0 if ($prog eq 'ab' and $h =~ /^\s*Content-Type\s*:\s*(.*\S)/i) { }
2566 0 0 if ($req =~ /\G.+/cgs or $meth eq "POST" or $meth eq "PUT")
2569 0 0 unless (defined $body)
2578 0 0 if ($meth eq 'PUT') { }
0 0 elsif ($meth eq 'POST') { }
0 0 elsif ($meth eq 'GET') { }
2594 0 0 if ($meth eq "HEAD")
2602 0 0 unless (defined $server_addr)
2614 0 0 if ($Test::Nginx::Util::Verbose)
2632 0 0 if ($denom == 0)