summaryrefslogtreecommitdiffstats
path: root/contrib/perl5/t/op/groups.t
blob: 47aabe3d7b4502db7c25b16a36a81a8b3e16613c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!./perl

if (! -x ($groups = '/usr/ucb/groups') &&
    ! -x ($groups = '/usr/bin/groups') &&
    ! -x ($groups = '/bin/groups')
) {
    print "1..0\n";
    exit 0;
}

print "1..2\n";

$pwgid = $( + 0;
($pwgnam) = getgrgid($pwgid);
@basegroup{$pwgid,$pwgnam} = (1,1);

$seen{$pwgid}++;

for (split(' ', $()) {
    next if $seen{$_}++;
    ($group) = getgrgid($_);
    if (defined $group) {
	push(@gr, $group);
    }
    else {
	push(@gr, $_);
    }
} 

$gr1 = join(' ', sort @gr);

$gr2 = join(' ', grep(!$basegroup{$_}++, sort split(' ',`$groups`)));

if ($gr1 eq $gr2) {
    print "ok 1\n";
}
else {
    print "#gr1 is <$gr1>\n";
    print "#gr2 is <$gr2>\n";
    print "not ok 1\n";
}

# multiple 0's indicate GROUPSTYPE is currently long but should be short

if ($pwgid == 0 || $seen{0} < 2) {
    print "ok 2\n";
}
else {
    print "not ok 2 (groupstype should be type short, not long)\n";
}
OpenPOWER on IntegriCloud