aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2022-08-01 09:20:45 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2022-08-01 09:20:45 +0000
commitf28532a0f363dd99691597708ae01331fb2c9a54 (patch)
treeeea5f14228d4f38e5e600ed26e1908098c0486a2 /tests
parent5c23343b8c0cc018f06a4a2cb2d911770bdc8ee2 (diff)
downloadsrc-f28532a0f363dd99691597708ae01331fb2c9a54.tar.gz
src-f28532a0f363dd99691597708ae01331fb2c9a54.zip
tests: fix unix_passfd_dgram:rights_creds_payload after be1f485d7d6b
The test was failing due to the assert on lack of MSG_TRUNC flag in the output flags of recvmsg(). The code passed MSG_TRUNC, along with sufficient-size buffer to hold the message to-be-received to the recvmsg(), and expected MSG_TRUNC to be returned as well. This is not exactly correct as a) MSG_TRUNC was not even a supported recvmsg() flag before be1f485d7d6b and b) it violates POSIX, as POSIX states it should be set only "If a message is too long to fit in the supplied buffers,". The test was working before as the kernel copied input flags to the output flags. be1f485d7d6b changed that behaviour to clear MSG_TRUNC if it was present on the input. Fix the test by checking POSIX-defined behaviour. Discussed with: glebius
Diffstat (limited to 'tests')
-rw-r--r--tests/sys/kern/unix_passfd_test.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/tests/sys/kern/unix_passfd_test.c b/tests/sys/kern/unix_passfd_test.c
index dc017db4f1ce..49f4540bb9d0 100644
--- a/tests/sys/kern/unix_passfd_test.c
+++ b/tests/sys/kern/unix_passfd_test.c
@@ -255,9 +255,8 @@ recvfd_payload(int sockfd, int *recv_fd, void *buf, size_t buflen,
"recvmsg: did not receive single-fd message");
ATF_REQUIRE_MSG(!localcreds(sockfd) || foundcreds,
"recvmsg: expected credentials were not received");
- if (recvmsg_flags & MSG_TRUNC)
- ATF_REQUIRE_MSG(msghdr.msg_flags & MSG_TRUNC,
- "recvmsg: expected MSG_TRUNC missing");
+ ATF_REQUIRE_MSG((msghdr.msg_flags & MSG_TRUNC) == 0,
+ "recvmsg: MSG_TRUNC is set while buffer is sufficient");
}
static void
@@ -584,8 +583,7 @@ ATF_TC_BODY(rights_creds_payload, tc)
ATF_REQUIRE_MSG((size_t)len == sendspace,
"sendmsg: %zu bytes sent", len);
recvfd_payload(fd[1], &getfd, buf, len,
- CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX)) + CMSG_SPACE(sizeof(int)),
- MSG_TRUNC);
+ CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX)) + CMSG_SPACE(sizeof(int)), 0);
#endif
close(putfd);