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

ruby-changes:33920

From: akr <ko1@a...>
Date: Sun, 18 May 2014 17:45:44 +0900 (JST)
Subject: [ruby-changes:33920] akr:r46001 (trunk): Use Etc.uname instead of uname command invocation.

akr	2014-05-18 17:45:37 +0900 (Sun, 18 May 2014)

  New Revision: 46001

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

  Log:
    Use Etc.uname instead of uname command invocation.

  Modified files:
    trunk/test/ruby/test_io.rb
    trunk/test/ruby/test_sleep.rb
    trunk/test/socket/test_socket.rb
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 46000)
+++ test/ruby/test_io.rb	(revision 46001)
@@ -1673,14 +1673,14 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1673
       when 0x9123683E # BTRFS_SUPER_MAGIC
       when 0x7461636f # OCFS2_SUPER_MAGIC
       when 0xEF53 # EXT2_SUPER_MAGIC EXT3_SUPER_MAGIC EXT4_SUPER_MAGIC
-        return false if (`/bin/uname -r`.split('.').map(&:to_i) <=> [3,8]) < 0
+        return false if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,8]) < 0
         # ext3's timestamp resolution is seconds
         s = f.stat
         s.mtime.nsec != 0 || s.atime.nsec != 0 || s.ctime.nsec != 0
       when 0x58465342 # XFS_SUPER_MAGIC
-        return false if (`/bin/uname -r`.split('.').map(&:to_i) <=> [3,5]) < 0
+        return false if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,5]) < 0
       when 0x01021994 # TMPFS_MAGIC
-        return false if (`/bin/uname -r`.split('.').map(&:to_i) <=> [3,8]) < 0
+        return false if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,8]) < 0
       else
         return false
       end
Index: test/ruby/test_sleep.rb
===================================================================
--- test/ruby/test_sleep.rb	(revision 46000)
+++ test/ruby/test_sleep.rb	(revision 46001)
@@ -1,4 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_sleep.rb#L1
 require 'test/unit'
+require 'etc'
 
 class TestSleep < Test::Unit::TestCase
   def test_sleep_5sec
@@ -9,7 +10,7 @@ class TestSleep < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_sleep.rb#L10
     bottom =
       case RUBY_PLATFORM
       when /linux/
-        4.98 if /Linux ([\d.]+)/ =~ `uname -sr` && ($1.split('.').map(&:to_i)<=>[2,6,18])<1
+        4.98 if (Etc.uname[:release].split('.').map(&:to_i)<=>[2,6,18]) <= 0
       when /mswin|mingw/
         4.98
       end
Index: test/socket/test_socket.rb
===================================================================
--- test/socket/test_socket.rb	(revision 46000)
+++ test/socket/test_socket.rb	(revision 46001)
@@ -2,6 +2,7 @@ begin https://github.com/ruby/ruby/blob/trunk/test/socket/test_socket.rb#L2
   require "socket"
   require "tmpdir"
   require "fcntl"
+  require "etc"
   require "test/unit"
 rescue LoadError
 end
@@ -332,7 +333,7 @@ class TestSocket < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/socket/test_socket.rb#L333
         case RUBY_PLATFORM
         when /linux/
           if ai.ip_address.include?('%') and
-            (`uname -r`[/[0-9.]+/].split('.').map(&:to_i) <=> [2,6,18]) <= 0
+            (Etc.uname[:release][/[0-9.]+/].split('.').map(&:to_i) <=> [2,6,18]) <= 0
             # Cent OS 5.6 (2.6.18-238.19.1.el5xen) doesn't correctly work
             # sendmsg with pktinfo for link-local ipv6 addresses
             next true

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

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