mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
253bd7b103
commit
fe18cd011c
1 changed files with 36 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue