[前][次][番号順一覧][スレッド一覧]

ruby-changes:24782

From: shirosaki <ko1@a...>
Date: Mon, 27 Aug 2012 20:57:56 +0900 (JST)
Subject: [ruby-changes:24782] shirosaki:r36833 (trunk): test_etc.rb: fix for non unique GID

shirosaki	2012-08-27 20:57:43 +0900 (Mon, 27 Aug 2012)

  New Revision: 36833

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36833

  Log:
    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]

  Modified files:
    trunk/ChangeLog
    trunk/test/etc/test_etc.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36832)
+++ ChangeLog	(revision 36833)
@@ -1,3 +1,10 @@
+Mon Aug 27 20:19:49 2012  Hiroshi Shirosaki  <h.shirosaki@g...>
+
+	* 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]
+
 Mon Aug 27 18:19:36 2012  Koichi Sasada  <ko1@a...>
 
 	* include/ruby/ruby.h (rb_float_value): optimize it.
Index: test/etc/test_etc.rb
===================================================================
--- test/etc/test_etc.rb	(revision 36832)
+++ test/etc/test_etc.rb	(revision 36833)
@@ -76,13 +76,18 @@
   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
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]