diff mbox series

[ndctl,3/3] cxl/test: use an explicit --since time in journalctl

Message ID 1802cf15f22fe5c284167a9186eba8f2cd3c31c6.1701143039.git.alison.schofield@intel.com (mailing list archive)
State New, archived
Headers show
Series cxl/test: CXL unit test helpers | expand

Commit Message

Alison Schofield Nov. 28, 2023, 4:11 a.m. UTC
From: Alison Schofield <alison.schofield@intel.com>

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 <alison.schofield@intel.com>
---
 test/common | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Dave Jiang Nov. 28, 2023, 6:19 p.m. UTC | #1
On 11/27/23 21:11, alison.schofield@intel.com wrote:
> From: Alison Schofield <alison.schofield@intel.com>
> 
> 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 <alison.schofield@intel.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> ---
>  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")
>  	# 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
>  }
Verma, Vishal L Nov. 28, 2023, 10:18 p.m. UTC | #2
On Mon, 2023-11-27 at 20:11 -0800, alison.schofield@intel.com wrote:
> From: Alison Schofield <alison.schofield@intel.com>
> 
> 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 <alison.schofield@intel.com>
> ---
>  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
>  }
diff mbox series

Patch

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")
 	# 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
 }