[LTP] [PATCH] openposix: Fix aio_suspend/1-1 completion race

Martin Doucha mdoucha@suse.cz
Thu Oct 1 14:01:07 CEST 2026


Hi,
removing the check defeats the purpose of the test. The proper fix is to 
block on a full socket instead, but aio_suspend() tests will also need a 
second thread that'll drain the socket while the main thread is suspended.

On 10/1/26 13:00, Andrea Cervesato wrote:
> From: Andrea Cervesato <andrea.cervesato@suse.com>
> 
> The selected read may finish before the test calls aio_suspend().
> Treating this as an unresolved result makes the test depend on I/O
> speed and scheduling.
> 
> POSIX permits aio_suspend() to return immediately for a completed
> request. Drop the racy precondition and retain the completion checks.
> 
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> Two aio_suspend tests assume that queued I/O cannot complete before
> the test checks its status. Depending on I/O speed and scheduling,
> this can produce an unresolved result or a false test failure.
> 
> In 1-1, early completion is valid: aio_suspend() must return
> immediately when a listed request has already completed. Remove the
> check that rejects this case.
> ---
>   .../conformance/interfaces/aio_suspend/1-1.c             | 16 +---------------
>   1 file changed, 1 insertion(+), 15 deletions(-)
> 
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c
> index 8f0c9ae95..2de7c87d2 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c
> @@ -25,7 +25,6 @@
>    *
>    *	- write to a file
>    *	- submit a list of read requests
> - *	- check that the selected request has not completed
>    *	- suspend on selected request
>    *	- check that the selected request has completed using aio_error and
>    *	  aio_return
> @@ -146,20 +145,7 @@ int test_main(int argc PTS_ATTRIBUTE_UNUSED, char **argv PTS_ATTRIBUTE_UNUSED)
>   		exit(PTS_UNRESOLVED);
>   	}
>   
> -	/* Check selected request has not completed yet */
> -	err = aio_error(aiocbs[WAIT_FOR_AIOCB]);
> -	if (!err) {
> -		printf(TNAME " Error : AIOCB %d already completed before "
> -		       "suspend\n", WAIT_FOR_AIOCB);
> -		for (i = 0; i < NUM_AIOCBS; i++)
> -			free(aiocbs[i]);
> -		free(bufs);
> -		free(aiocbs);
> -		close(fd);
> -		exit(PTS_UNRESOLVED);
> -	}
> -
> -	/* Suspend on selected request */
> +	/* The selected request may have already completed, which is valid. */
>   	ret = aio_suspend((const struct aiocb **)plist, 2, NULL);
>   	if (ret) {
>   		printf(TNAME " Error at aio_suspend() %d: %s\n",
> 
> ---
> base-commit: 65c0cffc7dda79320e551f6437327a5625e88d65
> change-id: 20261001-fix_aio_suspend-1-1-2b05a5fddd53
> 
> Best regards,
> --
> Andrea Cervesato <andrea.cervesato@suse.com>
> 
> 


-- 
Martin Doucha   mdoucha@suse.cz
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


More information about the ltp mailing list