public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/2] c: Use $LTP_TIMEOUT_MUL also in retry functions
Date: Fri, 19 Jul 2019 11:15:19 +0200	[thread overview]
Message-ID: <20190719091519.GC30204@dell5510> (raw)
In-Reply-To: <CAEemH2e6PmPYWWQg+NgSR=6Qc4BZpEswbcc4Y+n3B_pFqnQJDQ@mail.gmail.com>

Hi Li,

thanks for your review!

> On Thu, Jul 18, 2019 at 4:40 PM Petr Vorel <pvorel@suse.cz> wrote:
> >...
> >  #ifndef TST_COMMON_H__
> > @@ -51,15 +40,22 @@

> >  #define TST_RETRY_FN_EXP_BACKOFF(FUNC, ERET, MAX_DELAY)        \
> >  ({     int tst_delay_ = 1;                                             \
> > +       float m = 1;    \
> > +       char *mul = getenv("LTP_TIMEOUT_MUL");  \

> We also need a prefix/suffix in the variable definition to make sure
> that it will
> not alias with anything that has been passed to the FUNC, just like what we do
> for the tst_delay_.

> e.g. if the FUNC is defined as foo_func(m); the m variable will be aliased and
> the function will do something very unexpected.
Good point, I'll fix it in v3.

> > +       if (mul) {      \
> > +               m = atof(mul); \
> > +               if (m < 1) \
> > +                       tst_brk(TBROK, "Invalid timeout multiplier '%s'", mul); \

> If we reverse some code order in tst_set_timeout() function, then here
> we have no need to check if m < 1 again, since the LTP_TIMEOUT_MUL
> valid check will be finished in setup() early phase.
> (This comment is just FYI, and I also think it's OK to check twice.)
Good point. I'd probably check twice in case the logic changes one day.

> --------------------------------------
> void tst_set_timeout(int timeout)
> {
>         float m = 1;
>         char *mul = getenv("LTP_TIMEOUT_MUL");

>         if (mul) {
>                 m = atof(mul);
>                 if (m < 1)
>                         tst_brk(TBROK, "Invalid timeout multiplier '%s'", mul);
>         }

>         if (timeout == -1) {
>                 tst_res(TINFO, "Timeout per run is disabled");
>                 return;
>         }

>         results->timeout = timeout * m + 0.5;

>         tst_res(TINFO, "Timeout per run is %uh %02um %02us",
>                 results->timeout/3600, (results->timeout%3600)/60,
>                 results->timeout % 60);

>         if (getpid() == lib_pid)
>                 alarm(results->timeout);
>         else
>                 heartbeat();
> }


Kind regards,
Petr

  reply	other threads:[~2019-07-19  9:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-18  8:39 [LTP] [PATCH 1/2] shell: Use $LTP_TIMEOUT_MUL also in retry functions Petr Vorel
2019-07-18  8:39 ` [LTP] [PATCH 2/2] c: " Petr Vorel
2019-07-19  5:02   ` Li Wang
2019-07-19  9:15     ` Petr Vorel [this message]
2019-07-19  4:56 ` [LTP] [PATCH 1/2] shell: " Li Wang
2019-07-19  9:01   ` Petr Vorel

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=20190719091519.GC30204@dell5510 \
    --to=pvorel@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