Return-Path: Delivered-To: apmail-perl-modperl-cvs-archive@www.apache.org Received: (qmail 14279 invoked from network); 18 Nov 2003 01:14:44 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 18 Nov 2003 01:14:44 -0000 Received: (qmail 3963 invoked by uid 500); 18 Nov 2003 01:14:28 -0000 Delivered-To: apmail-perl-modperl-cvs-archive@perl.apache.org Received: (qmail 3777 invoked by uid 500); 18 Nov 2003 01:14:27 -0000 Mailing-List: contact modperl-cvs-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: dev@perl.apache.org Delivered-To: mailing list modperl-cvs@perl.apache.org Received: (qmail 3751 invoked by uid 500); 18 Nov 2003 01:14:27 -0000 Delivered-To: apmail-modperl-2.0-cvs@apache.org Subject: Re: cvs commit: modperl-2.0/t/response/TestAPR finfo.pm From: "Philippe M. Chiasson" To: dev@perl.apache.org Cc: modperl-2.0-cvs@apache.org In-Reply-To: <20031117233102.51309.qmail@minotaur.apache.org> References: <20031117233102.51309.qmail@minotaur.apache.org> Content-Type: text/plain Message-Id: <1069118043.2796.7.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) Date: Mon, 17 Nov 2003 17:14:03 -0800 Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Mon, 2003-11-17 at 15:31, geoff@apache.org wrote: > geoff 2003/11/17 15:31:02 > > Added: t/response/TestAPR finfo.pm > Log: > add $r->finfo tests > > Revision Changes Path > 1.1 modperl-2.0/t/response/TestAPR/finfo.pm > > Index: finfo.pm > =================================================================== > package TestAPR::finfo; > > use strict; > use warnings FATAL => 'all'; > > use Apache::Test; > use Apache::TestUtil; > use Apache::TestTrace; > > use Apache::RequestRec (); > use APR::Finfo (); > use APR::Const -compile => qw(SUCCESS FINFO_NORM REG > WREAD WWRITE WEXECUTE); > > use File::Spec::Functions qw(catfile); > use Fcntl qw(:mode); > > use Apache::Const -compile => 'OK'; > > sub handler { > my $r = shift; > > plan $r, tests => 17; > > { > my $finfo = $r->finfo; > my $isa = $finfo->isa('APR::Finfo'); > > t_debug "\$r->finfo $finfo"; > ok $isa; > } > > { > my $pool = $r->finfo->pool; > my $isa = $pool->isa('APR::Pool'); > > t_debug "\$r->finfo->pool $pool"; > ok $isa; > } > > my $file = Apache->server_root_relative(catfile qw(htdocs index.html)); > > # stat tests > { > # populate the finfo struct first > my $status = APR::Finfo::stat($r->finfo, $file, > APR::FINFO_NORM, $r->pool); > > ok t_cmp(APR::SUCCESS, > $status, > "stat $file"); > > # now, get information from perl's stat() > our ($device, $inode, $protection, $nlink, $user, $group, > undef, $size, $atime, $mtime, $ctime) = stat $file; I dunno, but I am afraid that stuff like device, inode, nlink and such might not work similarly on non-Unixes.. These tests most likely need to be a bit more OS-specific to avoid failures on those OSes > # compare stat fields between perl and apr_stat > { > no strict qw(refs); > foreach my $method (qw(device inode nlink user group > size atime mtime ctime)) { > > ok t_cmp(${$method}, > $r->finfo->$method(), > "\$r->finfo->$method()"); > } > } > > # match world bits > > ok t_cmp($protection & S_IROTH, > $r->finfo->protection & APR::WREAD, > '$r->finfo->protection() & APR::WREAD'); > > ok t_cmp($protection & S_IWOTH, > $r->finfo->protection & APR::WWRITE, > '$r->finfo->protection() & APR::WWRITE'); > > ok t_cmp($protection & S_IXOTH, > $r->finfo->protection & APR::WEXECUTE, > '$r->finfo->protection() & APR::WEXECUTE'); > } > > # tests for stuff not in perl's stat > { > ok t_cmp($file, > $r->finfo->fname, > '$r->finfo->fname()'); > > ok t_cmp(APR::REG, > $r->finfo->filetype, > '$r->finfo->filetype()'); > } > > Apache::OK; > } > > 1; > > > >