From: Marc Herbert <marc.herbert@linux.intel.com>
To: alison.schofield@intel.com, nvdimm@lists.linux.dev,
Li Zhijian <lizhijian@fujitsu.com>
Subject: Re: [ndctl PATCH v3] test/monitor.sh: replace sleep with event driven wait
Date: Mon, 19 May 2025 15:42:30 -0700 [thread overview]
Message-ID: <f15e4a85-cdb0-4243-bd82-28f09710bb7c@linux.intel.com> (raw)
In-Reply-To: <20250519192858.1611104-1-alison.schofield@intel.com>
On 2025-05-19 12:28, alison.schofield@intel.com wrote:
> From: Alison Schofield <alison.schofield@intel.com>
>
>
> Again, looking for Tested-by Tags. Thanks!
Wow, it went so fast I genuinely thought something went terribly wrong
and it did not test anything anymore. While reporting "Success!" - that
has happened before.
But I check the test logs and it does a lot of stuff - in less 2
seconds! What a difference.
Tested-by: Marc Herbert <marc.herbert@linux.intel.com>
I have only concern holding back my Reviewed-by + some minor nits after
the code. I think the error message for the timeout pipeline is too
limited, terse and generic; does not say anything about what happened,
does not make the difference between a timeout and some other, unexpected
failure, how many occurences were found etc. I think the error clause
should do at least two things:
- print the timeout $? exit code.
- grep the log file again, either with -c if it's too long, or not.
- Any other useful information that could be up for grabs at that point.
> +wait_for_logfile_update()
> +{
> + local expect_string="$1"
> + local expect_count="$2"
> +
> + # Wait up to 3s for $expect_count occurrences of $expect_string
> + # tail -n +1 -F: starts watching the logfile from the first line
> +
> + if ! timeout 3s tail -n +1 -F "$logfile" | grep -m "$expect_count" -q "$expect_string"; then
> + echo "logfile not updated in 3 secs"
> + err "$LINENO"
> + fi
> +}
tail -F really does solve the problem with very little code, well
spotted!
Nit 1: I did not know that -F option: can you try to sneak the word
"retry" somewhere in the comments?
Codestyle Nit 2: to avoid negations I generally prefer:
timeout 3s tail -n +1 -F "$logfile" |
grep -q -m "$expect_count" -q "$expect_string" || {
error ...
}
This also translates to plain English nicely as "wait or fail", "do or
die", etc.
Super minor nit 3: "$expect_string" looks like an argument of "-q", can
you move -q first?
next prev parent reply other threads:[~2025-05-19 22:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-19 19:28 [ndctl PATCH v3] test/monitor.sh: replace sleep with event driven wait alison.schofield
2025-05-19 22:42 ` Marc Herbert [this message]
2025-05-22 4:20 ` Alison Schofield
2025-05-20 20:47 ` Verma, Vishal L
2025-05-22 4:22 ` Alison Schofield
2025-05-21 9:00 ` Zhijian Li (Fujitsu)
2025-05-22 4:35 ` Alison Schofield
2025-05-22 18:38 ` Dan Williams
2025-05-22 22:05 ` Alison Schofield
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=f15e4a85-cdb0-4243-bd82-28f09710bb7c@linux.intel.com \
--to=marc.herbert@linux.intel.com \
--cc=alison.schofield@intel.com \
--cc=lizhijian@fujitsu.com \
--cc=nvdimm@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.