Commit | Line | Data |
c7506216 |
1 | #!./perl |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | @INC = '../lib'; |
6 | } |
7 | |
8 | BEGIN { |
9 | our $haspw; |
10 | eval { my @n = getpwuid 0 }; |
11 | $haspw = 1 unless $@ && $@ =~ /unimplemented/; |
12 | unless ($haspw) { print "1..0 # Skip: no getpwuid\n"; exit 0 } |
13 | use Config; |
14 | $haspw = 0 unless $Config{'i_pwd'} eq 'define'; |
15 | unless ($haspw) { print "1..0 # Skip: no pwd.h\n"; exit 0 } |
16 | } |
17 | |
18 | BEGIN { |
19 | our @pwent = getpwuid 0; # This is the function getpwuid. |
20 | unless (@pwent) { print "1..0 # Skip: no uid 0\n"; exit 0 } |
21 | } |
22 | |
23 | print "1..9\n"; |
24 | |
25 | use User::pwent; |
26 | |
27 | print "ok 1\n"; |
28 | |
29 | my $pwent = getpwuid 0; # This is the OO getpwuid. |
30 | |
0da7f12a |
31 | print "not " unless $pwent->uid == 0 || |
32 | ($^O eq 'cygwin' && $pwent->uid == 500); # go figure |
c7506216 |
33 | print "ok 2\n"; |
34 | |
35 | print "not " unless $pwent->name == $pwent[0]; |
36 | print "ok 3\n"; |
37 | |
38 | print "not " unless $pwent->passwd eq $pwent[1]; |
39 | print "ok 4\n"; |
40 | |
41 | print "not " unless $pwent->uid == $pwent[2]; |
42 | print "ok 5\n"; |
43 | |
44 | print "not " unless $pwent->gid == $pwent[3]; |
45 | print "ok 6\n"; |
46 | |
47 | # The quota and comment fields are unportable. |
48 | |
49 | print "not " unless $pwent->gecos eq $pwent[6]; |
50 | print "ok 7\n"; |
51 | |
52 | print "not " unless $pwent->dir eq $pwent[7]; |
53 | print "ok 8\n"; |
54 | |
55 | print "not " unless $pwent->shell eq $pwent[8]; |
56 | print "ok 9\n"; |
57 | |
58 | # The expire field is unportable. |
59 | |
60 | # Testing pretty much anything else is unportable: |
61 | # there maybe more than one username with uid 0; |
62 | # uid 0's home directory may be "/" or "/root' or something else, |
63 | # and so on. |
64 | |