summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-16 02:13:44 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-16 02:13:44 +0000
commit62f6e9242c620a9d1423010c2c93acbf97cfcd68 (patch)
treed8f8882b7fb482c6c0867c8eb9765527436b222c /test
parente9ff4a22dfbd07ea6c54179979d937ff739eead3 (diff)
merge revision(s) 36625: [Backport #6831]
test_etc.rb: remove implicit assumption * test/etc/test_etc.rb (TestEtc#test_getpwuid): remove implicit assumption, that getpwuid() would return the first entry in the order of getpw(), for shared UID. apparently it is not true on MacOS X 10.8. [ruby-core:46975][Bug #6831] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@37210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/etc/test_etc.rb17
1 files changed, 12 insertions, 5 deletions
diff --git a/test/etc/test_etc.rb b/test/etc/test_etc.rb
index c4db71cdf4..b73a95f995 100644
--- a/test/etc/test_etc.rb
+++ b/test/etc/test_etc.rb
@@ -28,11 +28,18 @@ class TestEtc < Test::Unit::TestCase
end
def test_getpwuid
- passwd = {}
- Etc.passwd {|s| passwd[s.uid] ||= s }
- passwd.each_value do |s|
- assert_equal(s, Etc.getpwuid(s.uid))
- assert_equal(s, Etc.getpwuid) if Process.euid == s.uid
+ # password database is not unique on UID, and which entry will be
+ # returned by getpwuid() is not specified.
+ passwd = Hash.new {[]}
+ # on MacOSX, same entries are returned from /etc/passwd and Open
+ # Directory.
+ Etc.passwd {|s| passwd[s.uid] |= [s]}
+ passwd.each_pair do |uid, s|
+ assert_include(s, Etc.getpwuid(uid))
+ end
+ s = passwd[Process.euid]
+ if s
+ assert_include(s, Etc.getpwuid)
end
end