ndctl/0071-ndctl-test-Move-reset-to-function-in-common.patch
Jeff Moyer 2c91dc1bcd Backport changes up to v74, excluding the config file changes
This includes support for the CXL commands, and adds the following
packages: cxl-cli, cxl-devel, cxl-libs.

Resolves: rhbz#2132167
2022-10-13 16:55:42 -04:00

429 lines
11 KiB
Diff

From 6538529be5738f06543a0d7178f97e0b0e6b63c2 Mon Sep 17 00:00:00 2001
From: Dan Williams <dan.j.williams@intel.com>
Date: Wed, 5 Jan 2022 13:31:55 -0800
Subject: [PATCH 071/217] ndctl/test: Move 'reset()' to function in 'common'
When BLK mode is removed, tests that expect the nfit_test region to allow
pmem namespace creation will need to 'init' rather than 'zero' labels. In
preparation, take the time opportunity to move reset() to a common
function. So that 'ndctl zero-labels' can be replaced with 'ndctl
init-labels' in one central location.
Link: https://lore.kernel.org/r/164141831509.3990253.14783946910211635678.stgit@dwillia2-desk3.amr.corp.intel.com
Tested-by: Alison Schofield <alison.schofield@intel.com>
Tested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
test/blk-exhaust.sh | 4 +---
test/btt-check.sh | 7 -------
test/btt-errors.sh | 12 +++---------
test/btt-pad-compat.sh | 7 -------
test/clear.sh | 4 +---
test/common | 15 +++++++++++++++
test/create.sh | 4 +---
test/daxctl-create.sh | 4 ++--
test/daxdev-errors.sh | 4 +---
test/firmware-update.sh | 8 +++-----
test/inject-error.sh | 7 -------
test/max_available_extent_ns.sh | 9 +--------
test/monitor.sh | 11 ++---------
test/multi-dax.sh | 4 +---
test/pfn-meta-errors.sh | 4 +---
test/pmem-errors.sh | 4 +---
test/rescan-partitions.sh | 7 -------
test/sector-mode.sh | 9 ++-------
test/track-uuid.sh | 4 +---
19 files changed, 36 insertions(+), 92 deletions(-)
diff --git a/test/blk-exhaust.sh b/test/blk-exhaust.sh
index 09c4aae..b6d3808 100755
--- a/test/blk-exhaust.sh
+++ b/test/blk-exhaust.sh
@@ -14,9 +14,7 @@ trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
# if the kernel accounting is correct we should be able to create two
# pmem and two blk namespaces on nfit_test.0
diff --git a/test/btt-check.sh b/test/btt-check.sh
index 8e0b489..65b5c58 100755
--- a/test/btt-check.sh
+++ b/test/btt-check.sh
@@ -39,13 +39,6 @@ create()
[ $size -gt 0 ] || err "$LINENO"
}
-reset()
-{
- $NDCTL disable-region -b $NFIT_TEST_BUS0 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
- $NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
# re-enable the BTT namespace, and do IO to it in an attempt to
# verify it still comes up ok, and functions as expected
post_repair_test()
diff --git a/test/btt-errors.sh b/test/btt-errors.sh
index 4e59f57..5a20d26 100755
--- a/test/btt-errors.sh
+++ b/test/btt-errors.sh
@@ -45,9 +45,7 @@ trap 'err $LINENO cleanup' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1
@@ -126,9 +124,7 @@ dd if=$MNT/$FILE of=/dev/null iflag=direct bs=4096 count=1
# reset everything to get a clean log
if grep -q "$MNT" /proc/mounts; then umount $MNT; fi
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
dev="x"
json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m sector)
eval "$(echo "$json" | json2var)"
@@ -148,9 +144,7 @@ force_raw 0
dd if=/dev/$blockdev of=/dev/null iflag=direct bs=4096 count=1 && err $LINENO || true
# done, exit
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
cleanup
_cleanup
exit 0
diff --git a/test/btt-pad-compat.sh b/test/btt-pad-compat.sh
index bf1ea54..be538b7 100755
--- a/test/btt-pad-compat.sh
+++ b/test/btt-pad-compat.sh
@@ -37,13 +37,6 @@ create()
fi
}
-reset()
-{
- $NDCTL disable-region -b $NFIT_TEST_BUS0 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
- $NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
verify_idx()
{
idx0="$1"
diff --git a/test/clear.sh b/test/clear.sh
index fb9d52c..c4d02d5 100755
--- a/test/clear.sh
+++ b/test/clear.sh
@@ -14,9 +14,7 @@ trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1
diff --git a/test/common b/test/common
index 6bcefca..3c54d63 100644
--- a/test/common
+++ b/test/common
@@ -46,6 +46,21 @@ err()
exit $rc
}
+reset()
+{
+ $NDCTL disable-region -b $NFIT_TEST_BUS0 all
+ $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
+ $NDCTL enable-region -b $NFIT_TEST_BUS0 all
+}
+
+reset1()
+{
+ $NDCTL disable-region -b $NFIT_TEST_BUS1 all
+ $NDCTL zero-labels -b $NFIT_TEST_BUS1 all
+ $NDCTL enable-region -b $NFIT_TEST_BUS1 all
+}
+
+
# check_min_kver
# $1: Supported kernel version. format: X.Y
#
diff --git a/test/create.sh b/test/create.sh
index b0fd99f..e9baaa0 100755
--- a/test/create.sh
+++ b/test/create.sh
@@ -15,9 +15,7 @@ trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1
diff --git a/test/daxctl-create.sh b/test/daxctl-create.sh
index 198779a..d319a39 100755
--- a/test/daxctl-create.sh
+++ b/test/daxctl-create.sh
@@ -10,7 +10,7 @@ trap 'cleanup $LINENO' ERR
cleanup()
{
printf "Error at line %d\n" "$1"
- [[ $testdev ]] && reset
+ [[ $testdev ]] && reset_dax
exit $rc
}
@@ -70,7 +70,7 @@ reset_dev()
"$DAXCTL" enable-device "$testdev"
}
-reset()
+reset_dax()
{
test -n "$testdev"
diff --git a/test/daxdev-errors.sh b/test/daxdev-errors.sh
index 9547d78..e13453d 100755
--- a/test/daxdev-errors.sh
+++ b/test/daxdev-errors.sh
@@ -15,9 +15,7 @@ trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1
diff --git a/test/firmware-update.sh b/test/firmware-update.sh
index 8cc9c41..93ce166 100755
--- a/test/firmware-update.sh
+++ b/test/firmware-update.sh
@@ -10,11 +10,9 @@ image="update-fw.img"
trap 'err $LINENO' ERR
-reset()
+fwupd_reset()
{
- $NDCTL disable-region -b $NFIT_TEST_BUS0 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
- $NDCTL enable-region -b $NFIT_TEST_BUS0 all
+ reset
if [ -f $image ]; then
rm -f $image
fi
@@ -73,7 +71,7 @@ do_tests()
check_min_kver "4.16" || do_skip "may lack firmware update test handling"
modprobe nfit_test
-reset
+fwupd_reset
detect
rc=1
do_tests
diff --git a/test/inject-error.sh b/test/inject-error.sh
index 7d0b826..fd823b6 100755
--- a/test/inject-error.sh
+++ b/test/inject-error.sh
@@ -37,13 +37,6 @@ create()
[ $size -gt 0 ] || err "$LINENO"
}
-reset()
-{
- $NDCTL disable-region -b $NFIT_TEST_BUS0 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
- $NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
check_status()
{
local sector="$1"
diff --git a/test/max_available_extent_ns.sh b/test/max_available_extent_ns.sh
index 343f3c9..47a921f 100755
--- a/test/max_available_extent_ns.sh
+++ b/test/max_available_extent_ns.sh
@@ -11,13 +11,6 @@ trap 'err $LINENO' ERR
check_min_kver "4.19" || do_skip "kernel $KVER may not support max_available_size"
check_prereq "jq"
-init()
-{
- $NDCTL disable-region -b $NFIT_TEST_BUS0 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
- $NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
do_test()
{
region=$($NDCTL list -b $NFIT_TEST_BUS0 -R -t pmem | jq -r 'sort_by(-.size) | .[].dev' | head -1)
@@ -40,7 +33,7 @@ do_test()
modprobe nfit_test
rc=1
-init
+reset
do_test
_cleanup
exit 0
diff --git a/test/monitor.sh b/test/monitor.sh
index c015c11..6aa4196 100755
--- a/test/monitor.sh
+++ b/test/monitor.sh
@@ -19,13 +19,6 @@ trap 'err $LINENO' ERR
check_min_kver "4.15" || do_skip "kernel $KVER may not support monitor service"
-init()
-{
- $NDCTL disable-region -b $NFIT_TEST_BUS0 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
- $NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
start_monitor()
{
logfile=$(mktemp)
@@ -112,7 +105,7 @@ test_filter_region()
test_filter_namespace()
{
- init
+ reset
monitor_namespace=$($NDCTL create-namespace -b $smart_supported_bus | jq -r .dev)
monitor_dimms=$(get_monitor_dimm "-n $monitor_namespace")
start_monitor "-n $monitor_namespace"
@@ -170,7 +163,7 @@ do_tests()
modprobe nfit_test
rc=1
-init
+reset
set_smart_supported_bus
do_tests
_cleanup
diff --git a/test/multi-dax.sh b/test/multi-dax.sh
index b343a38..04070ad 100755
--- a/test/multi-dax.sh
+++ b/test/multi-dax.sh
@@ -17,9 +17,7 @@ ALIGN_SIZE=`getconf PAGESIZE`
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1
query=". | sort_by(.available_size) | reverse | .[0].dev"
diff --git a/test/pfn-meta-errors.sh b/test/pfn-meta-errors.sh
index 0ade2e5..6314897 100755
--- a/test/pfn-meta-errors.sh
+++ b/test/pfn-meta-errors.sh
@@ -29,9 +29,7 @@ trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1
diff --git a/test/pmem-errors.sh b/test/pmem-errors.sh
index 4225c3b..2065780 100755
--- a/test/pmem-errors.sh
+++ b/test/pmem-errors.sh
@@ -28,9 +28,7 @@ trap 'err $LINENO cleanup' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1
diff --git a/test/rescan-partitions.sh b/test/rescan-partitions.sh
index 1686de3..51bbd73 100755
--- a/test/rescan-partitions.sh
+++ b/test/rescan-partitions.sh
@@ -25,13 +25,6 @@ check_min_kver "4.16" || do_skip "may not contain fixes for partition rescanning
check_prereq "parted"
check_prereq "blockdev"
-reset()
-{
- $NDCTL disable-region -b $NFIT_TEST_BUS0 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
- $NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
test_mode()
{
local mode="$1"
diff --git a/test/sector-mode.sh b/test/sector-mode.sh
index 7a2faea..439ef33 100755
--- a/test/sector-mode.sh
+++ b/test/sector-mode.sh
@@ -15,13 +15,8 @@ ALIGN_SIZE=`getconf PAGESIZE`
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
-
-$NDCTL disable-region -b $NFIT_TEST_BUS1 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS1 all
-$NDCTL enable-region -b $NFIT_TEST_BUS1 all
+reset
+reset1
rc=1
query=". | sort_by(.size) | reverse | .[0].dev"
diff --git a/test/track-uuid.sh b/test/track-uuid.sh
index be3cf9c..3bacd2c 100755
--- a/test/track-uuid.sh
+++ b/test/track-uuid.sh
@@ -12,9 +12,7 @@ trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1
--
2.27.0