From: "nobu (Nobuyoshi Nakada)" Date: 2012-08-04T22:38:43+09:00 Subject: [ruby-core:46986] [ruby-trunk - Bug #6831][Feedback] test_getpwuid() on Mountain Lion Issue #6831 has been updated by nobu (Nobuyoshi Nakada). Status changed from Assigned to Feedback =begin Does this patch fix it? diff --git i/test/etc/test_etc.rb w/test/etc/test_etc.rb index c4db71c..b73a95f 100644 --- i/test/etc/test_etc.rb +++ w/test/etc/test_etc.rb @@ -29,9 +29,16 @@ class TestEtc < Test::Unit::TestCase 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 =end ---------------------------------------- Bug #6831: test_getpwuid() on Mountain Lion https://bugs.ruby-lang.org/issues/6831#change-28643 Author: kosaki (Motohiro KOSAKI) Status: Feedback Priority: Normal Assignee: mrkn (Kenta Murata) Category: ext Target version: 2.0.0 ruby -v: ruby 2.0.0dev (2012-08-04 trunk 36617) [x86_64-darwin12.0.0] When using Mountain Lion, following test failure occur. 1) Failure: test_getpwuid(TestEtc) [/ruby/git/test/etc/test_etc.rb:34]: <#> expected but was <#>. ------------------------------------------ getpwent() of Mountain Lion seems buggy. see below: test_getpwent.c ----------------------------------------- #include #include #include #include #include int main(void) { struct passwd *ent; while((ent = getpwent()) != NULL) { if (ent->pw_uid == 55) printf("%s:%d:%s\n", ent->pw_name, ent->pw_uid, ent->pw_gecos); } return 0; } result ---------------- _appleevents:55:AppleEvents Daemon _pcastagent:55:Podcast Producer Agent mrkn, what do you think? -- http://bugs.ruby-lang.org/