test_exec: SO_KEEPALIVE value only needs to be true
commit4ce6b00f75f1584aff088f6b4e6b15488331e582
authorEric Wong <e@80x24.org>
Fri, 10 Mar 2017 20:34:31 +0000 (10 20:34 +0000)
committerEric Wong <e@80x24.org>
Tue, 14 Mar 2017 20:08:06 +0000 (14 20:08 +0000)
tree7812e3f9ce468c4d52a2dea1ea26b4746b2d5c69
parentc0975d0c2faf0f9186399b452cc889ff9259eed6
test_exec: SO_KEEPALIVE value only needs to be true

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;
}
test/exec/test_exec.rb