cxl/test: CXL unit test helpers
[email protected]
maintainercover cxl/test: CXL unit test helpers
From: Alison Schofield <[email protected]>
This set started with the intent of expanding the check_dmesg() to look for the 'calc interleave' failure message that is added to kernel 6.7. It ended up being a bit more than that including a small reorg of some commonly used setup and shutdown commands plus a fixup to a timing issue with the dmesg log searches.
This does not depend upon 6.7 as it is only checking for the existence of the failed message. In fact, it's value at the moment, is probably in the hands of folks developing and testing on 6.7rc* and onward.
This is built upon ndctl origin/pending branch. (base commit below)
Alison Schofield (3):
cxl/test: add and use cxl_common_[start|stop] helpers cxl/test: add a cxl_ derivative of check_dmesg() cxl/test: use an explicit --since time in journalctl
test/common | 37 +++++++++++++++++++++++++++++++++++++ test/cxl-create-region.sh | 16 ++-------------- test/cxl-events.sh | 18 +++--------------- test/cxl-labels.sh | 16 ++-------------- test/cxl-poison.sh | 17 ++--------------- test/cxl-region-sysfs.sh | 16 ++-------------- test/cxl-topology.sh | 16 ++-------------- test/cxl-update-firmware.sh | 17 ++--------------- test/cxl-xor-region.sh | 15 ++------------- 9 files changed, 54 insertions(+), 114 deletions(-)
base-commit: cbf049039482a56c2b66ede3e10d5e9c652890b7
Signature · 1 line
2.37.3
[email protected]
maintainerPATCH 1/3 cxl/test: add and use cxl_common_[start|stop] helpers
From: Alison Schofield <[email protected]>
CXL unit tests use a mostly common set of commands to setup and tear down their test environments. Standardize on a common set and make all unit tests that run as part of the CXL suite use the helpers.
This assures that each test is following the best known practice of set up and tear down, and that each is using the existing common helper - check_dmesg(). It also allows for expansion of the common helpers without the need to touch every unit test.
Note that this makes all tests have the same execution prerequisites, so all tests will skip if a prerequisite for any test is not present. At the moment, the extra prereqs are sha256sum and dd, both used by cxl-update-firmware.sh. The broad requirement is a good thing, in that it enforces correct setup and complete runs of the entire CXL suite.
cxl-security.sh was excluded from this migration as its setup has more in common with the nfit_test and legacy security test than with the other CXL unit tests.
--- test/common | 23 +++++++++++++++++++++++ test/cxl-create-region.sh | 16 ++-------------- test/cxl-events.sh | 18 +++--------------- test/cxl-labels.sh | 16 ++-------------- test/cxl-poison.sh | 17 ++--------------- test/cxl-region-sysfs.sh | 16 ++-------------- test/cxl-topology.sh | 16 ++-------------- test/cxl-update-firmware.sh | 17 ++--------------- test/cxl-xor-region.sh | 15 ++------------- 9 files changed, 40 insertions(+), 114 deletions(-)
test/common +23 -0
@@ -150,3 +150,26 @@ check_dmesg() grep -q "Call Trace" <<< $log && err $1 true } + +# cxl_common_start +# $1: optional module parameter(s) for cxl-test +cxl_common_start() +{ + rc=77 + set -ex + trap 'err $LINENO' ERR + check_prereq "jq" + check_prereq "dd" + check_prereq "sha256sum" + modprobe -r cxl_test + modprobe cxl_test "$1" + rc=1 +} + +# cxl_common_end +# $1: line number where this is called +cxl_common_stop() +{ + check_dmesg "$1" + modprobe -r cxl_test +}
test/cxl-create-region.sh +2 -14
@@ -4,17 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 +cxl_common_start destroy_regions() {
@@ -149,6 +139,4 @@ for mem in ${mems[@]}; do create_subregions "$mem" done -check_dmesg "$LINENO" - -modprobe -r cxl_test +cxl_common_stop "$LINENO"
test/cxl-events.sh +3 -15
@@ -4,24 +4,14 @@ . "$(dirname "$0")/common" +cxl_common_start + # Results expected num_overflow_expected=1 num_fatal_expected=2 num_failure_expected=16 num_info_expected=3 -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 - dev_path="/sys/bus/platform/devices" test_cxl_events()
@@ -74,6 +64,4 @@ if [ "$num_info" -ne $num_info_expected ]; then err "$LINENO" fi -check_dmesg "$LINENO" - -modprobe -r cxl_test +cxl_common_stop "$LINENO"
test/cxl-labels.sh +2 -14
@@ -4,17 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 +cxl_common_start test_label_ops() {
@@ -66,6 +56,4 @@ for nmem in ${nmems[@]}; do test_label_ops "$nmem" done -check_dmesg "$LINENO" - -modprobe -r cxl_test +cxl_common_stop "$LINENO"
test/cxl-poison.sh +2 -15
@@ -4,18 +4,7 @@ . "$(dirname "$0")"/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test - -rc=1 +cxl_common_start # THEORY OF OPERATION: Exercise cxl-cli and cxl driver ability to # inject, clear, and get the poison list. Do it by memdev and by region.
@@ -153,6 +142,4 @@ echo 1 > /sys/kernel/tracing/events/cxl/cxl_poison/enable test_poison_by_memdev test_poison_by_region -check_dmesg "$LINENO" - -modprobe -r cxl-test +cxl_common_stop "$LINENO"
test/cxl-region-sysfs.sh +2 -14
@@ -4,17 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 +cxl_common_start # THEORY OF OPERATION: Create a x8 interleave across the pmem capacity # of the 8 endpoints defined by cxl_test, commit the decoders (which
@@ -163,6 +153,4 @@ readarray -t endpoint < <($CXL free-dpa -t pmem ${mem[*]} | jq -r ".[] | .decoder.decoder") echo "$region released ${#endpoint[@]} targets: ${endpoint[@]}" -check_dmesg "$LINENO" - -modprobe -r cxl_test +cxl_common_stop "$LINENO"
test/cxl-topology.sh +2 -14
@@ -4,17 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 +cxl_common_start # THEORY OF OPERATION: Validate the hard coded assumptions of the # cxl_test.ko module that defines its topology in
@@ -187,6 +177,4 @@ done # validate that the bus can be disabled without issue $CXL disable-bus $root -f -check_dmesg "$LINENO" - -modprobe -r cxl_test +cxl_common_stop "$LINENO"
test/cxl-update-firmware.sh +2 -15
@@ -4,19 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" -check_prereq "dd" -check_prereq "sha256sum" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 +cxl_common_start mk_fw_file() {
@@ -192,5 +180,4 @@ test_nonblocking_update test_multiple_memdev test_cancel -check_dmesg "$LINENO" -modprobe -r cxl_test +cxl_common_stop "$LINENO"
test/cxl-xor-region.sh +2 -13
@@ -4,18 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test interleave_arithmetic=1 -udevadm settle -rc=1 +cxl_common_start "interleave_arithmetic=1" # THEORY OF OPERATION: Create x1,2,3,4 regions to exercise the XOR math # option of the CXL driver. As with other cxl_test tests, changes to the
@@ -93,4 +82,4 @@ create_and_destroy_region setup_x4 create_and_destroy_region -modprobe -r cxl_test +cxl_common_stop "$LINENO"
Signature · 1 line
2.37.3
Re: [ndctl PATCH 1/3] cxl/test: add and use cxl_common_[start|stop] helpers
Quoted 17 lines · On 11/27/23 21:11, [email protected] wrote:
From: Alison Schofield <[email protected]>
CXL unit tests use a mostly common set of commands to setup and tear down their test environments. Standardize on a common set and make all unit tests that run as part of the CXL suite use the helpers.
This assures that each test is following the best known practice of set up and tear down, and that each is using the existing common helper -
check_dmesg(). It also allows for expansion of the common helpers without the need to touch every unit test.Note that this makes all tests have the same execution prerequisites, so all tests will skip if a prerequisite for any test is not present. At the moment, the extra prereqs are sha256sum and dd, both used by
cxl-update-firmware.sh. The broad requirement is a good thing, in that it enforces correct setup and complete runs of the entire CXL suite.
Quoted 5 lines
cxl-security.shwas excluded from this migration as its setup has more in common with thenfit_testand legacy security test than with the other CXL unit tests.Signed-off-by Alison Schofield <[email protected]>
Quoted 300 lines
--- test/common | 23 +++++++++++++++++++++++ test/cxl-create-region.sh | 16 ++-------------- test/cxl-events.sh | 18 +++--------------- test/cxl-labels.sh | 16 ++-------------- test/cxl-poison.sh | 17 ++--------------- test/cxl-region-sysfs.sh | 16 ++-------------- test/cxl-topology.sh | 16 ++-------------- test/cxl-update-firmware.sh | 17 ++--------------- test/cxl-xor-region.sh | 15 ++------------- 9 files changed, 40 insertions(+), 114 deletions(-)test/common +23
-0@@ -150,3 +150,26 @@ check_dmesg() grep -q "Call Trace" <<< $log && err $1 true } + +# cxl_common_start +# $1: optional module parameter(s) for cxl-test +cxl_common_start() +{ + rc=77 + set -ex + trap 'err $LINENO' ERR + check_prereq "jq" + check_prereq "dd" + check_prereq "sha256sum" + modprobe -r cxl_test + modprobe cxl_test "$1" + rc=1 +} + +# cxl_common_end +# $1: line number where this is called +cxl_common_stop() +{ + check_dmesg "$1" + modprobe -r cxl_test +}test/cxl-create-region.sh +2
-14@@ -4,17 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 +cxl_common_start destroy_regions() {@@ -149,6 +139,4 @@ for mem in ${mems[@]}; do create_subregions "$mem" done -check_dmesg "$LINENO" - -modprobe -r cxl_test +cxl_common_stop "$LINENO"test/cxl-events.sh +3
-15@@ -4,24 +4,14 @@ . "$(dirname "$0")/common" +cxl_common_start + # Results expected num_overflow_expected=1 num_fatal_expected=2 num_failure_expected=16 num_info_expected=3 -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 - dev_path="/sys/bus/platform/devices" test_cxl_events()@@ -74,6 +64,4 @@ if [ "$num_info" -ne $num_info_expected ]; then err "$LINENO" fi -check_dmesg "$LINENO" - -modprobe -r cxl_test +cxl_common_stop "$LINENO"test/cxl-labels.sh +2
-14@@ -4,17 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 +cxl_common_start test_label_ops() {@@ -66,6 +56,4 @@ for nmem in ${nmems[@]}; do test_label_ops "$nmem" done -check_dmesg "$LINENO" - -modprobe -r cxl_test +cxl_common_stop "$LINENO"test/cxl-poison.sh +2
-15@@ -4,18 +4,7 @@ . "$(dirname "$0")"/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test - -rc=1 +cxl_common_start # THEORY OF OPERATION: Exercise cxl-cli and cxl driver ability to # inject, clear, and get the poison list. Do it by memdev and by region.@@ -153,6 +142,4 @@ echo 1 > /sys/kernel/tracing/events/cxl/cxl_poison/enable test_poison_by_memdev test_poison_by_region -check_dmesg "$LINENO" - -modprobe -r cxl-test +cxl_common_stop "$LINENO"test/cxl-region-sysfs.sh +2
-14@@ -4,17 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 +cxl_common_start # THEORY OF OPERATION: Create a x8 interleave across the pmem capacity # of the 8 endpoints defined by cxl_test, commit the decoders (which@@ -163,6 +153,4 @@ readarray -t endpoint < <($CXL free-dpa -t pmem ${mem[*]} | jq -r ".[] | .decoder.decoder") echo "$region released ${#endpoint[@]} targets: ${endpoint[@]}" -check_dmesg "$LINENO" - -modprobe -r cxl_test +cxl_common_stop "$LINENO"test/cxl-topology.sh +2
-14@@ -4,17 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 +cxl_common_start # THEORY OF OPERATION: Validate the hard coded assumptions of the # cxl_test.ko module that defines its topology in@@ -187,6 +177,4 @@ done # validate that the bus can be disabled without issue $CXL disable-bus $root -f -check_dmesg "$LINENO" - -modprobe -r cxl_test +cxl_common_stop "$LINENO"test/cxl-update-firmware.sh +2
-15@@ -4,19 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" -check_prereq "dd" -check_prereq "sha256sum" - -modprobe -r cxl_test -modprobe cxl_test -rc=1 +cxl_common_start mk_fw_file() {@@ -192,5 +180,4 @@ test_nonblocking_update test_multiple_memdev test_cancel -check_dmesg "$LINENO" -modprobe -r cxl_test +cxl_common_stop "$LINENO"test/cxl-xor-region.sh +2
-13@@ -4,18 +4,7 @@ . $(dirname $0)/common -rc=77 - -set -ex - -trap 'err $LINENO' ERR - -check_prereq "jq" - -modprobe -r cxl_test -modprobe cxl_test interleave_arithmetic=1 -udevadm settle -rc=1 +cxl_common_start "interleave_arithmetic=1" # THEORY OF OPERATION: Create x1,2,3,4 regions to exercise the XOR math # option of the CXL driver. As with other cxl_test tests, changes to the@@ -93,4 +82,4 @@ create_and_destroy_region setup_x4 create_and_destroy_region -modprobe -r cxl_test +cxl_common_stop "$LINENO"
Verma, Vishal L
maintainerRe: [ndctl PATCH 1/3] cxl/test: add and use cxl_common_[start|stop] helpers
In reply to [email protected]Quoted 45 lines · On Mon, 2023-11-27 at 20:11 -0800, [email protected] wrote:
From: Alison Schofield <[email protected]>
CXL unit tests use a mostly common set of commands to setup and tear down their test environments. Standardize on a common set and make all unit tests that run as part of the CXL suite use the helpers.
This assures that each test is following the best known practice of set up and tear down, and that each is using the existing common helper -
check_dmesg(). It also allows for expansion of the common helpers without the need to touch every unit test.Note that this makes all tests have the same execution prerequisites, so all tests will skip if a prerequisite for any test is not present. At the moment, the extra prereqs are sha256sum and dd, both used by
cxl-update-firmware.sh. The broad requirement is a good thing, in that it enforces correct setup and complete runs of the entire CXL suite.
cxl-security.shwas excluded from this migration as its setup has more in common with thenfit_testand legacy security test than with the other CXL unit tests.Signed-off-by Alison Schofield <[email protected]>---
test/common | 23 +++++++++++++++++++++++ test/cxl-create-region.sh | 16 ++--------------test/cxl-events.sh | 18 +++--------------- test/cxl-labels.sh | 16 ++-------------- test/cxl-poison.sh | 17 ++---------------test/cxl-region-sysfs.sh | 16 ++-------------- test/cxl-topology.sh | 16 ++--------------
test/cxl-update-firmware.sh| 17 ++--------------- test/cxl-xor-region.sh | 15 ++-------------9 files changed, 40 insertions(+), 114 deletions(-)test/common +0
-0@@ -150,3 +150,26 @@ check_dmesg()grep -q "Call Trace" <<< $log && err $1
true
}test/common +3
-0+ +# cxl_common_start +# $1: optional module parameter(s) for cxl-test
test/common check_dmesg() · line 165
Quoted 10 lines
test/common +10
-0+cxl_common_start() +{ + rc=77 + set -ex + trap 'err $LINENO' ERR + check_prereq "jq" + check_prereq "dd" + check_prereq "sha256sum" + modprobe -r cxl_test + modprobe cxl_test "$1"
This should use "$@". $1 will break if multiple parameters need to be passed (currently we only ever pass one, so it happens to work, but if a second param ever gets added this will be surprising).
Rest of this looks good, thanks for doing this cleanup!
[email protected]
maintainerPATCH 2/3 cxl/test: add a cxl_ derivative of check_dmesg()
In reply to [email protected]From: Alison Schofield <[email protected]>
check_dmesg() is used by CXL unit tests as well as by a few DAX unit tests. Add a cxl_check_dmesg() version that can be expanded for CXL special checks like this:
Add a check for an interleave calculation failure. This is a dev_dbg() message that spews (success or failure) whenever a user creates a region. It is useful as a regression check across the entire CXL suite.
--- test/common | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
test/common +14 -1
@@ -151,6 +151,19 @@ check_dmesg() true } +# cxl_check_dmesg +# $1: line number where this is called +cxl_check_dmesg() +{ + sleep 1 + log=$(journalctl -r -k --since "-$((SECONDS+1))s") + # 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 + grep -q "Test cxl_calc_interleave_pos(): fail" <<< "$log" && err "$1" + true +} + # cxl_common_start # $1: optional module parameter(s) for cxl-test cxl_common_start()
@@ -170,6 +183,6 @@ cxl_common_start() # $1: line number where this is called cxl_common_stop() { - check_dmesg "$1" + cxl_check_dmesg "$1" modprobe -r cxl_test }
Signature · 1 line
2.37.3
Re: [ndctl PATCH 2/3] cxl/test: add a cxl_ derivative of check_dmesg()
Quoted 6 lines · On 11/27/23 21:11, [email protected] wrote:
From: Alison Schofield <[email protected]>
check_dmesg()is used by CXL unit tests as well as by a few DAX unit tests. Add acxl_check_dmesg()version that can be expanded for CXL special checks like this:
Quoted 6 lines
Add a check for an interleave calculation failure. This is a
dev_dbg()message that spews (success or failure) whenever a user creates a region. It is useful as a regression check across the entire CXL suite.Signed-off-by Alison Schofield <[email protected]>
Quoted 36 lines
--- test/common | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)test/common +14
-1@@ -151,6 +151,19 @@ check_dmesg() true } +# cxl_check_dmesg +# $1: line number where this is called +cxl_check_dmesg() +{ + sleep 1 + log=$(journalctl -r -k --since "-$((SECONDS+1))s") + # 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 + grep -q "Test cxl_calc_interleave_pos(): fail" <<< "$log" && err "$1" + true +} + # cxl_common_start # $1: optional module parameter(s) for cxl-test cxl_common_start()@@ -170,6 +183,6 @@ cxl_common_start() # $1: line number where this is called cxl_common_stop() { - check_dmesg "$1" + cxl_check_dmesg "$1" modprobe -r cxl_test }
Verma, Vishal L
maintainerRe: [ndctl PATCH 2/3] cxl/test: add a cxl_ derivative of check_dmesg()
In reply to [email protected]Quoted 26 lines · On Mon, 2023-11-27 at 20:11 -0800, [email protected] wrote:
From: Alison Schofield <[email protected]>
check_dmesg()is used by CXL unit tests as well as by a few DAX unit tests. Add acxl_check_dmesg()version that can be expanded for CXL special checks like this:Add a check for an interleave calculation failure. This is a
dev_dbg()message that spews (success or failure) whenever a user creates a region. It is useful as a regression check across the entire CXL suite.Signed-off-by Alison Schofield <[email protected]>---
test/common | 15 ++++++++++++++-1 file changed, 14 insertions(+), 1 deletion(-)test/common +0
-0@@ -151,6 +151,19 @@ check_dmesg()true
}test/common +2
-0+# cxl_check_dmesg +# $1: line number where this is called
test/common check_dmesg() · line 165
Quoted 10 lines
test/common +10
-0+cxl_check_dmesg() +{ + sleep 1 + log=$(journalctl -r -k --since "-$((SECONDS+1))s") + # 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 + grep -q "Test cxl_calc_interleave_pos(): fail" <<< "$log" && err "$1" + true +}
I like the idea of adding new checks - how about a generic helper that greps on a list of strings passed to it, and wrappers on top of it can have their own custom set of strings.
Something like this (untested):
# __check_dmesg
# $1: line number where this is called
# $2.. : strings to check for__check_dmesg()
{
line="$1"
shift
strings=( "$@" )
sleep 1
log=$(journalctl -r -k --since "-$((SECONDS+1))s")
for string in "${strings[@]}"; do
if grep -q "$string" <<< $log; then
err "$line"
fi
done
true
}check_dmesg()
{
line="$1"
shift
strings=( "$@" )
__check_dmesg "$line" "Call Trace" "${strings[@]}"
}cxl_check_dmesg()
{
line="$1"
shift
strings=( "$@" )
check_dmesg "$line" \
"Test cxl_calc_interleave_pos(): fail" \
"${strings[@]}"
}This lets tests opt in to any 'level' of checks, and lets them add any of their own test-specific strings to be checked at any stage as well.
Quoted 12 lines
+
# cxl_common_start # $1: optional module parameter(s) for cxl-test cxl_common_start()test/common +1
-1@@ -170,6 +183,6 @@ cxl_common_start() # $1: line number where this is called cxl_common_stop() { - check_dmesg "$1" + cxl_check_dmesg "$1"modprobe -r
cxl_test
}
[email protected]
maintainerPATCH 3/3 cxl/test: use an explicit --since time in journalctl
In reply to [email protected]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.
--- test/common | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
test/common +2 -1
@@ -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 }
Signature · 1 line
2.37.3
Re: [ndctl PATCH 3/3] cxl/test: use an explicit --since time in journalctl
Quoted 7 lines · On 11/27/23 21:11, [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.
Quoted 5 lines
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]>
Quoted 25 lines
--- test/common | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)test/common +2
-1@@ -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
maintainerRe: [ndctl PATCH 3/3] cxl/test: use an explicit --since time in journalctl
In reply to [email protected]Quoted 23 lines · 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(-)test/common +0
-0@@ -156,7 +156,7 @@ check_dmesg() cxl_check_dmesg() {
Quoted 3 lines
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.
Quoted 11 lines
# 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() checktest/common +0
-0@@ -175,6 +175,7 @@ cxl_common_start()check_prereq "dd"
check_prereq "sha256sum"
modprobe -rcxl_test
+ starttime=$(date +"%T.%3N")
modprobecxl_test"$1"
rc=1
}