Re: git: de6328af0c8c - main - tests/sys/kern/ssl_sendfile: :eagain_vs_eof: improve failure messaging

From: Siva Mahadevan <siva_at_FreeBSD.org>
Date: Fri, 13 Nov 2026 00:13:07 UTC
On Thu Nov 12, 2026 at 116:00 UTC, Enji Cooper <ngie@FreeBSD.org> wrote:
> The branch main has been updated by ngie:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=de6328af0c8c0284d28574364db3b8d98d51e005
>
> commit de6328af0c8c0284d28574364db3b8d98d51e005
> Author:     Enji Cooper <ngie@FreeBSD.org>
> AuthorDate: 2026-11-12 23:55:46 +0000
> Commit:     Enji Cooper <ngie@FreeBSD.org>
> CommitDate: 2026-11-12 23:59:37 +0000
>
>     tests/sys/kern/ssl_sendfile: :eagain_vs_eof: improve failure messaging
>     
>     Convert many raw `ATF_REQUIRE(..)` macro calls to `ATF_REQUIRE_MSG(..)`
>     and output the sbytes attached to the context in provide meaningful
>     information with failure messages.
>     
>     While here, fix a typo in a comment and some indentation in another
>     testcase (:random).
>     
>     PR:             299447
>     MFC after:      1 week
> ---
>  tests/sys/kern/ssl_sendfile.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/tests/sys/kern/ssl_sendfile.c b/tests/sys/kern/ssl_sendfile.c
> index ad938b65ef19..d44296c90750 100644
> --- a/tests/sys/kern/ssl_sendfile.c
> +++ b/tests/sys/kern/ssl_sendfile.c
> @@ -350,7 +350,7 @@ ATF_TC_BODY(random, tc)
>  		require_sbytes(&c, (ssize_t)expect);
>  	}
>  
> -        common_cleanup(&c);
> +	common_cleanup(&c);
>  }
>  
>  /* Truncate the file while sendfile(2) is working on it. */
> @@ -470,11 +470,12 @@ ATF_TC_BODY(eagain_vs_eof, tc)
>  
>  	/*
>  	 * Exercise short write due to no buffer space on non-blocking
> -	 * socket.  Internall sendfile(2) returns -1 and errno == EAGAIN.
> +	 * socket.  Internal sendfile(2) returns -1 and errno == EAGAIN.
>  	 */
>  	ATF_REQUIRE(pthread_mutex_lock(&c.mtx) == 0);
>  	sendme_locked_wait(&c, 0, FSIZE, true);
> -	ATF_REQUIRE(c.sbytes > 0);
> +	ATF_REQUIRE_MSG(c.sbytes > 0, "c.sbytes <= 0: %jd",
> +	    (ossl_ssize_t)c.sbytes);
>  	ATF_REQUIRE(SSL_get_error(c.srv, c.sbytes) == 0);
>  #if 0	/* see https://github.com/openssl/openssl/issues/29742 */
>  	ATF_REQUIRE(BIO_should_retry(SSL_get_wbio(c.srv)));
> @@ -484,7 +485,8 @@ ATF_TC_BODY(eagain_vs_eof, tc)
>  	 * Exercise second attempt on already full buffer.
>  	 */
>  	sendme_locked_wait(&c, 0, FSIZE, true);
> -	ATF_REQUIRE(c.sbytes == -1);
> +	ATF_REQUIRE_MSG(c.sbytes == -1, "c.sbytes != -1: %jd",
> +	    (ossl_ssize_t)c.sbytes);

In the future, please use the narrower ATF_REQUIRE_*EQ or
ATF_REQUIRE_*EQ_MSG macros, as they will include the expected/actual
values in the message directly in a uniform way. In this file,
ATF_REQUIRE_INTEQ_MSG would've worked well in many cases.

I have a local WIP sweeping change patch
to change all trivial equality checks using ATF_REQUIRE to the narrower
macros, I'll post that for review sometime.

>  	ATF_REQUIRE(SSL_get_error(c.srv, c.sbytes) == SSL_ERROR_WANT_WRITE);
>  	ATF_REQUIRE(BIO_should_retry(SSL_get_wbio(c.srv)));
>  
> @@ -505,7 +507,8 @@ ATF_TC_BODY(eagain_vs_eof, tc)
>  	 * rather than asserts that this is a correct behavior.
>  	 */
>  	sendme_locked_wait(&c, FSIZE, 0, true);
> -	ATF_REQUIRE(c.sbytes == 0);
> +	ATF_REQUIRE_MSG(c.sbytes == 0, "c.sbytes != 0: %jd",
> +	    (ossl_ssize_t)c.sbytes);
>  	ATF_REQUIRE(SSL_get_error(c.srv, c.sbytes) == SSL_ERROR_SYSCALL);
>  #if 0	/* see https://github.com/openssl/openssl/issues/29742 */
>  	ATF_REQUIRE(!BIO_should_retry(SSL_get_wbio(c.srv)));
> @@ -515,7 +518,8 @@ ATF_TC_BODY(eagain_vs_eof, tc)
>  	 * Exercise short write due to end of file.
>  	 */
>  	sendme_locked_wait(&c, FSIZE - 100, 0, true);
> -	ATF_REQUIRE(c.sbytes == 100);
> +	ATF_REQUIRE_MSG(c.sbytes == 100, "c.sbytes != 100: %jd",
> +	    (ossl_ssize_t)c.sbytes);
>  	ATF_REQUIRE(SSL_get_error(c.srv, c.sbytes) == 0);
>  #if 0	/* see https://github.com/openssl/openssl/issues/29742 */
>  	ATF_REQUIRE(!BIO_should_retry(SSL_get_wbio(c.srv)));