From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: Thu, 15 May 2025 15:27:22 -0400
quoted
@@ -227,10 +297,18 @@ void __send_fd(struct __test_metadata *_metadata,
.msg_control = &cmsg,
.msg_controllen = CMSG_SPACE(sizeof(cmsg.fd)),
};
- int ret;
+ int ret, saved_errno;
+ errno = 0;
ret = sendmsg(self->fd[receiver * 2 + 1], &msg, variant->flags);
- ASSERT_EQ(MSGLEN, ret);
+ saved_errno = errno;
+
+ if (variant->disabled) {
+ ASSERT_EQ(-1, ret);
+ ASSERT_EQ(-EPERM, -saved_errno);
+ } else {
+ ASSERT_EQ(MSGLEN, ret);
+ }
Why is this errno complexity needed?
It should never be needed to manually reset errno.
Is the saved_errno there because ASSERT_EQ on ret could call a libc
function that resets errno?
I guess it's paranoid here.
When ASSERT_EQ() calls TH_LOG(), it always fails and does
not reach the 2nd ASSERT_EQ().
Will remove them.
Thanks!