[前][次][番号順一覧][スレッド一覧]

ruby-changes:19221

From: kosaki <ko1@a...>
Date: Mon, 11 Apr 2011 21:51:01 +0900 (JST)
Subject: [ruby-changes:19221] Ruby:r31260 (trunk): * test/ruby/test_io.rb: Added TestIO#test_cross_thread_close_stdio

kosaki	2011-04-11 21:50:55 +0900 (Mon, 11 Apr 2011)

  New Revision: 31260

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31260

  Log:
    * test/ruby/test_io.rb: Added TestIO#test_cross_thread_close_stdio
      and TestIO#test_cross_thread_close_fd.
      The patch was written by Eric Wong. [ruby-core:35669]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_io.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 31259)
+++ ChangeLog	(revision 31260)
@@ -1,3 +1,9 @@
+Mon Apr 11 21:49:18 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* test/ruby/test_io.rb: Added TestIO#test_cross_thread_close_stdio
+	  and TestIO#test_cross_thread_close_fd.
+	  The patch was written by Eric Wong. [ruby-core:35669]
+
 Mon Apr 11 21:15:54 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* file.c (rb_group_member): kill 256K of stack usage.
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 31259)
+++ test/ruby/test_io.rb	(revision 31260)
@@ -1809,4 +1809,43 @@
       Process.waitpid2(pid)
     end
   end
+
+  def test_cross_thread_close_fd
+    with_pipe do |r,w|
+      read_thread = Thread.new do
+        begin
+          r.read(1)
+        rescue => e
+          e
+        end
+      end
+
+      sleep(0.1) until read_thread.stop?
+      r.close
+      read_thread.join
+      assert_kind_of(IOError, read_thread.value)
+    end
+  end
+
+  def test_cross_thread_close_stdio
+    with_pipe do |r,w|
+      pid = fork do
+        $stdin.reopen(r)
+        r.close
+        read_thread = Thread.new do
+          begin
+            $stdin.read(1)
+          rescue => e
+            e
+          end
+        end
+        sleep(0.1) until read_thread.stop?
+        $stdin.close
+        read_thread.join
+        exit(IOError === read_thread.value)
+      end
+      assert Process.waitpid2(pid)[1].success?
+    end
+    rescue NotImplementedError
+  end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]