about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-03-10 20:34:31 +0000
committerEric Wong <e@80x24.org>2017-03-14 20:08:06 +0000
commit4ce6b00f75f1584aff088f6b4e6b15488331e582 (patch)
tree7812e3f9ce468c4d52a2dea1ea26b4746b2d5c69 /test
parentc0975d0c2faf0f9186399b452cc889ff9259eed6 (diff)
downloadunicorn-4ce6b00f75f1584aff088f6b4e6b15488331e582.tar.gz
On FreeBSD 10.3, the value of SO_KEEPALIVE returned by
getsockopt is 8, even when set to '1' via setsockopt.
Relax the test to only ensure the boolean value is
interpreted as "true".

Verified independently of Ruby using the following:
--------8<---------
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <stdio.h>

static int err(const char *msg)
{
	perror(msg);
	return 1;
}

int main(void)
{
	int sv[2];
	int set = 1;
	int got;
	socklen_t len = (socklen_t)sizeof(int);
	int rc;

	rc = socketpair(PF_LOCAL, SOCK_STREAM, 0, sv);
	if (rc) return err("socketpair failed");

	rc = setsockopt(sv[0], SOL_SOCKET, SO_KEEPALIVE, &set, len);
	if (rc) return err("setsockopt failed");

	rc = getsockopt(sv[0], SOL_SOCKET, SO_KEEPALIVE, &got, &len);
	if (rc) return err("getsockopt failed");

	printf("got: %d\n", got);
	return 0;
}
Diffstat (limited to 'test')
-rw-r--r--test/exec/test_exec.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/test/exec/test_exec.rb b/test/exec/test_exec.rb
index 4941c4e..08f92ae 100644
--- a/test/exec/test_exec.rb
+++ b/test/exec/test_exec.rb
@@ -143,7 +143,7 @@ run lambda { |env|
     res = hit(["http://#@addr:#@port/"])
     assert_equal [ "HI\n" ], res
     assert_shutdown(pid)
-    assert_equal 1, sock.getsockopt(:SOL_SOCKET, :SO_KEEPALIVE).int,
+    assert sock.getsockopt(:SOL_SOCKET, :SO_KEEPALIVE).bool,
                 'unicorn should always set SO_KEEPALIVE on inherited sockets'
   ensure
     sock.close if sock