ruby-changes:33585
From: naruse <ko1@a...>
Date: Tue, 22 Apr 2014 21:55:22 +0900 (JST)
Subject: [ruby-changes:33585] naruse:r45666 (trunk): check statfs and skip
naruse 2014-04-22 21:55:16 +0900 (Tue, 22 Apr 2014) New Revision: 45666 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45666 Log: check statfs and skip Modified files: trunk/test/ruby/test_io.rb Index: test/ruby/test_io.rb =================================================================== --- test/ruby/test_io.rb (revision 45665) +++ test/ruby/test_io.rb (revision 45666) @@ -1666,6 +1666,22 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1666 } end + def can_seek_data(f) + if /linux/ =~ RUBY_PLATFORM + # include/uapi/linux/magic.h + case f.statfs.type + when 0x9123683E # BTRFS_SUPER_MAGIC + when 0x7461636f # OCFS2_SUPER_MAGIC + when 0xEF53 # EXT4_SUPER_MAGIC + when 0x58465342 # XFS_SUPER_MAGIC + when 0x01021994 # TMPFS_MAGIC + else + return false + end + end + true + end + def test_seek make_tempfile {|t| @@ -1692,6 +1708,7 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1708 if defined?(IO::SEEK_DATA) open(t.path) { |f| + break unless can_seek_data(f) assert_equal("foo\n", f.gets) assert_nothing_raised("cannot SEEK_DATA on FS(0x%X)" % f.statfs.type) do f.seek(0, IO::SEEK_DATA) @@ -1699,6 +1716,7 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1716 assert_equal("foo\nbar\nbaz\n", f.read) } open(t.path, 'r+') { |f| + break unless can_seek_data(f) pos = f.pos f.seek(100*1024, IO::SEEK_SET) f.print("zot\n") @@ -1740,6 +1758,7 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1758 if defined?(IO::SEEK_DATA) open(t.path) { |f| + break unless can_seek_data(f) assert_equal("foo\n", f.gets) assert_nothing_raised("cannot SEEK_DATA on FS(0x%X)" % f.statfs.type) do f.seek(0, :DATA) @@ -1747,6 +1766,7 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1766 assert_equal("foo\nbar\nbaz\n", f.read) } open(t.path, 'r+') { |f| + break unless can_seek_data(f) pos = f.pos f.seek(100*1024, :SET) f.print("zot\n") -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/