From: Eric Wong <normalperson@yhbt.net>
To: kgio@librelist.org
Subject: Re: There's no TCP_NOPUSH in Solaris 10
Date: Mon, 19 Mar 2012 09:31:29 +0000 [thread overview]
Message-ID: <20120319093129.GA27611@dcvr.yhbt.net> (raw)
In-Reply-To: CAAtReCnE4cWnAS9SeFp7p=v15MxuAwvV91o7pfpd=wbqD8c2sg@mail.gmail.com
Edho Arief <edho@myconan.net> wrote:
> Forcing definition of them enables unicorn to work (at least seems to
> be working) but fails test (tried both Linux and BSD version):
Wait, this fails on Linux and *BSD, too? Which Ruby version and exactly
which OSes did you use?
> 1) Failure:
> test_wait_writable_ruby_default(TestUnixServerReadClientWrite)
> [/home/edho/git/kgio/test/lib_read_write.rb:289]:
> Exception raised:
> <Interrupt>.
>
> (it took long time so I stopped it)
I've removed my idiotic assert_nothing_raised usage in all tests to make
it easier to track down. Also pushed to bogomips.org/kgio.git
>From 74b9f78e11b915439555290dc3bdd4331303561c Mon Sep 17 00:00:00 2001
From: Eric Wong <normalperson@yhbt.net>
Date: Mon, 19 Mar 2012 06:05:06 +0000
Subject: [PATCH] test/*: remove assert_nothing_raised
It makes test failures hard to track down, tests will
already fail if exceptions are thrown and we'll get
nice backtraces.
---
test/lib_read_write.rb | 19 +++++++------------
test/test_accept_class.rb | 10 +++++-----
test/test_autopush.rb | 22 +++++++++-------------
test/test_connect_fd_leak.rb | 10 ++++------
test/test_poll.rb | 4 +---
test/test_singleton_read_write.rb | 2 +-
test/test_tryopen.rb | 2 +-
7 files changed, 28 insertions(+), 41 deletions(-)
diff --git a/test/lib_read_write.rb b/test/lib_read_write.rb
index d7f50c2..dfcba20 100644
--- a/test/lib_read_write.rb
+++ b/test/lib_read_write.rb
@@ -9,10 +9,8 @@ module LibReadWriteTest
RANDOM_BLOB = File.open("/dev/urandom") { |fp| fp.read(10 * 1024 * 1024) }
def teardown
- assert_nothing_raised do
- @rd.close if defined?(@rd) && ! @rd.closed?
- @wr.close if defined?(@wr) && ! @wr.closed?
- end
+ @rd.close if defined?(@rd) && ! @rd.closed?
+ @wr.close if defined?(@wr) && ! @wr.closed?
end
def test_write_empty
@@ -264,10 +262,8 @@ module LibReadWriteTest
foo = nil
t0 = Time.now
thr = Thread.new { sleep 1; @wr.write "HELLO" }
- assert_nothing_raised do
- foo = @rd.kgio_read(5)
- elapsed = Time.now - t0
- end
+ foo = @rd.kgio_read(5)
+ elapsed = Time.now - t0
assert elapsed >= 1.0, "elapsed: #{elapsed}"
assert_equal "HELLO", foo
thr.join
@@ -286,10 +282,9 @@ module LibReadWriteTest
foo = nil
t0 = Time.now
thr = Thread.new { sleep 1; @rd.readpartial(nr) }
- assert_nothing_raised do
- foo = @wr.kgio_write("HELLO")
- elapsed = Time.now - t0
- end
+ foo = @wr.kgio_write("HELLO")
+ elapsed = Time.now - t0
+
assert_nil foo
if @wr.stat.pipe?
assert elapsed >= 1.0, "elapsed: #{elapsed}"
diff --git a/test/test_accept_class.rb b/test/test_accept_class.rb
index cf59a2f..0e1d172 100644
--- a/test/test_accept_class.rb
+++ b/test/test_accept_class.rb
@@ -12,12 +12,12 @@ class TestAcceptClass < Test::Unit::TestCase
end
def teardown
- assert_nothing_raised { Kgio.accept_class = nil }
+ Kgio.accept_class = nil
assert_equal Kgio::Socket, Kgio.accept_class
end
def test_tcp_socket
- assert_nothing_raised { Kgio.accept_class = Kgio::TCPSocket }
+ Kgio.accept_class = Kgio::TCPSocket
assert_equal Kgio::TCPSocket, Kgio.accept_class
end
@@ -31,21 +31,21 @@ class TestAcceptClass < Test::Unit::TestCase
@srv = Kgio::TCPServer.new(@host, 0)
@port = @srv.addr[1]
- assert_nothing_raised { Kgio.accept_class = Kgio::TCPSocket }
+ Kgio.accept_class = Kgio::TCPSocket
client = TCPSocket.new(@host, @port)
assert_instance_of Kgio::TCPSocket, @srv.kgio_accept
client = TCPSocket.new(@host, @port)
IO.select([@srv])
assert_instance_of Kgio::TCPSocket, @srv.kgio_tryaccept
- assert_nothing_raised { Kgio.accept_class = nil }
+ Kgio.accept_class = nil
client = TCPSocket.new(@host, @port)
assert_instance_of Kgio::Socket, @srv.kgio_accept
client = TCPSocket.new(@host, @port)
IO.select([@srv])
assert_instance_of Kgio::Socket, @srv.kgio_tryaccept
- assert_nothing_raised { Kgio.accept_class = Kgio::UNIXSocket }
+ Kgio.accept_class = Kgio::UNIXSocket
client = TCPSocket.new(@host, @port)
assert_instance_of Kgio::UNIXSocket, @srv.kgio_accept
client = TCPSocket.new(@host, @port)
diff --git a/test/test_autopush.rb b/test/test_autopush.rb
index 57fbefa..6c6e05f 100644
--- a/test/test_autopush.rb
+++ b/test/test_autopush.rb
@@ -18,12 +18,10 @@ class TestAutopush < Test::Unit::TestCase
@host = ENV["TEST_HOST"] || '127.0.0.1'
@srv = Kgio::TCPServer.new(@host, 0)
- assert_nothing_raised {
+ RUBY_PLATFORM =~ /linux/ and
@srv.setsockopt(Socket::IPPROTO_TCP, TCP_CORK, 1)
- } if RUBY_PLATFORM =~ /linux/
- assert_nothing_raised {
+ RUBY_PLATFORM =~ /freebsd/ and
@srv.setsockopt(Socket::IPPROTO_TCP, TCP_NOPUSH, 1)
- } if RUBY_PLATFORM =~ /freebsd/
@port = @srv.addr[1]
end
@@ -35,7 +33,7 @@ class TestAutopush < Test::Unit::TestCase
assert ! s.kgio_autopush?
s.kgio_autopush = true
assert s.kgio_autopush?
- assert_nothing_raised { s.kgio_write 'asdf' }
+ s.kgio_write 'asdf'
assert_equal :wait_readable, s.kgio_tryread(1)
assert s.kgio_autopush?
val = s.getsockopt(Socket::IPPROTO_TCP, opt).unpack('i')[0]
@@ -64,12 +62,10 @@ class TestAutopush < Test::Unit::TestCase
lines = io.readlines
assert lines.grep(/TCP_CORK/).empty?, lines.inspect
else
- assert_nothing_raised do
- @wr = @srv.kgio_accept
- t0 = Time.now
- @wr.kgio_write "HI\n"
- rc = @wr.kgio_tryread 666
- end
+ @wr = @srv.kgio_accept
+ t0 = Time.now
+ @wr.kgio_write "HI\n"
+ rc = @wr.kgio_tryread 666
end
assert_equal "HI\n", @rd.kgio_read(3)
diff = Time.now - t0
@@ -151,8 +147,8 @@ class TestAutopush < Test::Unit::TestCase
lines = io.readlines
assert_equal 2, lines.grep(/TCP_CORK/).size, lines.inspect
end
- assert_nothing_raised { @wr.close }
- assert_nothing_raised { @rd.close }
+ @wr.close
+ @rd.close
@wr = Kgio::TCPSocket.new(@host, @port)
if defined?(Strace)
diff --git a/test/test_connect_fd_leak.rb b/test/test_connect_fd_leak.rb
index f6a8543..1dfc4cd 100644
--- a/test/test_connect_fd_leak.rb
+++ b/test/test_connect_fd_leak.rb
@@ -9,11 +9,9 @@ class TestConnectFDLeak < Test::Unit::TestCase
nr = 0
path = "/non/existent/path"
assert(! File.exist?(path), "#{path} should not exist")
- assert_nothing_raised do
- begin
- sock = Kgio::UNIXSocket.new(path)
- rescue Errno::ENOENT
- end while (nr += 1) < 10000
- end
+ begin
+ sock = Kgio::UNIXSocket.new(path)
+ rescue Errno::ENOENT
+ end while (nr += 1) < 10000
end
end
diff --git a/test/test_poll.rb b/test/test_poll.rb
index df59354..40092cf 100644
--- a/test/test_poll.rb
+++ b/test/test_poll.rb
@@ -122,9 +122,7 @@ class TestPoll < Test::Unit::TestCase
exit!(0)
end
- assert_nothing_raised do
- empty += 1 until Kgio.poll(set.dup, 100)
- end
+ empty += 1 until Kgio.poll(set.dup, 100)
_, status = Process.waitpid2(pid)
assert status.success?, status.inspect
assert usr1 > 0, "usr1: #{usr1}"
diff --git a/test/test_singleton_read_write.rb b/test/test_singleton_read_write.rb
index 5abbf00..86d30a2 100644
--- a/test/test_singleton_read_write.rb
+++ b/test/test_singleton_read_write.rb
@@ -6,7 +6,7 @@ class TestSingletonReadWrite < Test::Unit::TestCase
def test_unix_socketpair
a, b = UNIXSocket.pair
- assert_nothing_raised { Kgio.trywrite(a, "HELLO") }
+ Kgio.trywrite(a, "HELLO")
buf = ""
assert_equal "HELLO", Kgio.tryread(b, 5, buf)
assert_equal "HELLO", buf
diff --git a/test/test_tryopen.rb b/test/test_tryopen.rb
index 5a8efb2..80b5de3 100644
--- a/test/test_tryopen.rb
+++ b/test/test_tryopen.rb
@@ -15,7 +15,7 @@ class TestTryopen < Test::Unit::TestCase
assert_equal File.read(__FILE__), tmp.read
assert_equal __FILE__, tmp.path
assert_equal __FILE__, tmp.to_path
- assert_nothing_raised { tmp.close }
+ tmp.close
end
def test_tryopen_ENOENT
next prev parent reply other threads:[~2012-03-19 9:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-18 12:45 There's no TCP_NOPUSH in Solaris 10 Edho Arief
2012-03-19 9:29 ` Eric Wong
2012-03-19 9:31 ` Eric Wong [this message]
2012-03-19 9:35 ` Edho Arief
2012-03-19 9:52 ` Eric Wong
2012-03-19 10:10 ` Edho Arief
2012-03-19 20:09 ` Eric Wong
2012-03-20 10:53 ` Edho Arief
2012-03-21 20:15 ` Eric Wong
2012-03-22 1:48 ` Edho Arief
2012-03-22 8:38 ` Eric Wong
2012-03-22 15:00 ` Edho Arief
2012-03-23 21:15 ` Eric Wong
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=20120319093129.GA27611@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).