public inbox for [email protected]
 help / color / mirror / Atom feed
From: Marcelo Diop-Gonzalez <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: [PATCH liburing] tests: add another timeout sequence test case
Date: Tue, 19 Jan 2021 09:04:41 -0500	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On Mon, Jan 18, 2021 at 12:00:29PM -0500, Marcelo Diop-Gonzalez wrote:
> This test case catches an issue where timeouts may not be flushed
> if the number of new events is greater (not equal) to the number
> of events requested in the timeout.
> 
> Signed-off-by: Marcelo Diop-Gonzalez <[email protected]>
> ---
>  test/timeout.c | 26 +++++++++++++++++---------
>  1 file changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/test/timeout.c b/test/timeout.c
> index 9c8211c..d46d93d 100644
> --- a/test/timeout.c
> +++ b/test/timeout.c
> @@ -112,7 +112,7 @@ err:
>  /*
>   * Test numbered trigger of timeout
>   */
> -static int test_single_timeout_nr(struct io_uring *ring)
> +static int test_single_timeout_nr(struct io_uring *ring, int nr)
>  {
>  	struct io_uring_cqe *cqe;
>  	struct io_uring_sqe *sqe;
> @@ -126,7 +126,7 @@ static int test_single_timeout_nr(struct io_uring *ring)
>  	}
>  
>  	msec_to_ts(&ts, TIMEOUT_MSEC);
> -	io_uring_prep_timeout(sqe, &ts, 2, 0);
> +	io_uring_prep_timeout(sqe, &ts, nr, 0);
>  
>  	sqe = io_uring_get_sqe(ring);
>  	io_uring_prep_nop(sqe);
> @@ -149,6 +149,8 @@ static int test_single_timeout_nr(struct io_uring *ring)
>  			goto err;
>  		}
>  
> +		ret = cqe->res;
> +
>  		/*
>  		 * NOP commands have user_data as 1. Check that we get the
>  		 * two NOPs first, then the successfully removed timout as
> @@ -167,15 +169,16 @@ static int test_single_timeout_nr(struct io_uring *ring)
>  				fprintf(stderr, "%s: timeout not last\n", __FUNCTION__);
>  				goto err;
>  			}

Ahh wait actually I don't like it so much because this assumes the
timeout has to be the last one in the ring even when nr = 1. Happens
to be true but doesn't seem like something the test should require in
that case. I'll send a v2 later.

-Marcelo

> +			if (ret) {
> +				fprintf(stderr, "%s: timeout triggered by passage of"
> +					" time, not by events completed\n", __FUNCTION__);
> +				goto err;
> +			}
>  			break;
>  		}
>  
> -		ret = cqe->res;
>  		io_uring_cqe_seen(ring, cqe);
> -		if (ret < 0) {
> -			fprintf(stderr, "Timeout: %s\n", strerror(-ret));
> -			goto err;
> -		} else if (ret) {
> +		if (ret) {
>  			fprintf(stderr, "res: %d\n", ret);
>  			goto err;
>  		}
> @@ -1224,9 +1227,14 @@ int main(int argc, char *argv[])
>  		return ret;
>  	}
>  
> -	ret = test_single_timeout_nr(&ring);
> +	ret = test_single_timeout_nr(&ring, 1);
> +	if (ret) {
> +		fprintf(stderr, "test_single_timeout_nr(1) failed\n");
> +		return ret;
> +	}
> +	ret = test_single_timeout_nr(&ring, 2);
>  	if (ret) {
> -		fprintf(stderr, "test_single_timeout_nr failed\n");
> +		fprintf(stderr, "test_single_timeout_nr(2) failed\n");
>  		return ret;
>  	}
>  
> -- 
> 2.20.1
> 

      reply	other threads:[~2021-01-19 23:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-18 17:00 [PATCH liburing] tests: add another timeout sequence test case Marcelo Diop-Gonzalez
2021-01-19 14:04 ` Marcelo Diop-Gonzalez [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox