You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jose Kahan <jo...@w3.org> on 2007/08/10 09:37:43 UTC

How to contribute new tests to the Apache TestSuite?

Hi!

I've added some tests to your Perl Framework test suite (latest
co from svn). These tests cover subrequests and content-negotiation,
following the bug report (and patch) I sent as bug #41960.

For these tests, I added a new test script (.t), a new section
to extra.conf.in, and a new subdirectory (with content) to htdocs.

Could you tell me what is the best way to submit this patch to
save you time in its evaluation / integration? And also, what's
the easiest way to generate it for you? (svn diff?).

Many thanks,

-jose

New test: subrequests and content negotiation

Posted by Jose Kahan <jo...@w3.org>.
Hi!

Here's my first submission. This test is written against your
perl-framework test environment.

It tests that subrequests are correctly parsing and taking into
account directives that are declared in <Directory>, <Location> sections
and .htaccess files. I'm using the same test scenario I gave in bug
#41960.

Basically, this requires having the following global content-type:
	AddType text/html; charset=iso-8859-1	html/htm

The test consists on overloading the charset to utf-8:
	AddType text/html; charset=utf-8	html/htm

in the test locations under t/apache/subrequests/, one each
for <Directory>, <Location>, and .htaccess. There is a file each
time that is being requested with its complete name 
	http://..../apache/subrequests/.../hello.html

and through content-negotiation:
	http://..../apache/subrequests/.../hello

It is the content-negotiation that is being processed thru subrequests.

The patch I sent to bug #41960 fixes the subrequest bugs. Without
that patch, one of these tests will return an error (under Apache/2.2.4).

I'm attaching a tgz file which includes a patch to extra.conf.in,
and new files to be stored under t/htdocs/apache/subrequests and
t/subrequests.t The tar archive contains the full hierarchy.

I put this test under t/apache rather than under t/modules because it
is testing subrequests, even if we do so thru content-negotiation. The
tests could be expanded to any other directive that is declared for
a specific location.

Comments are welcome.

Cheers,

-jose

=== inline version of the test and extra.config.in section follows ==

=== subrequests.t ====

use strict;
use warnings FATAL => 'all';

use Apache::Test;
use Apache::TestRequest;
use Apache::TestUtil;

plan tests => 6, have_module qw(mod_negotiation mod_mime);

## Returns ok if the returned content-type is the same as the 
## expected one.
#
sub check_content_type  
{
    my $path = shift;
    my $expected = shift;
    my $error_msg = shift;

    my $h = HEAD_STR $path;

    ## parse response headers looking for our headers
    my $actual_value;
    foreach my $head (split /\n/, $h) {
	if ($head =~ /^Content-Type: (.*)$/) {
	    $actual_value = $1;
	    last;
	}
    }

    ok t_cmp($actual_value, $expected, $error_msg);
	
}

## The server is configured to return text/html; charset=iso8859-1 by default
## The different section overrides change this to charset=utf-8. 
## We do the test with and without content-negotiation

my $expected_type = "text/html; charset=utf-8";

check_content_type ("/apache/subrequests/dir_override/hello.html", 
		    $expected_type,
		    "subrequests with <Directory> overrides");
check_content_type ("/apache/subrequests/dir_override/hello", 
		    $expected_type,
		    "subrequests with <Directory> overrides and conn-neg");

check_content_type ("/apache/subrequests/location_override/hello.html",
		    $expected_type,
		    "subrequests with <Location> overrides");
check_content_type ("/apache/subrequests/location_override/hello",
		    $expected_type,
		    "subrequests with <Location> overrides and conn-neg");

check_content_type ("/apache/subrequests/htaccess_override/hello.html",
		    $expected_type,
		    "subrequests with .htaccess overrides");
check_content_type ("/apache/subrequests/htaccess_override/hello",
		    $expected_type,
		    "subrequests with .htaccess overrides and conn-neg");

========== extra.conf.in section ==

##
## subrequests test config
##

<IfDefine APACHE2>
    <IfModule mod_mime.c>
       AddType text/html;charset=iso-8859-1     html htm
    </IfModule>

    <IfModule mod_negotiation.c>

       <Directory @SERVERROOT@/htdocs/apache/subrequests/dir_override>
          Options +MultiViews
          AddType text/html;charset=utf-8               html htm
       </Directory>

       <Location "/apache/subrequests/location_override">
          Options +MultiViews
          AddType text/html;charset=utf-8               html htm
       </Location>
       <Directory "@SERVERROOT@/htdocs/apache/subrequests/htaccess_override/">
          Options +MultiViews
          AllowOverride FileInfo
       </Directory>

    </IfModule>
</IfDefine>


Re: How to contribute new tests to the Apache TestSuite?

Posted by Plüm, Rüdiger, VF-Group <ru...@vodafone.com>.

> -----Ursprüngliche Nachricht-----
> Von: Jose Kahan 
> Gesendet: Freitag, 10. August 2007 09:38
> An: dev@httpd.apache.org
> Betreff: How to contribute new tests to the Apache TestSuite?
> 
> 
> Hi!
> 
> I've added some tests to your Perl Framework test suite (latest
> co from svn). These tests cover subrequests and content-negotiation,
> following the bug report (and patch) I sent as bug #41960.
> 
> For these tests, I added a new test script (.t), a new section
> to extra.conf.in, and a new subdirectory (with content) to htdocs.
> 
> Could you tell me what is the best way to submit this patch to
> save you time in its evaluation / integration? And also, what's
> the easiest way to generate it for you? (svn diff?).

svn diff as attachment of a mail and inline in the mail (if not too large)
to the dev@ list sounds fine. The attachment is useful for applying the patch
in the developers environment. The inline version is useful for stating
comments on your patch back on the list.

Regards

Rüdiger