ndctl, test: fix tests that use error injection on older kernels
Vishal Verma
maintainerPATCH 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
@@ -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
@@ -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
@@ -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
@@ -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
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.
Reported-by Jacek Zolch <[email protected]>Cc Dan Williams <[email protected]>Signed-off-by Vishal Verma <[email protected]>--- 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@@ -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 $MNTtest/clear.sh +3
-1@@ -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; thentest/daxdev-errors.sh +0
-0
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