X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=tools%2Fprivoxy-regression-test.pl;h=6e1ad5223bdda124342d851af517ccb60a701596;hb=117316ec8bfeeed624c1ca2fbb21e4fc886c0ea7;hp=3ea75a6c097869446f00eff2d92fc4c18c85a441;hpb=6fa3bd1bc9e8df19e27e4e4d6d83d0522ef47b30;p=privoxy.git diff --git a/tools/privoxy-regression-test.pl b/tools/privoxy-regression-test.pl index 3ea75a6c..6e1ad522 100755 --- a/tools/privoxy-regression-test.pl +++ b/tools/privoxy-regression-test.pl @@ -7,7 +7,7 @@ # A regression test "framework" for Privoxy. For documentation see: # perldoc privoxy-regression-test.pl # -# $Id: privoxy-regression-test.pl,v 1.2 2008/01/21 18:43:16 fabiankeil Exp $ +# $Id: privoxy-regression-test.pl,v 1.110 2008/02/16 12:55:18 fk Exp fk $ # # Wish list: # @@ -156,8 +156,9 @@ sub check_for_forbidden_characters ($) { sub load_regressions_tests () { our $privoxy_cgi_url; + our @privoxy_config; my @actionfiles; - my $curl_url = ''; + my $curl_url = ''; my $file_number = 0; $curl_url .= $privoxy_cgi_url; @@ -167,10 +168,16 @@ sub load_regressions_tests () { foreach (@{get_cgi_page_or_else($curl_url)}) { + chomp; if (/(.*?)<\/td>/) { my $url = $privoxy_cgi_url . 'show-status?file=actions&index=' . $2; $actionfiles[$file_number++] = $url; + + } elsif (m@config\.html#.*\">([^<]*)\s+(.*)
@) { + + my $directive = $1 . " " . $2; + push (@privoxy_config, $directive); } } @@ -330,6 +337,12 @@ sub load_action_files ($) { $count++; enlist_new_test(\@regression_tests, $token, $value, $si, $ri, $count); } + + if ($token =~ /level\s+(\d+)/i) { + + my $level = $1; + register_dependency($level, $value); + } if ($si == -1 || $ri == -1) { # No beginning of a test detected yet, @@ -480,6 +493,7 @@ sub level_is_unacceptable ($) { return ((cli_option_is_set('level') and get_cli_option('level') != $level) or ($level < get_cli_option('min-level')) or ($level > get_cli_option('max-level')) + or dependency_unsatisfied($level) ); } @@ -489,6 +503,38 @@ sub test_number_is_unacceptable ($) { and get_cli_option('test-number') != $test_number) } +sub dependency_unsatisfied ($) { + + my $level = shift; + our %dependencies; + our @privoxy_config; + my $dependency_problem = 0; + + if (defined ($dependencies{$level}{'config line'})) { + + my $dependency = $dependencies{$level}{'config line'}; + $dependency_problem = 1; + + foreach (@privoxy_config) { + + $dependency_problem = 0 if (/$dependency/); + } + } + + return $dependency_problem; +} + +sub register_dependency ($$) { + + my $level = shift; + my $dependency = shift; + our %dependencies; + + if ($dependency =~ /config line\s+(.*)/) { + + $dependencies{$level}{'config line'} = $1; + } +} # XXX: somewhat misleading name sub execute_regression_test ($) { @@ -520,7 +566,6 @@ sub execute_regression_test ($) { } - return $result; } @@ -536,14 +581,9 @@ sub execute_method_test ($) { my $curl_parameters = ''; my $expected_status_code = $test{'expected-status-code'}; - if ($method =~ /HEAD/i) { - - $curl_parameters .= '--head '; - - } else { - - $curl_parameters .= '-X ' . $method . ' '; - } + $curl_parameters .= '--request ' . $method . ' '; + # Don't complain in case about the 'missing' body + $curl_parameters .= '--head ' if ($method =~ /^HEAD$/i); $curl_parameters .= PRIVOXY_CGI_URL; @@ -555,7 +595,6 @@ sub execute_method_test ($) { return $result; } - sub execute_dumb_fetch_test ($) { my $test_ref = shift; @@ -568,7 +607,7 @@ sub execute_dumb_fetch_test ($) { my $expected_status_code = $test{'expected-status-code'}; if (defined $test{method}) { - $curl_parameters .= '-X ' . $test{method} . ' '; + $curl_parameters .= '--request ' . $test{method} . ' '; } if ($test{type} == TRUSTED_CGI_REQUEST) { $curl_parameters .= '--referer ' . PRIVOXY_CGI_URL . ' '; @@ -716,7 +755,6 @@ sub check_header_result ($$) { return $success; } - sub get_header_name ($) { my $header = shift; @@ -807,7 +845,7 @@ sub get_server_header ($$) { foreach (@buffer) { - # XXX: shoul probably verify that the request + # XXX: should probably verify that the request # was actually answered by Fellatio. if (/^$header_to_get/) { $header = $_; @@ -819,53 +857,6 @@ sub get_server_header ($$) { return $header; } -sub get_header_to_check ($) { - - # No longer in use but not removed yet. - - my $buffer_ref = shift; - my $header; - my @buffer = @{$buffer_ref}; - my $line; - my $processed_request_reached = 0; - my $read_header = 0; - my $processed_request = ''; - - l(LL_ERROR, "You are not supposed to use get_header_to_()!"); - - foreach (@buffer) { - - # Skip everything before the Processed request - if (/Processed Request/) { - $processed_request_reached = 1; - next; - } - next unless $processed_request_reached; - - # End loop after the Processed request - last if (/<\/pre>/); - - # Ditch tags and leading/trailing white space. - s@^\s*<.*?>@@g; - s@\s*$@@g; - - $processed_request .= $_; - - if (/^X-Privoxy-Regression-Test/) { - $read_header = 1; - next; - } - - if ($read_header) { - $header = $_; - $read_header = 0; - } - - } - - return $header; -} - sub get_status_code ($) { my $buffer_ref = shift; @@ -1005,6 +996,8 @@ sub get_page_with_curl ($) { $curl_line .= ' --proxy ' . get_cli_option('privoxy-address'); } + # We want to see the HTTP status code + $curl_line .= " --include "; # Let Privoxy emit two log messages less. $curl_line .= ' -H \'Proxy-Connection:\' ' unless $parameters =~ /Proxy-Connection:/; $curl_line .= ' -H \'Connection: close\' ' unless $parameters =~ /Connection:/; @@ -1012,8 +1005,6 @@ sub get_page_with_curl ($) { $curl_line .= " -s "; # We do care about the failure reason if any. $curl_line .= " -S "; - # We want to see the HTTP status code - $curl_line .= " --include "; # We want to advertise ourselves $curl_line .= " --user-agent '" . PRT_VERSION . "' "; # We aren't too patient