git: f28532a0f363 - main - tests: fix unix_passfd_dgram:rights_creds_payload after be1f485d7d6b
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 01 Aug 2022 09:30:39 UTC
The branch main has been updated by melifaro:
URL: https://cgit.FreeBSD.org/src/commit/?id=f28532a0f363dd99691597708ae01331fb2c9a54
commit f28532a0f363dd99691597708ae01331fb2c9a54
Author: Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2022-08-01 09:20:45 +0000
Commit: Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2022-08-01 09:20:45 +0000
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
---
tests/sys/kern/unix_passfd_test.c | 8 +++-----
1 file 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);