From 7478faa5ce191918c577fddf3fd79de8d7d9b515 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Thu, 9 Jan 2014 08:45:53 -0800 Subject: [PATCH] test: Adds support to handle different content in log depending on the version Some functionalities are just enabled on Apache, not part of nginx or IIS. As example we have the "proxy", currently just supported in Apache. This patches add to our regression test suite the ability to expect different contents based on the targert platform. --- tests/run-regression-tests-nginx.pl | 28 ++++++++++++++++++++++++++++ tests/run-regression-tests.pl.in | 26 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/tests/run-regression-tests-nginx.pl b/tests/run-regression-tests-nginx.pl index db062939..967a2c88 100755 --- a/tests/run-regression-tests-nginx.pl +++ b/tests/run-regression-tests-nginx.pl @@ -44,6 +44,9 @@ $UA->agent($UA_NAME); $SIG{TERM} = $SIG{INT} = \&handle_interrupt; + +my $platform = "nginx"; + my %opt; getopts('A:E:D:C:T:H:a:p:dvh', \%opt); @@ -233,6 +236,19 @@ sub runfile { for my $key (keys %{ $t{match_response} || {}}) { my($neg,$mtype) = ($key =~ m/^(-?)(.*)$/); my $m = $t{match_response}{$key}; + if (ref($m) eq "HASH") { + if ($m->{$platform}) { + $m = $m->{$platform}; + } + else { + my $ap = join(", ", keys %{$m}); + msg("Warning: trying to match response. Nothing " . + "to match in current platform: $platform. " . + "This test only contains cotent for: $ap."); + last; + } + } + my $match = match_response($mtype, $resp, $m); if ($neg and defined $match) { $rc = 1; @@ -266,6 +282,18 @@ sub runfile { for my $key (keys %{ $t{match_log} || {}}) { my($neg,$mtype) = ($key =~ m/^(-?)(.*)$/); my $m = $t{match_log}{$key}; + if (ref($m) eq "HASH") { + if ($m->{$platform}) { + $m = $m->{$platform}; + } + else { + my $ap = join(", ", keys %{$m}); + msg("Warning: trying to match: $mtype. Nothing " . + "to match in current platform: $platform. " . + "This test only contains cotent for: $ap."); + last; + } + } my $match = match_log($mtype, @{$m || []}); if ($neg and defined $match) { $rc = 1; diff --git a/tests/run-regression-tests.pl.in b/tests/run-regression-tests.pl.in index 019ccf2c..40e885f0 100755 --- a/tests/run-regression-tests.pl.in +++ b/tests/run-regression-tests.pl.in @@ -51,6 +51,8 @@ if ($HTTPD eq "\@APXS_HTTPD\@") { $SIG{TERM} = $SIG{INT} = \&handle_interrupt; +my $platform = "apache"; + my %opt; getopts('A:E:D:C:T:H:a:p:dvh', \%opt); @@ -230,6 +232,18 @@ sub runfile { for my $key (keys %{ $t{match_response} || {}}) { my($neg,$mtype) = ($key =~ m/^(-?)(.*)$/); my $m = $t{match_response}{$key}; + if (ref($m) eq "HASH") { + if ($m->{$platform}) { + $m = $m->{$platform}; + } + else { + my $ap = join(", ", keys %{$m}); + msg("Warning: trying to match: $mtype. Nothing " . + "to match in current platform: $platform. " . + "This test only contains cotent for: $ap."); + last; + } + } my $match = match_response($mtype, $resp, $m); if ($neg and defined $match) { $rc = 1; @@ -263,6 +277,18 @@ sub runfile { for my $key (keys %{ $t{match_log} || {}}) { my($neg,$mtype) = ($key =~ m/^(-?)(.*)$/); my $m = $t{match_log}{$key}; + if (ref($m) eq "HASH") { + if ($m->{$platform}) { + $m = $m->{$platform}; + } + else { + my $ap = join(", ", keys %{$m}); + msg("Warning: trying to match: $mtype. Nothing " . + "to match in current platform: $platform. " . + "This test only contains cotent for: $ap."); + last; + } + } my $match = match_log($mtype, @{$m || []}); if ($neg and defined $match) { $rc = 1;