Project

General

Profile

Bug #9789

Error in TestIO#test_seek_symwhence and TestIO#test_seek on systems without File::Statfs#type (e.g. Solaris)

Added by ngoto (Naohisa Goto) about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 2.2.0dev (2014-04-30) [sparc64-solaris2.10]
[ruby-dev:48154]

Description

File::Statfs#type が無い(NotImplementedErrorになる)環境にて、
TestIO#test_seek_symwhence と TestIO#test_seek がエラーになります。
Solaris 10 (64ビット)、r45760 (+ Bug #9788 のパッチ)にて確認しました。

 52) Error:
TestIO#test_seek_symwhence:
NotImplementedError: type() function is unimplemented on this machine
    /XXXXXXXXXX/test/ruby/test_io.rb:1768:in `type'
    /XXXXXXXXXX/test/ruby/test_io.rb:1768:in `block (2 levels) in test_seek_symwhence'
    /XXXXXXXXXX/lib/open-uri.rb:36:in `open'
    /XXXXXXXXXX/lib/open-uri.rb:36:in `open'
    /XXXXXXXXXX/test/ruby/test_io.rb:1765:in `block in test_seek_symwhence'
    /XXXXXXXXXX/test/ruby/test_io.rb:1432:in `make_tempfile'
    /XXXXXXXXXX/test/ruby/test_io.rb:1747:in `test_seek_symwhence'

 53) Error:
TestIO#test_seek:
NotImplementedError: type() function is unimplemented on this machine
    /XXXXXXXXXX/test/ruby/test_io.rb:1718:in `type'
    /XXXXXXXXXX/test/ruby/test_io.rb:1718:in `block (2 levels) in test_seek'
    /XXXXXXXXXX/lib/open-uri.rb:36:in `open'
    /XXXXXXXXXX/lib/open-uri.rb:36:in `open'
    /XXXXXXXXXX/test/ruby/test_io.rb:1715:in `block in test_seek'
    /XXXXXXXXXX/test/ruby/test_io.rb:1432:in `make_tempfile'
    /XXXXXXXXXX/test/ruby/test_io.rb:1692:in `test_seek'

Related issues

Related to Ruby trunk - Feature #9772: IO#statfs and File::StatfsRejected2014-04-24

Associated revisions

Revision d1c03755
Added by nobu (Nobuyoshi Nakada) about 4 years ago

test_io.rb: defer f_type

  • test/ruby/test_io.rb (test_seek, test_seek_symwhence): defer File::Statfs#type call which may not be implemented, to mitigate errors on platforms where SEEK_DATA is available but f_type in struct statfs is not. [Bug #9789]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 45783
Added by nobu (Nobuyoshi Nakada) about 4 years ago

test_io.rb: defer f_type

  • test/ruby/test_io.rb (test_seek, test_seek_symwhence): defer File::Statfs#type call which may not be implemented, to mitigate errors on platforms where SEEK_DATA is available but f_type in struct statfs is not. [Bug #9789]

Revision 45783
Added by nobu (Nobuyoshi Nakada) about 4 years ago

test_io.rb: defer f_type

  • test/ruby/test_io.rb (test_seek, test_seek_symwhence): defer File::Statfs#type call which may not be implemented, to mitigate errors on platforms where SEEK_DATA is available but f_type in struct statfs is not. [Bug #9789]

Revision 45783
Added by nobu (Nobuyoshi Nakada) about 4 years ago

test_io.rb: defer f_type

  • test/ruby/test_io.rb (test_seek, test_seek_symwhence): defer File::Statfs#type call which may not be implemented, to mitigate errors on platforms where SEEK_DATA is available but f_type in struct statfs is not. [Bug #9789]

Revision 45783
Added by nobu (Nobuyoshi Nakada) about 4 years ago

test_io.rb: defer f_type

  • test/ruby/test_io.rb (test_seek, test_seek_symwhence): defer File::Statfs#type call which may not be implemented, to mitigate errors on platforms where SEEK_DATA is available but f_type in struct statfs is not. [Bug #9789]

Revision 45783
Added by nobu (Nobuyoshi Nakada) about 4 years ago

test_io.rb: defer f_type

  • test/ruby/test_io.rb (test_seek, test_seek_symwhence): defer File::Statfs#type call which may not be implemented, to mitigate errors on platforms where SEEK_DATA is available but f_type in struct statfs is not. [Bug #9789]

History

#1 [ruby-dev:48156] Updated by ngoto (Naohisa Goto) about 4 years ago

#2 [ruby-dev:48157] Updated by nobu (Nobuyoshi Nakada) about 4 years ago

  • Category set to core
  • Assignee set to ngoto (Naohisa Goto)
  • Target version set to 2.2.0
  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED

IO::SEEK_DATA自体はうごくんでしょうか。

diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index d2abd9e..5ed2ddd 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1715,7 +1715,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("cannot SEEK_DATA on FS(0x%X)" % f.statfs.type) do
+          assert_nothing_raised(proc {"cannot SEEK_DATA on FS(0x%X)" % f.statfs.type}) do
             f.seek(0, IO::SEEK_DATA)
           end
           assert_equal("foo\nbar\nbaz\n", f.read)
@@ -1765,7 +1765,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("cannot SEEK_DATA on FS(0x%X)" % f.statfs.type) do
+          assert_nothing_raised(proc {"cannot SEEK_DATA on FS(0x%X)" % f.statfs.type}) do
             f.seek(0, :DATA)
           end
           assert_equal("foo\nbar\nbaz\n", f.read)

#3 [ruby-dev:48158] Updated by ngoto (Naohisa Goto) about 4 years ago

IO::SEEK_DATA自体はうごくんでしょうか。

% dd if=/dev/zero of=/var/tmp/test.dat bs=512 count=10 seek=16384
% 
% ruby -e 'f = open("/var/tmp/test.dat"); f.seek(0, :DATA); p f.pos'
8388608
% ruby -e 'f = open("/var/tmp/test.dat"); f.seek(0, :HOLE); p f.pos'
0
% ruby -e 'p IO::SEEK_DATA; p IO::SEEK_HOLE'
3
4

ということで動いています。

#4 [ruby-dev:48164] Updated by nobu (Nobuyoshi Nakada) about 4 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r45783.


test_io.rb: defer f_type

  • test/ruby/test_io.rb (test_seek, test_seek_symwhence): defer File::Statfs#type call which may not be implemented, to mitigate errors on platforms where SEEK_DATA is available but f_type in struct statfs is not. [Bug #9789]

#5 [ruby-dev:48165] Updated by ngoto (Naohisa Goto) about 4 years ago

このパッチで、テストが通るようになりました。

何らかの原因でseekに失敗した時に、Procが呼ばれ、Solarisでは Statfs#type がNotImplementedError となり、(Failureではなく) Errorになる可能性は残ってはいますが、その機能自体が Feature #9772 の議論対象のため、結論を待ちます。

Also available in: Atom PDF