diff options
author | shirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-08-27 11:57:43 +0000 |
---|---|---|
committer | shirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-08-27 11:57:43 +0000 |
commit | a5849245c6ffb31053ab75ab2e36163674ca7c81 (patch) | |
tree | fb13a2edfcf1220749ef34f05bb60a6fe8274d0c /test/etc | |
parent | 0b89d6d5f9f8c788f4391d8a0499f10aed624371 (diff) | |
download | ruby-a5849245c6ffb31053ab75ab2e36163674ca7c81.tar.gz |
test_etc.rb: fix for non unique GID
* test/etc/test_etc.rb (TestEtc#test_getgrgid): fix for non unique GID.
No unixen systems guarantee that GID is unique. Etc.getgrgid would
not return the first entry in the order of Etc.group for shared GID.
[ruby-core:47312] [Bug #6935]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/etc')
-rw-r--r-- | test/etc/test_etc.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/test/etc/test_etc.rb b/test/etc/test_etc.rb index 5bc8db431c..c105122af1 100644 --- a/test/etc/test_etc.rb +++ b/test/etc/test_etc.rb @@ -76,13 +76,18 @@ class TestEtc < Test::Unit::TestCase end def test_getgrgid - groups = {} - Etc.group do |s| - groups[s.gid] ||= s + # group database is not unique on GID, and which entry will be + # returned by getgrgid() is not specified. + groups = Hash.new {[]} + # on MacOSX, same entries are returned from /etc/group and Open + # Directory. + Etc.group {|s| groups[s.gid] |= [s]} + groups.each_pair do |gid, s| + assert_include(s, Etc.getgrgid(gid)) end - groups.each_value do |s| - assert_equal(s, Etc.getgrgid(s.gid)) - assert_equal(s, Etc.getgrgid) if Process.egid == s.gid + s = groups[Process.egid] + unless s.empty? + assert_include(s, Etc.getgrgid) end end |