* test/ruby/test_file_exhaustive.rb: Test a block device on GNU/Linux.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2015-04-12 00:57:49 +00:00
parent b850ec4680
commit 2722cb9ce1
2 changed files with 23 additions and 2 deletions

View File

@ -1,3 +1,7 @@
Sun Apr 12 09:57:16 2015 Tanaka Akira <akr@fsij.org>
* test/ruby/test_file_exhaustive.rb: Test a block device on GNU/Linux.
Sun Apr 12 09:24:03 2015 Tanaka Akira <akr@fsij.org> Sun Apr 12 09:24:03 2015 Tanaka Akira <akr@fsij.org>
* test/ruby/test_file_exhaustive.rb: Test a file not owned. * test/ruby/test_file_exhaustive.rb: Test a file not owned.

View File

@ -155,6 +155,20 @@ class TestFileExhaustive < Test::Unit::TestCase
@chardev @chardev
end end
def blockdev
return @blockdev if defined? @blockdev
if /linux/ =~ RUBY_PLATFORM
if File.exist? '/dev/loop0'
@blockdev = '/dev/loop0'
elsif File.exist? '/dev/sda'
@blockdev = '/dev/sda'
end
else
@blockdev = nil
end
@blockdev
end
def test_path def test_path
file = regular_file file = regular_file
@ -272,10 +286,11 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_file.socket?(socket) if socket assert_file.socket?(socket) if socket
end end
def test_blockdev_p ## xxx def test_blockdev_p
assert_file.not_blockdev?(@dir) assert_file.not_blockdev?(@dir)
assert_file.not_blockdev?(regular_file) assert_file.not_blockdev?(regular_file)
assert_file.not_blockdev?(nofile) assert_file.not_blockdev?(nofile)
assert_file.blockdev?(blockdev) if blockdev
end end
def test_chardev_p def test_chardev_p
@ -1119,6 +1134,7 @@ class TestFileExhaustive < Test::Unit::TestCase
symlinkfile, symlinkfile,
hardlinkfile, hardlinkfile,
chardev, chardev,
blockdev,
fifo, fifo,
socket socket
].compact.each do |f| ].compact.each do |f|
@ -1245,9 +1261,10 @@ class TestFileExhaustive < Test::Unit::TestCase
assert(File::Stat.new(socket).socket?) if socket assert(File::Stat.new(socket).socket?) if socket
end end
def test_stat_blockdev_p ## xxx def test_stat_blockdev_p
assert(!(File::Stat.new(@dir).blockdev?)) assert(!(File::Stat.new(@dir).blockdev?))
assert(!(File::Stat.new(regular_file).blockdev?)) assert(!(File::Stat.new(regular_file).blockdev?))
assert(File::Stat.new(blockdev).blockdev?) if blockdev
end end
def test_stat_chardev_p def test_stat_chardev_p