1996-12-19 03:36:34 +08:00
|
|
|
#! /usr/bin/env python
|
|
|
|
"""Test script for the grp module
|
|
|
|
Roger E. Masse
|
|
|
|
"""
|
2000-10-24 01:22:08 +08:00
|
|
|
|
1996-12-19 03:36:34 +08:00
|
|
|
import grp
|
1996-12-21 06:36:52 +08:00
|
|
|
from test_support import verbose
|
1996-12-19 03:36:34 +08:00
|
|
|
|
|
|
|
groups = grp.getgrall()
|
|
|
|
if verbose:
|
|
|
|
print 'Groups:'
|
|
|
|
for group in groups:
|
1998-03-27 03:42:58 +08:00
|
|
|
print group
|
1996-12-19 03:36:34 +08:00
|
|
|
|
1997-12-15 22:57:19 +08:00
|
|
|
if not groups:
|
|
|
|
if verbose:
|
1998-03-27 03:42:58 +08:00
|
|
|
print "Empty Group Database -- no further tests of grp module possible"
|
1997-12-15 22:57:19 +08:00
|
|
|
else:
|
|
|
|
group = grp.getgrgid(groups[0][2])
|
|
|
|
if verbose:
|
1998-03-27 03:42:58 +08:00
|
|
|
print 'Group Entry for GID %d: %s' % (groups[0][2], group)
|
1996-12-19 03:36:34 +08:00
|
|
|
|
1997-12-15 22:57:19 +08:00
|
|
|
group = grp.getgrnam(groups[0][0])
|
|
|
|
if verbose:
|
1998-03-27 03:42:58 +08:00
|
|
|
print 'Group Entry for group %s: %s' % (groups[0][0], group)
|