xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/User/grent.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateBEGIN {
4*0Sstevel@tonic-gate    chdir 't' if -d 't';
5*0Sstevel@tonic-gate    @INC = '../lib';
6*0Sstevel@tonic-gate}
7*0Sstevel@tonic-gate
8*0Sstevel@tonic-gateuse Test::More;
9*0Sstevel@tonic-gate
10*0Sstevel@tonic-gateBEGIN {
11*0Sstevel@tonic-gate    our $hasgr;
12*0Sstevel@tonic-gate    eval { my @n = getgrgid 0 };
13*0Sstevel@tonic-gate    $hasgr = 1 unless $@ && $@ =~ /unimplemented/;
14*0Sstevel@tonic-gate    unless ($hasgr) { plan skip_all => "no getgrgid"; }
15*0Sstevel@tonic-gate    use Config;
16*0Sstevel@tonic-gate    $hasgr = 0 unless $Config{'i_grp'} eq 'define';
17*0Sstevel@tonic-gate    unless ($hasgr) { plan skip_all => "no grp.h"; }
18*0Sstevel@tonic-gate}
19*0Sstevel@tonic-gate
20*0Sstevel@tonic-gateBEGIN {
21*0Sstevel@tonic-gate    our @grent = getgrgid 0; # This is the function getgrgid.
22*0Sstevel@tonic-gate    unless (@grent) { plan skip_all => "no gid 0"; }
23*0Sstevel@tonic-gate}
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gateBEGIN {
26*0Sstevel@tonic-gate    plan tests => 5;
27*0Sstevel@tonic-gate    use_ok('User::grent');
28*0Sstevel@tonic-gate}
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gatecan_ok(__PACKAGE__, 'getgrgid');
31*0Sstevel@tonic-gate
32*0Sstevel@tonic-gatemy $grent = getgrgid 0;
33*0Sstevel@tonic-gate
34*0Sstevel@tonic-gateis( $grent->name, $grent[0],    'name matches core getgrgid' );
35*0Sstevel@tonic-gate
36*0Sstevel@tonic-gateis( $grent->passwd, $grent[1],  '   passwd' );
37*0Sstevel@tonic-gate
38*0Sstevel@tonic-gateis( $grent->gid, $grent[2],     '   gid' );
39*0Sstevel@tonic-gate
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gate# Testing pretty much anything else is unportable.
42*0Sstevel@tonic-gate
43