From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 1/2] include: add an exponential backoff macro for function repeat
Date: Mon, 23 Apr 2018 11:58:55 +0200 [thread overview]
Message-ID: <20180423095855.GA24481@rei> (raw)
In-Reply-To: <20180421021600.17549-1-liwang@redhat.com>
Hi!
> +#define TST_RETRY_FN_EXP_BACKOFF(FUNC, ERET, MAX_DELAY) \
> +({ int tst_delay = 1; \
> + for (;;) { \
> + typeof(FUNC) ret = FUNC; \
^
I prefixed this variable with tst_ and even added _
suffix to make sure that it will not alias either.
> + if (ret == ERET) \
> + break; \
> + if (tst_delay < MAX_DELAY * 1000000) { \
> + tst_res(TINFO, \
> + #FUNC" returned %i, retrying" \
> + " in %ius", ret, tst_delay); \
> + usleep(tst_delay); \
> + tst_delay *= 2; \
> + } else { \
> + tst_brk(TBROK, #FUNC" failed"); \
> + } \
> + } \
> + ERET; \
> +})
And pushed, thanks.
I know that the documentation is there in the comment but we should
probably add a note about the macro into the test-writing-guidelines.txt
as well...
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2018-04-23 9:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-21 2:15 [LTP] [PATCH v3 1/2] include: add an exponential backoff macro for function repeat Li Wang
2018-04-23 9:58 ` Cyril Hrubis [this message]
2018-04-23 10:53 ` Li Wang
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=20180423095855.GA24481@rei \
--to=chrubis@suse.cz \
--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