From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.6 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EC13920323 for ; Sat, 18 Mar 2017 08:11:25 +0000 (UTC) From: Eric Wong 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 Message-Id: <20170318081125.23820-1-e@80x24.org> List-Id: 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