From: Eric Wong <e@80x24.org>
To: ruby-posix-mq@bogomips.org
Subject: [PATCH] test_posix_mq: get tests passing under FreeBSD 10.3
Date: Sat, 18 Mar 2017 08:11:25 +0000 [thread overview]
Message-ID: <20170318081125.23820-1-e@80x24.org> (raw)
Apparently POSIX message queues adopted close-on-fork behavior
in FreeBSD at some point. Oh well, somebody else who is more
interested in FreeBSD than can look into fixing it on their end.
Improve exception reporting a bit while we're at it.
---
test/test_posix_mq.rb | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/test/test_posix_mq.rb b/test/test_posix_mq.rb
index e831012..843b65e 100644
--- a/test/test_posix_mq.rb
+++ b/test/test_posix_mq.rb
@@ -303,9 +303,10 @@ class Test_POSIX_MQ < Test::Unit::TestCase
begin
@mq.notify = :USR1
rescue Errno::EBUSY
- exit 0
+ exit!(0)
rescue => e
- p e
+ exit!(0) if Errno::EBADF === e && RUBY_PLATFORM =~ /freebsd/
+ warn "#{e.message} (#{e.class})\n"
end
exit! 1
end
@@ -326,14 +327,28 @@ class Test_POSIX_MQ < Test::Unit::TestCase
end
def test_setattr_fork
+ return if RUBY_PLATFORM !~ /freebsd/
@mq = POSIX_MQ.new @path, IO::CREAT|IO::WRONLY, 0666
mq_attr = POSIX_MQ::Attr.new(IO::NONBLOCK)
@mq.attr = mq_attr
assert @mq.nonblock?
- pid = fork { @mq.nonblock = false }
- assert Process.waitpid2(pid)[1].success?
- assert ! @mq.nonblock?
+ pid = fork do
+ begin
+ @mq.nonblock = false
+ rescue => e
+ exit!(2) if Errno::EBADF === e && RUBY_PLATFORM =~ /freebsd/
+ warn "#{e.message} (#{e.class})\n"
+ exit!(1)
+ end
+ exit!(0)
+ end
+ _, status = Process.waitpid2(pid)
+ if status.success?
+ assert ! @mq.nonblock?
+ else
+ assert_equal 2, status.exitstatus
+ end
end
def test_new_nonblocking
--
EW
reply other threads:[~2017-03-18 8:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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/ruby_posix_mq/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170318081125.23820-1-e@80x24.org \
--to=e@80x24.org \
--cc=ruby-posix-mq@bogomips.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/ruby_posix_mq.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).