Project

General

Profile

Actions

Bug #9789

closed

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

Added by ngoto (Naohisa Goto) almost 10 years ago. Updated almost 10 years ago.

Status:
Closed
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 1 (0 open1 closed)

Related to Ruby master - Feature #9772: IO#statfs and File::StatfsRejectedmatz (Yukihiro Matsumoto)04/24/2014Actions

Updated by ngoto (Naohisa Goto) almost 10 years ago

Updated by nobu (Nobuyoshi Nakada) almost 10 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)

Updated by ngoto (Naohisa Goto) almost 10 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

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

Updated by nobu (Nobuyoshi Nakada) almost 10 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. [ruby-dev:48154] [Bug #9789]

Updated by ngoto (Naohisa Goto) almost 10 years ago

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

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0