check statfs and skip
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
482dd826ee
commit
82b69180aa
@ -1666,6 +1666,22 @@ class TestIO < Test::Unit::TestCase
|
|||||||
}
|
}
|
||||||
end
|
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
|
def test_seek
|
||||||
make_tempfile {|t|
|
make_tempfile {|t|
|
||||||
@ -1692,6 +1708,7 @@ class TestIO < Test::Unit::TestCase
|
|||||||
|
|
||||||
if defined?(IO::SEEK_DATA)
|
if defined?(IO::SEEK_DATA)
|
||||||
open(t.path) { |f|
|
open(t.path) { |f|
|
||||||
|
break unless can_seek_data(f)
|
||||||
assert_equal("foo\n", f.gets)
|
assert_equal("foo\n", f.gets)
|
||||||
assert_nothing_raised("cannot SEEK_DATA on FS(0x%X)" % f.statfs.type) do
|
assert_nothing_raised("cannot SEEK_DATA on FS(0x%X)" % f.statfs.type) do
|
||||||
f.seek(0, IO::SEEK_DATA)
|
f.seek(0, IO::SEEK_DATA)
|
||||||
@ -1699,6 +1716,7 @@ class TestIO < Test::Unit::TestCase
|
|||||||
assert_equal("foo\nbar\nbaz\n", f.read)
|
assert_equal("foo\nbar\nbaz\n", f.read)
|
||||||
}
|
}
|
||||||
open(t.path, 'r+') { |f|
|
open(t.path, 'r+') { |f|
|
||||||
|
break unless can_seek_data(f)
|
||||||
pos = f.pos
|
pos = f.pos
|
||||||
f.seek(100*1024, IO::SEEK_SET)
|
f.seek(100*1024, IO::SEEK_SET)
|
||||||
f.print("zot\n")
|
f.print("zot\n")
|
||||||
@ -1740,6 +1758,7 @@ class TestIO < Test::Unit::TestCase
|
|||||||
|
|
||||||
if defined?(IO::SEEK_DATA)
|
if defined?(IO::SEEK_DATA)
|
||||||
open(t.path) { |f|
|
open(t.path) { |f|
|
||||||
|
break unless can_seek_data(f)
|
||||||
assert_equal("foo\n", f.gets)
|
assert_equal("foo\n", f.gets)
|
||||||
assert_nothing_raised("cannot SEEK_DATA on FS(0x%X)" % f.statfs.type) do
|
assert_nothing_raised("cannot SEEK_DATA on FS(0x%X)" % f.statfs.type) do
|
||||||
f.seek(0, :DATA)
|
f.seek(0, :DATA)
|
||||||
@ -1747,6 +1766,7 @@ class TestIO < Test::Unit::TestCase
|
|||||||
assert_equal("foo\nbar\nbaz\n", f.read)
|
assert_equal("foo\nbar\nbaz\n", f.read)
|
||||||
}
|
}
|
||||||
open(t.path, 'r+') { |f|
|
open(t.path, 'r+') { |f|
|
||||||
|
break unless can_seek_data(f)
|
||||||
pos = f.pos
|
pos = f.pos
|
||||||
f.seek(100*1024, :SET)
|
f.seek(100*1024, :SET)
|
||||||
f.print("zot\n")
|
f.print("zot\n")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user