summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-02 08:57:44 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-02 08:57:44 +0000
commitfe18cd011c516a20dc60654e8559f699f54181e2 (patch)
treeb0481dfba1393b2b5f0d00f2826ae7adb97d2882
parent253bd7b103aafa3a21e850a4522dc280d598a844 (diff)
test_advice show OS and filesystem when failed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_io.rb37
1 files changed, 36 insertions, 1 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index c3544b930ae..e12cf4adabe 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2447,13 +2447,48 @@ End
}
end
+ def os_and_fs(path)
+ uname = Etc.uname
+ os = "#{uname[:sysname]} #{uname[:release]}"
+
+ fs = nil
+ if uname[:sysname] == 'Linux'
+ # [ruby-dev:45703] Old Linux's fadvice() doesn't work on tmpfs.
+ mount = `mount`
+ mountpoints = []
+ mount.scan(/ on (\S+) type (\S+) /) {
+ mountpoints << [$1, $2]
+ }
+ mountpoints.sort_by {|mountpoint, fstype| mountpoint.length }.reverse_each {|mountpoint, fstype|
+ if path == mountpoint
+ fs = fstype
+ break
+ end
+ mountpoint += "/" if %r{/\z} !~ mountpoint
+ if path.start_with?(mountpoint)
+ fs = fstype
+ break
+ end
+ }
+ end
+
+ if fs
+ "#{fs} on #{os}"
+ else
+ os
+ end
+ end
+
def test_advise
make_tempfile {|tf|
assert_raise(ArgumentError, "no arguments") { tf.advise }
%w{normal random sequential willneed dontneed noreuse}.map(&:to_sym).each do |adv|
[[0,0], [0, 20], [400, 2]].each do |offset, len|
open(tf.path) do |t|
- assert_nil(t.advise(adv, offset, len))
+ ret = assert_nothing_raised(lambda { os_and_fs(tf.path) }) {
+ t.advise(adv, offset, len)
+ }
+ assert_nil(ret)
assert_raise(ArgumentError, "superfluous arguments") do
t.advise(adv, offset, len, offset)
end