From: Jarkko Hietaniemi Date: Tue, 29 May 2001 14:24:20 +0000 (+0000) Subject: Add test for User::pwent. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c750621644955b087636a9a45714624ec22f1f20;p=p5sagit%2Fp5-mst-13.2.git Add test for User::pwent. Probably will fall down somewhere for portability reasons. p4raw-id: //depot/perl@10285 --- diff --git a/MANIFEST b/MANIFEST index a06fbbf..b6b8fca 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1669,6 +1669,7 @@ t/lib/u-reftype.t Scalar::Util t/lib/u-sum.t List::Util t/lib/u-tainted.t Scalar::Util t/lib/u-weak.t Scalar::Util +t/lib/user-pwent.t See if User::pwent works t/lib/xs-typemap.t test that typemaps work t/op/64bitint.t See if 64 bit integers work t/op/anonsub.t See if anonymous subroutines work diff --git a/t/lib/1_compile.t b/t/lib/1_compile.t index f45bdd6..3e4ea6f 100644 --- a/t/lib/1_compile.t +++ b/t/lib/1_compile.t @@ -234,6 +234,7 @@ Time::HiRes Time::Local Time::Piece UNIVERSAL +User::pwent XS::Typemap attrs autouse diff --git a/t/lib/user-pwent.t b/t/lib/user-pwent.t new file mode 100644 index 0000000..e274265 --- /dev/null +++ b/t/lib/user-pwent.t @@ -0,0 +1,63 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +BEGIN { + our $haspw; + eval { my @n = getpwuid 0 }; + $haspw = 1 unless $@ && $@ =~ /unimplemented/; + unless ($haspw) { print "1..0 # Skip: no getpwuid\n"; exit 0 } + use Config; + $haspw = 0 unless $Config{'i_pwd'} eq 'define'; + unless ($haspw) { print "1..0 # Skip: no pwd.h\n"; exit 0 } +} + +BEGIN { + our @pwent = getpwuid 0; # This is the function getpwuid. + unless (@pwent) { print "1..0 # Skip: no uid 0\n"; exit 0 } +} + +print "1..9\n"; + +use User::pwent; + +print "ok 1\n"; + +my $pwent = getpwuid 0; # This is the OO getpwuid. + +print "not " unless $pwent->uid == 0; +print "ok 2\n"; + +print "not " unless $pwent->name == $pwent[0]; +print "ok 3\n"; + +print "not " unless $pwent->passwd eq $pwent[1]; +print "ok 4\n"; + +print "not " unless $pwent->uid == $pwent[2]; +print "ok 5\n"; + +print "not " unless $pwent->gid == $pwent[3]; +print "ok 6\n"; + +# The quota and comment fields are unportable. + +print "not " unless $pwent->gecos eq $pwent[6]; +print "ok 7\n"; + +print "not " unless $pwent->dir eq $pwent[7]; +print "ok 8\n"; + +print "not " unless $pwent->shell eq $pwent[8]; +print "ok 9\n"; + +# The expire field is unportable. + +# Testing pretty much anything else is unportable: +# there maybe more than one username with uid 0; +# uid 0's home directory may be "/" or "/root' or something else, +# and so on. +