X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=tools%2Fprivoxy-regression-test.pl;h=6e1ad5223bdda124342d851af517ccb60a701596;hb=117316ec8bfeeed624c1ca2fbb21e4fc886c0ea7;hp=4fc909648a56d97f4036de8410f9672b537e60b4;hpb=e56d26413b7b73cae45e39d934d655d67865ee4e;p=privoxy.git diff --git a/tools/privoxy-regression-test.pl b/tools/privoxy-regression-test.pl index 4fc90964..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.104 2008/01/21 18:23:49 fk Exp $ +# $Id: privoxy-regression-test.pl,v 1.110 2008/02/16 12:55:18 fk Exp fk $ # # Wish list: # @@ -45,9 +45,9 @@ use strict; use Getopt::Long; use constant { - PRT_VERSION => 'Privoxy-Regression-Test 0.2', + PRT_VERSION => 'Privoxy-Regression-Test 0.2', - CURL => 'curl', + CURL => 'curl', # CLI option defaults CLI_RETRIES => 1, @@ -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, @@ -383,7 +396,9 @@ sub load_action_files ($) { l(LL_FILE_LOADING, "Method: " . $value); $regression_tests[$si][$ri]{'method'} = $value; + } else { + # We don't use it, so we don't need $no_checks = 1; } @@ -467,7 +482,6 @@ sub execute_regression_tests () { } - if (get_cli_option('loops') > 1) { log_message("Total: Executed " . $all_tests . " regression tests. " . $all_successes . " successes, " . $all_failures . " failures."); @@ -479,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) ); } @@ -488,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 ($) { @@ -519,7 +566,6 @@ sub execute_regression_test ($) { } - return $result; } @@ -535,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; @@ -554,7 +595,6 @@ sub execute_method_test ($) { return $result; } - sub execute_dumb_fetch_test ($) { my $test_ref = shift; @@ -567,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 . ' '; @@ -715,7 +755,6 @@ sub check_header_result ($$) { return $success; } - sub get_header_name ($) { my $header = shift; @@ -796,7 +835,7 @@ sub get_server_header ($$) { if ($expect_header eq 'REMOVAL' or $expect_header eq 'NO CHANGE' - or $expect_header eq 'SOME CHANGE') { + or $expect_header eq 'SOME CHANGE') { $expect_header = $test{'data'}; @@ -806,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 = $_; @@ -818,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; @@ -898,7 +890,6 @@ sub test_content_as_string ($) { my $s = "\n\t"; foreach my $key (get_test_keys()) { - #$test{$key} = $test{$key} // 'undefined'; $test{$key} = 'Not set' unless (defined $test{$key}); } @@ -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 @@ -1272,7 +1263,6 @@ sub cli_option_is_set ($) { return defined $cli_options{$cli_option}; } - sub get_cli_option ($) { our %cli_options; @@ -1283,7 +1273,6 @@ sub get_cli_option ($) { return $cli_options{$cli_option}; } - sub main () { init_our_variables();