classification
Title: test_posix.test_getgrouplist fails on some systems - incorrectly comparing getgroups and getgrouplist results
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rosslagerwall Nosy List: gregory.p.smith, ned.deily, pitrou, python-dev, rosslagerwall
Priority: normal Keywords:

Created on 2012-12-11 03:46 by gregory.p.smith, last changed 2012-12-16 21:31 by ned.deily. This issue is now closed.

Messages (10)
msg177320 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2012-12-11 03:46
test_posix.test_getgrouplist is failing for me on my Linux (ubuntu precise) based desktop at work.

It looks like posix.getgrouplist() is returning all of the larger GIDs.  The lowest one it is reporting for my user is 499 but the more distro specific groups that I am are not included in its 18 element long list it returns so the test fails:

test test_posix failed -- Traceback (most recent call last):
  File "cpython/default/Lib/test/test_posix.py", line 660, in test_getgrouplist
    pwd.getpwuid(os.getuid())[3])))
AssertionError: Items in the first set but not the second:
128
4
104
44
46
20
24
25

strace reveals that the 'id -G' command this test is trying to compare against calls getgroups() while posix.getgrouplist() appears to do something else that does not make that syscall.

posix.getgroups() does the same thing as 'id -G', this test for posix.getgrouplist(username, uid) is making an incorrect assertion.
msg177321 - (view) Author: Ross Lagerwall (rosslagerwall) (Python committer) Date: 2012-12-11 07:08
It seems like getgrouplist returns the information from the system
database whereas getgroups (and consequently id -G) returns the
supplementary groups for the calling process.

I'm not exactly sure how getgrouplist() can be effectively tested then.
msg177322 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2012-12-11 07:23
would the values returned by getgrouplist always be a non empty subset of
getgroups?  (regardless, I expect the id -G process output parsing can be
removed)
msg177323 - (view) Author: Ross Lagerwall (rosslagerwall) (Python committer) Date: 2012-12-11 07:34
I wouldn't think so. A call to setgroups can add or remove groups for
the calling process. If it removes groups, then getgrouplist() won't
return a subset of getgroups().
msg177325 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2012-12-11 07:38
Given this is more of a code coverage test than any need to test the
functionality of the OS library call, just asserting that it returns a
non-empty list is a decent test. :)
msg177409 - (view) Author: Roundup Robot (python-dev) Date: 2012-12-13 15:24
New changeset ce85fe971e0a by Ross Lagerwall in branch '3.3':
Issue #16661: Fix the os.getgrouplist() test by not assuming that it
http://hg.python.org/cpython/rev/ce85fe971e0a

New changeset 05a37954a30c by Ross Lagerwall in branch 'default':
Merge with 3.3 for #16661
http://hg.python.org/cpython/rev/05a37954a30c
msg177411 - (view) Author: Ross Lagerwall (rosslagerwall) (Python committer) Date: 2012-12-13 16:18
Is that fixed now? I simplified the test to check for a non-empty list being returned.
msg177598 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-12-16 13:29
Apparently this also needs fixing on 2.7 and 3.2, see e.g. http://buildbot.python.org/all/builders/AMD64%20Mountain%20Lion%20%5BSB%5D%203.2
msg177600 - (view) Author: Ross Lagerwall (rosslagerwall) (Python committer) Date: 2012-12-16 14:03
getgrouplist() is new in 3.3. Those failures are from getgroups() failing. I'll open a separate issue for that.
msg177629 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-12-16 21:31
The getgroups test failure on OS X is likely the known limitation documented in issue10433.
History
Date User Action Args
2012-12-16 21:31:01ned.deilysetnosy: + ned.deily
messages: + msg177629
2012-12-16 14:03:08rosslagerwallsetstatus: open -> closed

messages: + msg177600
2012-12-16 13:29:56pitrousetstatus: closed -> open
versions: + Python 2.7, Python 3.2
nosy: + pitrou

messages: + msg177598
2012-12-15 20:34:51rosslagerwallsetstatus: open -> closed
assignee: rosslagerwall
resolution: fixed
stage: needs patch -> resolved
2012-12-13 16:18:47rosslagerwallsetmessages: + msg177411
2012-12-13 15:24:55python-devsetnosy: + python-dev
messages: + msg177409
2012-12-11 07:38:46gregory.p.smithsetmessages: + msg177325
2012-12-11 07:34:25rosslagerwallsetmessages: + msg177323
2012-12-11 07:23:35gregory.p.smithsetmessages: + msg177322
title: test_posix.test_getgrouplist fails on some systems - incorrectly comparing getgroups and getgrouplist results -> test_posix.test_getgrouplist fails on some systems - incorrectly comparing getgroups and getgrouplist results
2012-12-11 07:08:00rosslagerwallsetnosy: + rosslagerwall

messages: + msg177321
title: test_posix.test_getgrouplist fails on some systems - incorrectly comparing getgroups and getgrouplist results -> test_posix.test_getgrouplist fails on some systems - incorrectly comparing getgroups and getgrouplist results
2012-12-11 03:46:15gregory.p.smithcreate