Skip to contentSkip to conversation

ndctl, test: fix tests that use error injection on older kernels

PATCH In review Vishal Verma 2 participants 2 messages Feb 21, 2018 – Feb 24, 2018 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Vishal Verma

author maintainer
#0 lore raw

PATCH 1/1 ndctl, test: fix tests that use error injection on older kernels

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.

---
 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(-)
test/btt-errors.sh +1 -1
index 383abb6..ecc1282 100755
@@ -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
test/clear.sh +3 -1
index c22ff3b..9f16397 100755
@@ -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
test/daxdev-errors.sh +3 -1
index d15bd82..4b7373e 100755
@@ -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"
test/pmem-errors.sh +3 -1
index d3e05b0..7b6775b 100755
@@ -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
Signature · 6 lines
2.14.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw
Quoted 51 lines · Vishal Verma

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.

---
 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(-)
test/btt-errors.sh +1 -1
index 383abb6..ecc1282 100755
@@ -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
test/clear.sh +3 -1
index c22ff3b..9f16397 100755
@@ -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
test/daxdev-errors.sh +0 -0
index d15bd82..4b7373e 100755

test/daxdev-errors.sh busdev=$dev · line 86

Quoted 7 lines
test/daxdev-errors.sh +3 -1
@@ -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 [email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm