Fix hang when running tests on OpenBSD by skipping two tests

Jeremy Evans jeremyevans0 at gmail.com
Tue Nov 15 15:03:49 EST 2011


On Tue, Nov 15, 2011 at 4:17 AM, Eric Wong <normalperson at yhbt.net> wrote:
> I usually prefer to work on each problem, one-at-a-time.  However,
> GNU make already has a handy -k/--keep-going flag to ignore failures.

Thanks, I didn't know about that, and it is much easier than patching
make files.

I think I've fixed all the issues that caused test failures on
OpenBSD.  All changes are in the test code itself.  Hope this helps.
Sorry if gmail mangles these diffs.

Thanks,
Jeremy

expr on OpenBSD uses a basic regular expression (according to
re_format(7)), which doesn't support +, only *.

--- t/t0011-active-unix-socket.sh.orig  Tue Nov 15 20:28:37 2011
+++ t/t0011-active-unix-socket.sh       Tue Nov 15 20:28:54 2011
@@ -7,7 +7,7 @@ read_pid_unix () {
            socat - UNIX:$unix_socket | \
            tail -1)
        test -n "$x"
-       y="$(expr "$x" : '\([0-9]\+\)')"
+       y="$(expr "$x" : '\([0-9][0-9]*\)')"
        test x"$x" = x"$y"
        test -n "$y"
        echo "$y"

I assume you aren't purposely testing a large timeout here, so
hopefully this change is fine.  The original code caused an infinite
loop on OpenBSD, and also taking up all available space on the file
system if you let it run long enough because it wrote to the log
inside the loop.  On 1.8.7:

E, [2011-11-15T18:55:34.616397 #11092] ERROR -- : master loop error:
time + 2147483646.000000 out of Time range (RangeError)
E, [2011-11-15T18:55:34.616538 #11092] ERROR -- :
/usr/obj/ports/unicorn-4.1.1/unicorn-4.1.1/t/../test/ruby-1.8.7/lib/unicorn/http_server.rb:264:in
`+'
E, [2011-11-15T18:55:34.616611 #11092] ERROR -- :
/usr/obj/ports/unicorn-4.1.1/unicorn-4.1.1/t/../test/ruby-1.8.7/lib/unicorn/http_server.rb:264:in
`join'
E, [2011-11-15T18:55:34.616686 #11092] ERROR -- :
/usr/obj/ports/unicorn-4.1.1/unicorn-4.1.1/t/../test/ruby-1.8.7/bin/unicorn:121

On 1.9.3:

E, [2011-11-15T19:00:20.464234 #13442] ERROR -- : listen loop error:
Invalid argument (Errno::EINVAL)
E, [2011-11-15T19:00:20.464327 #13442] ERROR -- :
/usr/local/lib/ruby/gems/1.8/gems/unicorn-4.1.1/lib/unicorn/http_server.rb:620:in
`select'
E, [2011-11-15T19:00:20.464399 #13442] ERROR -- :
/usr/local/lib/ruby/gems/1.8/gems/unicorn-4.1.1/lib/unicorn/http_server.rb:620:in
`worker_loop'
E, [2011-11-15T19:00:20.464457 #13442] ERROR -- :
/usr/local/lib/ruby/gems/1.8/gems/unicorn-4.1.1/lib/unicorn/http_server.rb:485:in
`spawn_missing_workers'
E, [2011-11-15T19:00:20.464514 #13442] ERROR -- :
/usr/local/lib/ruby/gems/1.8/gems/unicorn-4.1.1/lib/unicorn/http_server.rb:135:in
`start'
E, [2011-11-15T19:00:20.464570 #13442] ERROR -- :
/usr/local/lib/ruby/gems/1.8/gems/unicorn-4.1.1/bin/unicorn:121
E, [2011-11-15T19:00:20.464626 #13442] ERROR -- :
/usr/local/bin/unicorn:19:in `load'
E, [2011-11-15T19:00:20.464681 #13442] ERROR -- : /usr/local/bin/unicorn:19

--- t/t0012-reload-empty-config.sh.orig Tue Nov 15 20:05:13 2011
+++ t/t0012-reload-empty-config.sh      Tue Nov 15 20:05:37 2011
@@ -9,7 +9,7 @@ t_begin "setup and start" && {
        cat >> $unicorn_config <<EOF
 logger Logger.new(STDOUT)
 preload_app true
-timeout 0x7fffffff
+timeout 0x7fffff
 worker_processes 2
 after_fork { |s,w| }
 \$dump_cfg = lambda { |fp,srv|

openssl sha1 on OpenBSD doesn't just spit out the hash:

$ openssl sha1 mocha.diff
SHA1(mocha.diff)= 4ea47d3cf9e4f1858a298a8a9f5a5671422971d5
$ sha1 -q mocha.diff
4ea47d3cf9e4f1858a298a8a9f5a5671422971d5

--- t/test-lib.sh.orig  Tue Nov 15 19:12:25 2011
+++ t/test-lib.sh       Tue Nov 15 19:38:05 2011
@@ -101,6 +101,7 @@ unicorn_wait_start () {

 rsha1 () {
        _cmd="$(which sha1sum 2>/dev/null || :)"
+       test -n "$_cmd" || _cmd="$(which sha1 2>/dev/null || :) -q"
        test -n "$_cmd" || _cmd="$(which openssl 2>/dev/null || :) sha1"
        test "$_cmd" != " sha1" || _cmd="$(which gsha1sum 2>/dev/null || :)"

You can listen on 0.0.0.0, but trying to connect to it doesn't work
well on OpenBSD.

--- test/test_helper.rb.orig    Tue Nov 15 20:43:39 2011
+++ test/test_helper.rb Tue Nov 15 20:46:17 2011
@@ -72,6 +72,7 @@ def hit(uris)
     res = nil

     if u.kind_of? String
+      u = 'http://127.0.0.1:8080/' if u == 'http://0.0.0.0:8080/'
       res = Net::HTTP.get(URI.parse(u))
     else
       url = URI.parse(u[0])


More information about the mongrel-unicorn mailing list