public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [RFC] [PATCH] tst_timer: Add tst_timer_expired_ms()
Date: Thu, 28 Jun 2018 15:47:50 -0400 (EDT)	[thread overview]
Message-ID: <986909105.29606861.1530215270429.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20180628092846.21204-1-chrubis@suse.cz>



----- Original Message -----
> Recently we were in the need of easy way to run a testcase for a given
> time interval. We nearly had everything in the timer library already but
> the problem was that the sampling function i.e. tst_timer_stop() and
> conversion functions e.g. tst_timer_elapsed_ms() were separated.
> 
> This commit adds a tst_timer_expired_ms() function that combines the
> sampling and comparsion, the intended usage is:
> 
> static void setup(void)
> {
> 	...
> 	tst_timer_check(CLOCK_MONOTONIC);
> 	...
> }
> 
> static void run(void)
> {
> 	...
> 
> 	tst_timer_start(CLOCK_MONOTONIC);
> 
> 	...
> 
> 	while (!tst_timer_expired_ms(5000)) {
> 		...
> 	}
> 
> 	...
> }
> 
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> CC: Eric Biggers <ebiggers3@gmail.com>

ACK

I'm thinking if it's worth skipping also tst_timer_check(),
and adding some like "LTP_TIMER_ANY" that would pick first
available clockid for you.

Regards,
Jan

  reply	other threads:[~2018-06-28 19:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-28  9:28 [LTP] [RFC] [PATCH] tst_timer: Add tst_timer_expired_ms() Cyril Hrubis
2018-06-28 19:47 ` Jan Stancek [this message]
2018-06-29 14:06   ` Cyril Hrubis

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=986909105.29606861.1530215270429.JavaMail.zimbra@redhat.com \
    --to=jstancek@redhat.com \
    --cc=ltp@lists.linux.it \
    /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