public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Zhao Gongyi <zhaogongyi@huawei.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] futex_waitv01: Add test verifies EAGIN/ETIMEDOUT
Date: Tue, 7 Jun 2022 15:12:06 +0200	[thread overview]
Message-ID: <Yp9OpshD7SOkK7QR@rei> (raw)
In-Reply-To: <20220607025435.184105-1-zhaogongyi@huawei.com>

Hi!
> +static void test_mismatch_between_uaddr_and_val(void)
> +{
> +	struct timespec to;
> +
> +	waitv->uaddr = (uintptr_t)futex;
> +	waitv->flags = FUTEX_32 | FUTEX_PRIVATE_FLAG;
> +	waitv->val = 1;
> +
> +	init_timeout(&to);
> +
> +	TST_EXP_FAIL(futex_waitv(waitv, 1, 0, &to, CLOCK_MONOTONIC), EAGAIN,
> +			"futex_waitv mismatch between value of uaddr and val");

The init_timeout(&to) inits the timeout with CLOCK_REALTIME time, so we
should pass CLOCK_REALTIME to the futex_waitv() as well.
 
> +}
> +
> +static void test_timeout(void)
> +{
> +	struct timespec to;
> +
> +	waitv->uaddr = (uintptr_t)futex;
> +	waitv->flags = FUTEX_32 | FUTEX_PRIVATE_FLAG;
> +	waitv->val = 0;
> +
> +	init_timeout(&to);

I guess that we can as well just do:

SAFE_CLOCK_GETTIME(CLOCK_REALTIME, &to);

Which would make the test much faster as we will not have to wait for
one second for the timeout.

Eventually we can as well add a few miliseconds to the timeout, we do
have a nice functions to work with different time structures in this
case we can just do:

	to = tst_timespec_add_us(to, 10000);

To add 10ms to the timeout.

> +	TST_EXP_FAIL(futex_waitv(waitv, 1, 0, &to, CLOCK_REALTIME), ETIMEDOUT,
> +			"futex_waitv timeout");
> +
> +}
> +
>  static void cleanup(void)
>  {
>  	free(futex);
> @@ -126,6 +154,8 @@ static void run(void)
>  	test_null_waiters();
>  	test_invalid_clockid();
>  	test_invalid_nr_futexes();
> +	test_mismatch_between_uaddr_and_val();
> +	test_timeout();
>  }
> 
>  static struct tst_test test = {
> --
> 2.17.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2022-06-07 13:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-07  2:54 [LTP] [PATCH v2] futex_waitv01: Add test verifies EAGIN/ETIMEDOUT Zhao Gongyi via ltp
2022-06-07 13:12 ` Cyril Hrubis [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-06-08  3:24 zhaogongyi via ltp

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 \
    --in-reply-to=Yp9OpshD7SOkK7QR@rei \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=zhaogongyi@huawei.com \
    /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