The basic and random test cases checked c->sbytes immediately after draining all data from SSL_read, without waiting for the server thread to return from SSL_sendfile().
On a loopback connection, the client can consume all data from the kernel receive buffer before SSL_sendfile() returns on the server side, leaving c->sbytes unset at the point of the ATF_REQUIRE check.
Add wait_server() which holds the mutex and waits on the condvar until the server thread transitions out of RUNNING state, ensuring c->sbytes is stable before it is read.
This fixes a flaky failure appearing roughly once every 40 runs with error:
tests/sys/kern/ssl_sendfile.c:327: c.sbytes == (ssize_t)expect not met