On Mon, 2023-11-27 at 20:11 -0800, [email protected] wrote:
> From: Alison Schofield <[email protected]>
> 
> Using the bash variable 'SECONDS' plus 1 for searching the
> dmesg log sometimes led to one test picking up error messages
> from the previous test when run as a suite. SECONDS alone may
> miss some logs, but SECONDS + 1 is just as often too great.
> 
> Since unit tests in the CXL suite are using common helpers to
> start and stop work, initialize and use a "starttime" variable
> with millisecond granularity for journalctl.
> 
> Signed-off-by: Alison Schofield <[email protected]>
> ---
>  test/common | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/test/common b/test/common
> index c20b7e48c2b6..93a280c7c150 100644
> --- a/test/common
> +++ b/test/common
> @@ -156,7 +156,7 @@ check_dmesg()
>  cxl_check_dmesg()
>  {
>         sleep 1
> -       log=$(journalctl -r -k --since "-$((SECONDS+1))s")
> +       log=$(journalctl -r -k --since "$starttime")

Once this is moved to the geenric helper, the other check_dmesg() will
get this benefit too, not just the cxl version :)

It might be worth adding a check to see if $starttime has been set, and
erroring out if not, in case a future test tries to use this, but
doesn't realize that they should've also used the common start helper.

>         # validate no WARN or lockdep report during the run
>         grep -q "Call Trace" <<< "$log" && err "$1"
>         # validate no failures of the interleave calc dev_dbg() check
> @@ -175,6 +175,7 @@ cxl_common_start()
>         check_prereq "dd"
>         check_prereq "sha256sum"
>         modprobe -r cxl_test
> +       starttime=$(date +"%T.%3N")
>         modprobe cxl_test "$1"
>         rc=1
>  }

Reply via email to