From: Eric Wong <normalperson@yhbt.net>
To: kgio@librelist.org
Subject: test fixes pushed to master on kgio.git
Date: Wed, 4 Sep 2013 00:12:50 +0000 [thread overview]
Message-ID: <20130904001250.GA13569@dcvr.yhbt.net> (raw)
In-Reply-To: <20130904001250.GA13569@dcvr.yhbt.net>
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
parent reply other threads:[~2013-09-04 0:13 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20130904001250.GA13569@dcvr.yhbt.net>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/kgio/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130904001250.GA13569@dcvr.yhbt.net \
--to=normalperson@yhbt.net \
--cc=kgio@librelist.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/kgio.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).