Date: Tue, 27 Jan 2026 21:17:16 +0000 From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 8a9508563542 - main - tests/kern: make ssl_sendfile:truncate and ssl_sendfile:grow less flaky Message-ID: <69792b5c.37509.d3cf068@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=8a9508563542d709b1a42a065e6e99e004a8b3fe commit 8a9508563542d709b1a42a065e6e99e004a8b3fe Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2026-01-27 21:13:11 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> CommitDate: 2026-01-27 21:17:08 +0000 tests/kern: make ssl_sendfile:truncate and ssl_sendfile:grow less flaky First problem is a trivial race that the client thread doesn't see updated c.sbytes. Second problem applies only to the truncate test. On a machine with huge default buffer sizes, there is a chance that sendfile(2) will fill both buffers with amount of data that is larger than the size we plan to truncate. To minimise chances for this scenario, increase file size and truncate it less aggressively, also try to decrease buffer sizes. --- tests/sys/kern/ssl_sendfile.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/sys/kern/ssl_sendfile.c b/tests/sys/kern/ssl_sendfile.c index 928a44a50811..884079e80be5 100644 --- a/tests/sys/kern/ssl_sendfile.c +++ b/tests/sys/kern/ssl_sendfile.c @@ -42,7 +42,7 @@ #include <atf-c.h> -#define FSIZE (size_t)(1024 * 1024) +#define FSIZE (size_t)(2 * 1024 * 1024) struct ctx { EVP_PKEY *pkey; /* Self-signed key ... */ @@ -338,10 +338,15 @@ ATF_TC_BODY(truncate, tc) char buf[128 * 1024]; size_t nread; int n; -#define TRUNC (FSIZE / 2) +#define TRUNC (FSIZE - 1024) common_init(&c); + ATF_REQUIRE(setsockopt(c.ss, SOL_SOCKET, SO_SNDBUF, &(int){FSIZE / 16}, + sizeof(int)) == 0); + ATF_REQUIRE(setsockopt(c.cs, SOL_SOCKET, SO_RCVBUF, &(int){FSIZE / 16}, + sizeof(int)) == 0); + sendme(&c, 0, 0, false); /* Make sure sender is waiting on the socket buffer. */ while (poll(&(struct pollfd){ .fd = c.ss, .events = POLLOUT }, 1, 1) @@ -354,7 +359,9 @@ ATF_TC_BODY(truncate, tc) nread += n; } ATF_REQUIRE(nread == TRUNC); + ATF_REQUIRE(pthread_mutex_lock(&c.mtx) == 0); ATF_REQUIRE(c.sbytes == TRUNC); + ATF_REQUIRE(pthread_mutex_unlock(&c.mtx) == 0); common_cleanup(&c); } @@ -372,6 +379,11 @@ ATF_TC_BODY(grow, tc) common_init(&c); + ATF_REQUIRE(setsockopt(c.ss, SOL_SOCKET, SO_SNDBUF, &(int){FSIZE / 16}, + sizeof(int)) == 0); + ATF_REQUIRE(setsockopt(c.cs, SOL_SOCKET, SO_RCVBUF, &(int){FSIZE / 16}, + sizeof(int)) == 0); + sendme(&c, 0, 0, false); /* Make sure sender is waiting on the socket buffer. */ while (poll(&(struct pollfd){ .fd = c.ss, .events = POLLOUT }, 1, 1) @@ -398,7 +410,9 @@ ATF_TC_BODY(grow, tc) nread += n; } ATF_REQUIRE(nread == GROW); + ATF_REQUIRE(pthread_mutex_lock(&c.mtx) == 0); ATF_REQUIRE(c.sbytes == FSIZE + GROW); + ATF_REQUIRE(pthread_mutex_unlock(&c.mtx) == 0); common_cleanup(&c); }home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69792b5c.37509.d3cf068>
