aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2026-03-10 21:02:02 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2026-03-10 21:03:25 +0000
commitded881f9056d2ecb224490e56e95877af54164c4 (patch)
treeaa7854f14c9b3198491036c71d852352d1d499ae
parent35b976c6ce6145678ab378b21fdeab687a0a76d5 (diff)
tests/kern/ssl_sendfile: fix 'random' and 'basic' flakyness
The read of c.sbytes needs to be synchronized with mutex. The problem was fixed for 'truncate' and 'grow' with 8a9508563542, but these two suffer from the same problem. Provide require_sbytes(), a locked wrapper around ATF_REQUIRE() to reduce copy and paste. Submitted by: olivier Differential Revision: https://reviews.freebsd.org/D55781
-rw-r--r--tests/sys/kern/ssl_sendfile.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/tests/sys/kern/ssl_sendfile.c b/tests/sys/kern/ssl_sendfile.c
index 066674f5fb03..c16640572bb1 100644
--- a/tests/sys/kern/ssl_sendfile.c
+++ b/tests/sys/kern/ssl_sendfile.c
@@ -285,6 +285,14 @@ SSL_read_b(SSL *ssl, void *buf, int size)
return (rv);
}
+static void
+require_sbytes(struct ctx *c, ssize_t expect)
+{
+ ATF_REQUIRE(pthread_mutex_lock(&c->mtx) == 0);
+ ATF_REQUIRE(c->sbytes == expect);
+ ATF_REQUIRE(pthread_mutex_unlock(&c->mtx) == 0);
+}
+
ATF_TC_WITHOUT_HEAD(basic);
ATF_TC_BODY(basic, tc)
{
@@ -302,7 +310,7 @@ ATF_TC_BODY(basic, tc)
nread += n;
}
ATF_REQUIRE(nread == FSIZE);
- ATF_REQUIRE(c.sbytes == FSIZE);
+ require_sbytes(&c, FSIZE);
common_cleanup(&c);
}
@@ -332,7 +340,7 @@ ATF_TC_BODY(random, tc)
nread += n;
}
ATF_REQUIRE(nread == expect);
- ATF_REQUIRE(c.sbytes == (ssize_t)expect);
+ require_sbytes(&c, (ssize_t)expect);
}
common_cleanup(&c);
@@ -367,9 +375,7 @@ 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);
+ require_sbytes(&c, TRUNC);
common_cleanup(&c);
}
@@ -418,9 +424,7 @@ 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);
+ require_sbytes(&c, FSIZE + GROW);
common_cleanup(&c);
}