Issue 16661: test_posix.test_getgrouplist fails on some systems - incorrectly comparing getgroups and getgrouplist results (original) (raw)

Created on 2012-12-11 03:46 by gregory.p.smith, last changed 2022-04-11 14:57 by admin. 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) (Python triager) 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 .
History
Date User Action Args
2022-04-11 14:57:39 admin set github: 60865
2012-12-16 21:31:01 ned.deily set nosy: + ned.deilymessages: +
2012-12-16 14:03:08 rosslagerwall set status: open -> closedmessages: +
2012-12-16 13:29:56 pitrou set status: closed -> openversions: + Python 2.7, Python 3.2nosy: + pitroumessages: +
2012-12-15 20:34:51 rosslagerwall set status: open -> closedassignee: rosslagerwallresolution: fixedstage: needs patch -> resolved
2012-12-13 16🔞47 rosslagerwall set messages: +
2012-12-13 15:24:55 python-dev set nosy: + python-devmessages: +
2012-12-11 07:38:46 gregory.p.smith set messages: +
2012-12-11 07:34:25 rosslagerwall set messages: +
2012-12-11 07:23:35 gregory.p.smith set messages: + 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:00 rosslagerwall set nosy: + rosslagerwallmessages: + 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:15 gregory.p.smith create