summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-22 10:39:48 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-22 10:39:48 +0000
commit210f863906c34ad524007abb3b045d4b3cba98b1 (patch)
tree5b8a152a0dc10635d17f62eb5cae727320b12b2b /test/ruby
parentfa244db49b16d05c0042e01ef8faa9190acc5922 (diff)
revert File::Statfs [Feature #9772]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_file.rb27
-rw-r--r--test/ruby/test_io.rb38
2 files changed, 16 insertions, 49 deletions
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb
index 8906e15ad0..01992a83d4 100644
--- a/test/ruby/test_file.rb
+++ b/test/ruby/test_file.rb
@@ -383,31 +383,4 @@ class TestFile < Test::Unit::TestCase
assert_file.not_exist?(path)
end
end
-
- def test_statfs
- skip "not implemented" unless $stdout.respond_to?(:statfs)
- open(__FILE__) do |f|
- st = f.statfs
- assert_kind_of File::Statfs, st
- begin
- assert_kind_of Integer, st.type
- rescue NotImplementedError
- end
- assert_kind_of Integer, st.bsize
- assert_kind_of Integer, st.blocks
- assert_kind_of Integer, st.bfree
- assert_kind_of Integer, st.bavail
- assert_kind_of Integer, st.files
- assert_kind_of Integer, st.ffree
- begin
- assert_kind_of String, st.fstypename
- rescue NotImplementedError
- end
- s = st.inspect
- assert_match(/\A\#<File::Statfs\b.*>\z/, s)
- assert_match(/\bbsize=\d+\b/, s)
- assert_match(/\bblocks=(?:\d+[,>\/])+\b/, s)
- assert_match(/\bfiles=(?:\d+[,>\/])+\b/, s)
- end
- end
end
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 1324a2c2fa..79a4bb4599 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1668,24 +1668,22 @@ class TestIO < Test::Unit::TestCase
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 # EXT2_SUPER_MAGIC EXT3_SUPER_MAGIC EXT4_SUPER_MAGIC
- 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 (Etc.uname[:release].split('.').map(&:to_i) <=> [3,5]) < 0
- when 0x01021994 # TMPFS_MAGIC
- return false if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,8]) < 0
- else
- return false
+ require "-test-/file"
+ # lseek(2)
+ case Bug::File::Fs.fsname(f.path)
+ when "btrfs"
+ return true if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,1]) >= 0
+ when "ocfs"
+ return true if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,2]) >= 0
+ when "xfs"
+ return true if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,5]) >= 0
+ when "ext4"
+ return true if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,8]) >= 0
+ when "tmpfs"
+ return true if (Etc.uname[:release].split('.').map(&:to_i) <=> [3,8]) >= 0
end
end
- true
+ false
end
def test_seek
@@ -1715,9 +1713,7 @@ class TestIO < Test::Unit::TestCase
open(t.path) { |f|
break unless can_seek_data(f)
assert_equal("foo\n", f.gets)
- assert_nothing_raised(proc {"cannot SEEK_DATA on FS(0x%X)" % f.statfs.type}) do
- f.seek(0, IO::SEEK_DATA)
- end
+ f.seek(0, IO::SEEK_DATA)
assert_equal("foo\nbar\nbaz\n", f.read)
}
open(t.path, 'r+') { |f|
@@ -1765,9 +1761,7 @@ class TestIO < Test::Unit::TestCase
open(t.path) { |f|
break unless can_seek_data(f)
assert_equal("foo\n", f.gets)
- assert_nothing_raised(proc {"cannot SEEK_DATA on FS(0x%X)" % f.statfs.type}) do
- f.seek(0, :DATA)
- end
+ f.seek(0, :DATA)
assert_equal("foo\nbar\nbaz\n", f.read)
}
open(t.path, 'r+') { |f|