Return-Path: Delivered-To: apmail-httpd-test-cvs-archive@httpd.apache.org Received: (qmail 63403 invoked by uid 500); 22 Aug 2003 09:21:15 -0000 Mailing-List: contact test-cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: test-dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list test-cvs@httpd.apache.org Received: (qmail 63288 invoked from network); 22 Aug 2003 09:21:12 -0000 Received: from minotaur.apache.org (209.237.227.194) by daedalus.apache.org with SMTP; 22 Aug 2003 09:21:12 -0000 Received: (qmail 58612 invoked by uid 1569); 22 Aug 2003 07:32:05 -0000 Date: 22 Aug 2003 07:32:05 -0000 Message-ID: <20030822073205.58611.qmail@minotaur.apache.org> From: nd@apache.org To: httpd-test-cvs@apache.org Subject: cvs commit: httpd-test/perl-framework/t/modules include.t X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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