All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: vishal.l.verma@intel.com
Cc: nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org
Subject: [ndctl PATCH v3 03/16] ndctl/test: Move 'reset()' to function in 'common'
Date: Wed, 05 Jan 2022 13:31:55 -0800	[thread overview]
Message-ID: <164141831509.3990253.14783946910211635678.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <164141829899.3990253.17547886681174580434.stgit@dwillia2-desk3.amr.corp.intel.com>

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.

Signed-off-by: Dan Williams <dan.j.williams@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 09c4aae146a6..b6d3808969f1 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 8e0b489a8eca..65b5c58bb236 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 4e59f57aea7c..5a20d26fe6d5 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 bf1ea54af9d2..be538b761151 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 fb9d52c837d4..c4d02d54714d 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 6bcefcad9bf9..3c54d633251f 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 b0fd99f1e7b1..e9baaa075a28 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 198779a851b4..d319a3939ac5 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 9547d781162b..e13453dfaa73 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 8cc9c41b57ca..93ce166e6255 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 7d0b8269f5db..fd823b6cfa13 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 343f3c9eac49..47a921f5edf2 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 28c55415c819..14450a7b23e3 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 b343a3869f9c..04070adb18e4 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 0ade2e52a8ad..631489797087 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 4225c3bce0c7..20657801fc0e 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 1686de3552f1..51bbd731fb55 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 7a2faeae8a2d..439ef331adaf 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 be3cf9c07a0a..3bacd2c24787 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
 


  parent reply	other threads:[~2022-01-05 21:31 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
2022-01-05 21:31 ` [ndctl PATCH v3 01/16] ndctl/docs: Clarify update-firwmware activation 'overflow' conditions Dan Williams
2022-01-05 21:31 ` [ndctl PATCH v3 02/16] ndctl/test: Prepare for BLK-aperture support removal Dan Williams
2022-01-05 21:31 ` Dan Williams [this message]
2022-01-05 21:32 ` [ndctl PATCH v3 04/16] ndctl/test: Initialize the label area by default Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 05/16] ndctl/test: Skip BLK flags checks Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 06/16] ndctl/test: Move sector-mode to a different region Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 07/16] ndctl: Deprecate BLK aperture support Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 08/16] ndctl/test: Fix support for missing dax_pmem_compat module Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 09/16] util: Distribute 'filter' and 'json' helpers to per-tool objects Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 10/16] Documentation: Drop attrs.adoc include Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 11/16] build: Drop unnecessary $tool/config.h includes Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 12/16] test: Prepare out of line builds Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 13/16] ndctl: Drop executable bit for bash-completion script Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 14/16] build: Add meson build infrastructure Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 15/16] build: Add meson rpmbuild support Dan Williams
2022-01-05 21:33 ` [ndctl PATCH v3 16/16] ndctl: Jettison autotools Dan Williams
2022-01-12 13:54 ` [ndctl PATCH v3 00/16] ndctl: Meson support Vaibhav Jain
2022-01-13  1:23 ` Alison Schofield
2022-01-14 16:04 ` Verma, Vishal L
2022-01-14 16:55   ` Michal Suchánek
2022-01-14 22:30   ` Jane Chu
2022-01-14 22:47     ` Dan Williams
2022-01-15  1:16       ` Verma, Vishal L

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=164141831509.3990253.14783946910211635678.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=vishal.l.verma@intel.com \
    /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.