ruby-changes:38167
From: akr <ko1@a...>
Date: Sun, 12 Apr 2015 09:58:00 +0900 (JST)
Subject: [ruby-changes:38167] akr:r50248 (trunk): * test/ruby/test_file_exhaustive.rb: Test a block device on GNU/Linux.
akr 2015-04-12 09:57:49 +0900 (Sun, 12 Apr 2015) New Revision: 50248 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50248 Log: * test/ruby/test_file_exhaustive.rb: Test a block device on GNU/Linux. Modified files: trunk/ChangeLog trunk/test/ruby/test_file_exhaustive.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 50247) +++ ChangeLog (revision 50248) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Apr 12 09:57:16 2015 Tanaka Akira <akr@f...> + + * test/ruby/test_file_exhaustive.rb: Test a block device on GNU/Linux. + Sun Apr 12 09:24:03 2015 Tanaka Akira <akr@f...> * test/ruby/test_file_exhaustive.rb: Test a file not owned. Index: test/ruby/test_file_exhaustive.rb =================================================================== --- test/ruby/test_file_exhaustive.rb (revision 50247) +++ test/ruby/test_file_exhaustive.rb (revision 50248) @@ -155,6 +155,20 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L155 @chardev 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 file = regular_file @@ -272,10 +286,11 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L286 assert_file.socket?(socket) if socket end - def test_blockdev_p ## xxx + def test_blockdev_p assert_file.not_blockdev?(@dir) assert_file.not_blockdev?(regular_file) assert_file.not_blockdev?(nofile) + assert_file.blockdev?(blockdev) if blockdev end def test_chardev_p @@ -1119,6 +1134,7 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L1134 symlinkfile, hardlinkfile, chardev, + blockdev, fifo, socket ].compact.each do |f| @@ -1245,9 +1261,10 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L1261 assert(File::Stat.new(socket).socket?) if socket end - def test_stat_blockdev_p ## xxx + def test_stat_blockdev_p assert(!(File::Stat.new(@dir).blockdev?)) assert(!(File::Stat.new(regular_file).blockdev?)) + assert(File::Stat.new(blockdev).blockdev?) if blockdev end def test_stat_chardev_p -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/