Index: tests/sys/kern/unix_passfd_test.c =================================================================== --- tests/sys/kern/unix_passfd_test.c +++ tests/sys/kern/unix_passfd_test.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2005 Robert N. M. Watson + * Copyright (c) 2014 Mark Johnston * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,7 +34,7 @@ #include #include -#include +#include #include #include #include @@ -133,14 +134,14 @@ *(int *)(void *)CMSG_DATA(cmsghdr) = sendfd; len = sendmsg(sockfd, &msghdr, 0); - ATF_REQUIRE(len >= 0); - ATF_CHECK_EQ_MSG((size_t)len, paylen, "sendmsg: %zd bytes sent", len); + ATF_REQUIRE_MSG(len >= 0, "sendmsg failed: %s", strerror(errno)); + ATF_REQUIRE_EQ_MSG((size_t)len, paylen, "sendmsg: %zd bytes sent", len); } static void sendfd(int sockfd, int sendfd) { - char ch; + char ch = 0; return (sendfd_payload(sockfd, sendfd, &ch, sizeof(ch))); } @@ -166,11 +167,13 @@ msghdr.msg_iovlen = 1; len = recvmsg(sockfd, &msghdr, 0); - ATF_REQUIRE(len >= 0); - ATF_CHECK_EQ_MSG((size_t)len, buflen, "recvmsg: %zd bytes received", len); + ATF_REQUIRE_MSG(len >= 0, "recvmsg failed: %s", strerror(errno)); + ATF_REQUIRE_EQ_MSG((size_t)len, buflen, "recvmsg: %zd bytes received", + len); cmsghdr = CMSG_FIRSTHDR(&msghdr); - ATF_REQUIRE_MSG(cmsghdr != NULL, "recvmsg: did not receive control message"); + ATF_REQUIRE_MSG(cmsghdr != NULL, + "recvmsg: did not receive control message"); *recvfd = -1; for (; cmsghdr != NULL; cmsghdr = CMSG_NXTHDR(&msghdr, cmsghdr)) { @@ -188,7 +191,7 @@ static void recvfd(int sockfd, int *recvfd) { - char ch; + char ch = 0; return (recvfd_payload(sockfd, recvfd, &ch, sizeof(ch))); } @@ -324,7 +327,11 @@ * Test for PR 151758: Send an character device over the UNIX domain socket and * then close both sockets to orphan the device. */ -ATF_TC_WITHOUT_HEAD(devfs_orphan); +ATF_TC(devfs_orphan); +ATF_TC_HEAD(devfs_orphan, tc) +{ + atf_tc_set_md_var(tc, "descr", "PR 151758 regression test"); +} ATF_TC_BODY(devfs_orphan, tc) { int fd[2], putfd; @@ -341,21 +348,30 @@ * message to the data. Sender sends large payload. Payload + SCM_RIGHTS + * LOCAL_CREDS hit socket buffer limit, and receiver receives truncated data. */ -ATF_TC_WITHOUT_HEAD(rights_creds_payload); +ATF_TC(rights_creds_payload); +ATF_TC_HEAD(rights_creds_payload, tc) +{ + atf_tc_set_md_var(tc, "descr", "PR 181741 regression test"); +} ATF_TC_BODY(rights_creds_payload, tc) { void *buf; + const char *ss_sysctl = "net.local.stream.sendspace"; u_long sendspace; size_t len; const int on = 1; int fd[2], getfd, putfd; + atf_tc_expect_fail("PR 181741: Packet loss when 'control' messages " + "are present with large data"); + len = sizeof(sendspace); - ATF_REQUIRE_EQ(sysctlbyname("net.local.stream.sendspace", &sendspace, - &len, NULL, 0), 0); + ATF_REQUIRE_EQ_MSG(sysctlbyname(ss_sysctl, &sendspace, &len, NULL, 0), + 0, "sysctl %s: %s", ss_sysctl, strerror(errno)); buf = malloc(sendspace); ATF_REQUIRE(buf != NULL); + bzero(buf, sendspace); domainsocketpair(fd); ATF_REQUIRE_EQ(setsockopt(fd[1], 0, LOCAL_CREDS, &on, sizeof(on)), 0); @@ -364,6 +380,7 @@ recvfd_payload(fd[1], &getfd, buf, sendspace); ATF_REQUIRE_EQ(close(putfd), 0); ATF_REQUIRE_EQ(close(getfd), 0); + closesocketpair(fd); } /*