This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: updated patch on the sysread, syswrite for VMS
[perl5.git] / t / op / groups.t
1 #!./perl
2
3 if (! -x ($groups = '/usr/ucb/groups') && ! -x ($groups = '/usr/bin/groups')) {
4     print "1..0\n";
5     exit 0;
6 }
7
8 print "1..2\n";
9
10 $pwgid = $( + 0;
11 ($pwgnam) = getgrgid($pwgid);
12 @basegroup{$pwgid,$pwgnam} = (1,1);
13
14 $seen{$pwgid}++;
15
16 for (split(' ', $()) {
17     next if $seen{$_}++;
18     ($group) = getgrgid($_);
19     if (defined $group) {
20         push(@gr, $group);
21     }
22     else {
23         push(@gr, $_);
24     }
25
26
27 $gr1 = join(' ', sort @gr);
28
29 $gr2 = join(' ', grep(!$basegroup{$_}++, sort split(' ',`$groups`)));
30
31 if ($gr1 eq $gr2) {
32     print "ok 1\n";
33 }
34 else {
35     print "#gr1 is <$gr1>\n";
36     print "#gr2 is <$gr2>\n";
37     print "not ok 1\n";
38 }
39
40 # multiple 0's indicate GROUPSTYPE is currently long but should be short
41
42 if ($pwgid == 0 || $seen{0} < 2) {
43     print "ok 2\n";
44 }
45 else {
46     print "not ok 2 (groupstype should be type short, not long)\n";
47 }