All of lore.kernel.org
 help / color / mirror / Atom feed
* [ndctl PATCH] ndctl, test: fix tests that use error injection on older kernels
@ 2018-02-21 23:20 Vishal Verma
  2018-02-24  0:29 ` Dan Williams
  0 siblings, 1 reply; 2+ messages in thread
From: Vishal Verma @ 2018-02-21 23:20 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: jacek.zloch

When we updated from using canned badblocks to injected errors in
nfit_test, we ended up breaking the tests for older kernels that didn't
have error injection capabilities.

Fix this by first checking if badblocks already exist. If they do, we
have an older kernel with canned badblocks, and we can simply use those.
If not, then apttempt to inject them as needed.

Reported-by: Jacek Zolch <jacek.zloch@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 test/btt-errors.sh    | 2 +-
 test/clear.sh         | 4 +++-
 test/daxdev-errors.sh | 4 +++-
 test/pmem-errors.sh   | 4 +++-
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/test/btt-errors.sh b/test/btt-errors.sh
index 383abb6..ecc1282 100755
--- a/test/btt-errors.sh
+++ b/test/btt-errors.sh
@@ -59,7 +59,7 @@ force_raw()
 	fi
 }
 
-check_min_kver "4.14" || { echo "kernel $KVER may lack BTT error handling"; exit $rc; }
+check_min_kver "4.15" || { echo "kernel $KVER may lack BTT error handling"; exit $rc; }
 
 set -e
 mkdir -p $MNT
diff --git a/test/clear.sh b/test/clear.sh
index c22ff3b..9f16397 100755
--- a/test/clear.sh
+++ b/test/clear.sh
@@ -57,7 +57,9 @@ eval $(echo $json | sed -e "$json2var")
 # inject errors in the middle of the namespace, verify that reading fails
 err_sector="$(((size/512) / 2))"
 err_count=8
-$NDCTL inject-error --block="$err_sector" --count=$err_count $dev
+if [ ! -e /sys/block/$blockdev/badblocks ]; then
+	$NDCTL inject-error --block="$err_sector" --count=$err_count $dev
+fi
 read sector len < /sys/block/$blockdev/badblocks
 [ $((sector * 2)) -ne $((size /512)) ] && echo "fail: $LINENO" && exit 1
 if dd if=/dev/$blockdev of=/dev/null iflag=direct bs=512 skip=$sector count=$len; then
diff --git a/test/daxdev-errors.sh b/test/daxdev-errors.sh
index d15bd82..4b7373e 100755
--- a/test/daxdev-errors.sh
+++ b/test/daxdev-errors.sh
@@ -81,7 +81,9 @@ busdev=$dev
 # inject errors in the middle of the namespace
 err_sector="$(((size/512) / 2))"
 err_count=8
-$NDCTL inject-error --block="$err_sector" --count=$err_count $nsdev
+if [ ! -e /sys/block/$blockdev/badblocks ]; then
+	$NDCTL inject-error --block="$err_sector" --count=$err_count $nsdev
+fi
 
 read sector len < /sys/bus/nd/devices/$region/badblocks
 echo "sector: $sector len: $len"
diff --git a/test/pmem-errors.sh b/test/pmem-errors.sh
index d3e05b0..7b6775b 100755
--- a/test/pmem-errors.sh
+++ b/test/pmem-errors.sh
@@ -57,7 +57,9 @@ eval $(echo $json | sed -e "$json2var")
 # inject errors in the middle of the namespace, verify that reading fails
 err_sector="$(((size/512) / 2))"
 err_count=8
-$NDCTL inject-error --block="$err_sector" --count=$err_count $dev
+if [ ! -e /sys/block/$blockdev/badblocks ]; then
+	$NDCTL inject-error --block="$err_sector" --count=$err_count $dev
+fi
 read sector len < /sys/block/$blockdev/badblocks
 [ $((sector * 2)) -ne $((size /512)) ] && echo "fail: $LINENO" && false
 if dd if=/dev/$blockdev of=/dev/null iflag=direct bs=512 skip=$sector count=$len; then
-- 
2.14.3

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [ndctl PATCH] ndctl, test: fix tests that use error injection on older kernels
  2018-02-21 23:20 [ndctl PATCH] ndctl, test: fix tests that use error injection on older kernels Vishal Verma
@ 2018-02-24  0:29 ` Dan Williams
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Williams @ 2018-02-24  0:29 UTC (permalink / raw)
  To: Vishal Verma; +Cc: Zloch, Jacek, linux-nvdimm

On Wed, Feb 21, 2018 at 3:20 PM, Vishal Verma <vishal.l.verma@intel.com> wrote:
> When we updated from using canned badblocks to injected errors in
> nfit_test, we ended up breaking the tests for older kernels that didn't
> have error injection capabilities.
>
> Fix this by first checking if badblocks already exist. If they do, we
> have an older kernel with canned badblocks, and we can simply use those.
> If not, then apttempt to inject them as needed.
>
> Reported-by: Jacek Zolch <jacek.zloch@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> ---
>  test/btt-errors.sh    | 2 +-
>  test/clear.sh         | 4 +++-
>  test/daxdev-errors.sh | 4 +++-
>  test/pmem-errors.sh   | 4 +++-
>  4 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/test/btt-errors.sh b/test/btt-errors.sh
> index 383abb6..ecc1282 100755
> --- a/test/btt-errors.sh
> +++ b/test/btt-errors.sh
> @@ -59,7 +59,7 @@ force_raw()
>         fi
>  }
>
> -check_min_kver "4.14" || { echo "kernel $KVER may lack BTT error handling"; exit $rc; }
> +check_min_kver "4.15" || { echo "kernel $KVER may lack BTT error handling"; exit $rc; }
>
>  set -e
>  mkdir -p $MNT
> diff --git a/test/clear.sh b/test/clear.sh
> index c22ff3b..9f16397 100755
> --- a/test/clear.sh
> +++ b/test/clear.sh
> @@ -57,7 +57,9 @@ eval $(echo $json | sed -e "$json2var")
>  # inject errors in the middle of the namespace, verify that reading fails
>  err_sector="$(((size/512) / 2))"
>  err_count=8
> -$NDCTL inject-error --block="$err_sector" --count=$err_count $dev
> +if [ ! -e /sys/block/$blockdev/badblocks ]; then
> +       $NDCTL inject-error --block="$err_sector" --count=$err_count $dev
> +fi
>  read sector len < /sys/block/$blockdev/badblocks
>  [ $((sector * 2)) -ne $((size /512)) ] && echo "fail: $LINENO" && exit 1
>  if dd if=/dev/$blockdev of=/dev/null iflag=direct bs=512 skip=$sector count=$len; then
> diff --git a/test/daxdev-errors.sh b/test/daxdev-errors.sh
> index d15bd82..4b7373e 100755
> --- a/test/daxdev-errors.sh
> +++ b/test/daxdev-errors.sh
> @@ -81,7 +81,9 @@ busdev=$dev
>  # inject errors in the middle of the namespace
>  err_sector="$(((size/512) / 2))"
>  err_count=8
> -$NDCTL inject-error --block="$err_sector" --count=$err_count $nsdev
> +if [ ! -e /sys/block/$blockdev/badblocks ]; then
> +       $NDCTL inject-error --block="$err_sector" --count=$err_count $nsdev
> +fi

I don't think this works at all. It seems what you want is to check if
there are *entries* in the badblocks file, not whether the file
exists.

This works for me:

-if [ ! -e /sys/block/$blockdev/badblocks ]; then
+if ! read sector len < /sys/block/$blockdev/badblocks; then
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-24  0:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-21 23:20 [ndctl PATCH] ndctl, test: fix tests that use error injection on older kernels Vishal Verma
2018-02-24  0:29 ` Dan Williams

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.