mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-21 10:19:04 +00:00
tests/unix_passfd: add a comment for send_a_lot
Explain why SOCK_DGRAM and SOCK_STREAM differ in this edge case. While here improve output in case of a failure.
This commit is contained in:
parent
1e68b8d9a9
commit
3ad0f9a584
|
@ -657,11 +657,20 @@ ATF_TC_BODY(rights_creds_payload, tc)
|
||||||
ATF_REQUIRE_MSG(len != -1 , "sendmsg failed: %s", strerror(errno));
|
ATF_REQUIRE_MSG(len != -1 , "sendmsg failed: %s", strerror(errno));
|
||||||
#if TEST_PROTO == SOCK_STREAM
|
#if TEST_PROTO == SOCK_STREAM
|
||||||
ATF_REQUIRE_MSG((size_t)len < sendspace,
|
ATF_REQUIRE_MSG((size_t)len < sendspace,
|
||||||
"sendmsg: %zd bytes sent", len);
|
"sendmsg: %zd bytes sent, expected < %lu", len, sendspace);
|
||||||
#endif
|
#endif
|
||||||
#if TEST_PROTO == SOCK_DGRAM
|
#if TEST_PROTO == SOCK_DGRAM
|
||||||
|
/*
|
||||||
|
* sendmsg(2) can't truncate datagrams, only recvmsg(2) can. There are
|
||||||
|
* two options for the kernel here: either accept the datagram with
|
||||||
|
* slight overcommit of the socket buffer space or return ENOBUFS for a
|
||||||
|
* datagram that is smaller or equal to the socket buffer space. Our
|
||||||
|
* implementation does overcommit. Explanation is simple: from our
|
||||||
|
* side we see space available, we have no idea that remote side has
|
||||||
|
* LOCAL_CREDS set. From our side we expect sendmsg(2) to succeed.
|
||||||
|
*/
|
||||||
ATF_REQUIRE_MSG((size_t)len == sendspace,
|
ATF_REQUIRE_MSG((size_t)len == sendspace,
|
||||||
"sendmsg: %zd bytes sent", len);
|
"sendmsg: %zd bytes sent, expected %lu", len, sendspace);
|
||||||
#endif
|
#endif
|
||||||
rlen = recvfd_payload(fd[1], &getfd, buf, len,
|
rlen = recvfd_payload(fd[1], &getfd, buf, len,
|
||||||
CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX)) + CMSG_SPACE(sizeof(int)), 0);
|
CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX)) + CMSG_SPACE(sizeof(int)), 0);
|
||||||
|
|
Loading…
Reference in a new issue