* [PATCH] test_posix_mq: get tests passing under FreeBSD 10.3
@ 2017-03-18 8:11 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2017-03-18 8:11 UTC (permalink / raw)
To: ruby-posix-mq
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-03-18 8:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-18 8:11 [PATCH] test_posix_mq: get tests passing under FreeBSD 10.3 Eric Wong
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).