From aa9f97af93fc9df5596654fc11f2720878c81e1a Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Mon, 16 May 2022 19:04:02 -0700 Subject: [PATCH] tests/unix_dgram: account for size of sender address in the filling cycle This fixes test failure with large net.local.dgram.recvspace values. --- tests/sys/kern/unix_dgram.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/sys/kern/unix_dgram.c b/tests/sys/kern/unix_dgram.c index 66a9ab6092e..4bcb84587f4 100644 --- a/tests/sys/kern/unix_dgram.c +++ b/tests/sys/kern/unix_dgram.c @@ -54,6 +54,9 @@ static struct sigaction sigact = { /* * Fill socket to a state when next send(len) would fail. + * + * Note that every datagram is prepended with sender address, + * size of struct sockaddr. */ static void fill(int fd, void *buf, ssize_t len) @@ -64,7 +67,9 @@ fill(int fd, void *buf, ssize_t len) ATF_REQUIRE(sysctlbyname("net.local.dgram.recvspace", &recvspace, &llen, NULL, 0) == 0); - for (sent = 0; sent + len < (ssize_t)recvspace; sent += len) + for (sent = 0; + sent + len + sizeof(struct sockaddr) < recvspace; + sent += len + sizeof(struct sockaddr)) ATF_REQUIRE(send(fd, buf, len, 0) == len); } -- 2.45.0