From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS47066 71.19.144.0/20 X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00, MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.kgio.general Subject: test fixes pushed to master on kgio.git Date: Wed, 4 Sep 2013 00:12:50 +0000 Message-ID: <20130904001250.GA13569@dcvr.yhbt.net> References: <20130904001250.GA13569@dcvr.yhbt.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1378253584 30363 80.91.229.3 (4 Sep 2013 00:13:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 4 Sep 2013 00:13:04 +0000 (UTC) To: kgio@librelist.org Original-X-From: kgio@librelist.org Wed Sep 04 02:13:08 2013 Return-path: Envelope-to: gclrkg-kgio@m.gmane.org In-Reply-To: <20130904001250.GA13569@dcvr.yhbt.net> List-Archive: List-Help: List-Id: List-Post: List-Subscribe: List-Unsubscribe: Precedence: list Original-Sender: kgio@librelist.org Xref: news.gmane.org gmane.comp.lang.ruby.kgio.general:203 Archived-At: Received: from zedshaw2.xen.prgmr.com ([71.19.156.177]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VH0iY-00043T-Tt for gclrkg-kgio@m.gmane.org; Wed, 04 Sep 2013 02:13:07 +0200 Received: from zedshaw2.xen.prgmr.com (unknown [IPv6:::1]) by zedshaw2.xen.prgmr.com (Postfix) with ESMTP id 6952973E0A for ; Wed, 4 Sep 2013 00:22:03 +0000 (UTC) All should be pretty obvious, full diff below: Eric Wong (4): test_tryopen: skip EACCES test when euid == 0 test/lib_read_write: account for larger-than-normal pipes test_poll: avoid potentially thread-unsafe test test_poll: preserve original trap(:USR1) handler test/lib_read_write.rb | 10 ++++++---- test/test_poll.rb | 10 ++++++---- test/test_tryopen.rb | 7 ++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/test/lib_read_write.rb b/test/lib_read_write.rb index 7df9a79..5034db8 100644 --- a/test/lib_read_write.rb +++ b/test/lib_read_write.rb @@ -456,10 +456,12 @@ def test_trywrite_wait_readable_method def @wr.kgio_wait_writable raise "Hello" end - tmp = [] - buf = "." * 1024 - 10000.times { tmp << @wr.kgio_trywrite(buf) } - assert_equal :wait_writable, tmp.pop + buf = "." * 4096 + rv = nil + until rv == :wait_writable + rv = @wr.kgio_trywrite(buf) + end + assert_equal :wait_writable, rv end def test_wait_writable_method diff --git a/test/test_poll.rb b/test/test_poll.rb index 3aa8c1f..5bfc70b 100644 --- a/test/test_poll.rb +++ b/test/test_poll.rb @@ -89,11 +89,13 @@ def test_poll_EINTR def test_poll_EINTR_changed ok = false - orig = trap(:USR1) { ok = true } pollset = { @rd => Kgio::POLLIN } + orig = trap(:USR1) do + pollset[@wr] = Kgio::POLLOUT + ok = true + end thr = Thread.new do sleep 0.100 - pollset[@wr] = Kgio::POLLOUT Process.kill(:USR1, $$) end t0 = Time.now @@ -112,7 +114,7 @@ def test_poll_signal_torture empty = 0 nr = 100 set = { @rd => Kgio::POLLIN } - trap(:USR1) { usr1 += 1 } + orig = trap(:USR1) { usr1 += 1 } pid = fork do trap(:USR1, "DEFAULT") sleep 0.1 @@ -127,6 +129,6 @@ def test_poll_signal_torture assert status.success?, status.inspect assert usr1 > 0, "usr1: #{usr1}" ensure - trap(:USR1, "DEFAULT") + trap(:USR1, orig) end unless RUBY_PLATFORM =~ /kfreebsd-gnu/ end if Kgio.respond_to?(:poll) diff --git a/test/test_tryopen.rb b/test/test_tryopen.rb index 8a8278c..abcbd37 100644 --- a/test/test_tryopen.rb +++ b/test/test_tryopen.rb @@ -30,7 +30,12 @@ def test_tryopen_EACCES tmp = Tempfile.new "tryopen" File.chmod 0000, tmp.path tmp = Kgio::File.tryopen(tmp.path) - assert_equal(:EACCES, tmp) + if Process.euid == 0 + assert_kind_of Kgio::File, tmp + warn "cannot test EACCES when euid == 0" + else + assert_equal(:EACCES, tmp) + end end def test_tryopen_readwrite -- Eric Wong