httpd-test-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-test/perl-framework/t/modules include.t
Date Fri, 22 Aug 2003 07:32:05 GMT
nd          2003/08/22 00:32:05

  Modified:    perl-framework/t/modules include.t
  Log:
  add test for fsize/flastmod. I'm not sure about the locale thing, but
  if I keep my locale, the test won't success. Seems, mod_include (httpd?)
  doesn't care about the locale (?!).
  
  Revision  Changes    Path
  1.36      +50 -4     httpd-test/perl-framework/t/modules/include.t
  
  Index: include.t
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/t/modules/include.t,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- include.t	21 Aug 2003 05:19:47 -0000	1.35
  +++ include.t	22 Aug 2003 07:32:05 -0000	1.36
  @@ -96,12 +96,12 @@
   );
   
   #
  -# in addition to $tests, there are 1 GET test, 11 XBitHack tests,
  -# 2 exec cgi tests, 2 malformed-ssi-directive tests, and 14 tests
  -# that use mod_bucketeer to construct brigades for mod_include
  +# in addition to $tests, there are 1 fsize/flastmod test, 1 GET test,
  +# 11 XBitHack tests, 2 exec cgi tests, 2 malformed-ssi-directive tests,
  +# and 14 tests that use mod_bucketeer to construct brigades for mod_include
   #
   my $tests = scalar(keys %test) + scalar(keys %t_test) + @patterns + 2;
  -plan tests => $tests + 30, have_module 'include';
  +plan tests => $tests + 31, have_module 'include';
   
   Apache::TestRequest::scheme('http'); #ssl not listening on this vhost
   Apache::TestRequest::module('mod_include'); #use this module's port
  @@ -145,6 +145,52 @@
            "GET ${dir}if7.shtml"
           );
   
  +### FLASTMOD/FSIZE TESTS
  +unless(eval{require POSIX}) {
  +    skip "POSIX module not found", 1;
  +}
  +else {
  +    my ($size, $mtime) = (stat "$docroot${dir}file.shtml")[7, 9];
  +    my @time = localtime($mtime);
  +    
  +    my $strftime = sub($) {
  +        my $fmt = shift;
  +
  +        POSIX::strftime($fmt, $time[0], $time[1], $time[2], $time[3], $time[4],
  +                        $time[5], -1, -1, -1);
  +    };
  +
  +    # XXX: not sure about the locale thing, but it seems to work at least on my
  +    # machine :)
  +    POSIX->import('locale_h');
  +    my $oldloc = setlocale(&LC_TIME);
  +    POSIX::setlocale(&LC_TIME, "C");
  +
  +    $expected = join ' ' =>
  +        $strftime->("%A, %d-%b-%Y %H:%M:%S %Z"),
  +        $strftime->("%A, %d-%b-%Y %H:%M:%S %Z"),
  +        $strftime->("%A, %B %e, %G"),
  +        $strftime->("%A, %B %e, %G"),
  +        $strftime->("%T"),
  +        $strftime->("%T");
  +
  +    # XXX: works, because file.shtml is very small.
  +    $expected .= " $size $size $size $size";
  +
  +    POSIX::setlocale(&LC_TIME, $oldloc);
  +
  +    $expected =~ s/\s+/ /g;
  +    $expected =~ s/ $//; $expected =~ s/^ //;
  +
  +    my $result = super_chomp(GET_BODY "${dir}file.shtml");
  +    $result =~ s/\s+/ /g;
  +    $result =~ s/ $//; $result =~ s/^ //;
  +
  +    ok t_cmp("$expected",
  +             "$result",
  +             "GET ${dir}file.shtml"
  +            );
  +}
   
   ### EXEC CGI TESTS
   # skipped if !have_cgi
  
  
  

Mime
View raw message