ndctl, test: Add some global variables and functions to cleanup.
v3 cover ndctl, test: Add some global variables and functions to cleanup.
This is additional cleanup patches for test scripts. Add following global variable and functions to test/common file. Then, cleanup test script to use them.
- NFIT_TEST_BUS[01] (global variable)
Buses are created when nfit_test module is loaded.
- NDCTL (global variable)
ndctl command path (renamed).
- _cleanup
Helper function cleans up nfit_test module.
- json2var
Helper function (filter) converts json to var.
Changelog:
- Fix missing '-b' before $NFIT_TEST_BUS*.
- Fix the subject to "ndctl, test:...".
Masayoshi Mizuma (2):
nfit, test: Add NFIT_TEST_BUS[01] variable and some helper funtions to common nfit, test: cleanup test scripts
test/blk-exhaust.sh | 21 ++++++---------- test/btt-check.sh | 52 ++++++++++++++++++--------------------- test/btt-errors.sh | 30 +++++++++++----------- test/btt-pad-compat.sh | 36 ++++++++++++--------------- test/clear.sh | 25 +++++++------------ test/common | 29 +++++++++++++++++++--- test/create.sh | 26 +++++++++----------- test/daxdev-errors.sh | 29 ++++++++-------------- test/firmware-update.sh | 25 +++++-------------- test/inject-error.sh | 24 ++++++++---------- test/label-compat.sh | 17 +++++-------- test/multi-dax.sh | 23 ++++++----------- test/pmem-errors.sh | 19 +++++--------- test/rescan-partitions.sh | 22 ++++++++--------- test/sector-mode.sh | 22 ++++++----------- 15 files changed, 172 insertions(+), 228 deletions(-)
Signature · 6 lines
2.18.0.rc1 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v3 1/2 ndctl, test: Add NFIT_TEST_BUS[01] variable and some helper funtions to common
From: Masayoshi Mizuma <[email protected]>
Add following global variable and functions to test/common file.
- NFIT_TEST_BUS[01] (global variable)
Buses are created when nfit_test module is loaded.
- NDCTL (global variable)
ndctl command path (renamed).
- _cleanup
Helper function cleans up nfit_test module.
- json2var
Helper function (filter) converts json to var.
--- test/common | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
test/common +26 -3
@@ -4,17 +4,23 @@ # Global variables -# ndctl +# NDCTL # if [ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ]; then - export ndctl=../ndctl/ndctl + export NDCTL=../ndctl/ndctl elif [ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ]; then - export ndctl=./ndctl/ndctl + export NDCTL=./ndctl/ndctl else echo "Couldn't find an ndctl binary" exit 1 fi +# NFIT_TEST_BUS[01] +# +NFIT_TEST_BUS0=nfit_test.0 +NFIT_TEST_BUS1=nfit_test.1 + + # Functions # err
@@ -58,3 +64,20 @@ check_prereq() do_skip "missing $1, skipping..." fi } + +# _cleanup +# +_cleanup() +{ + $NDCTL disable-region -b $NFIT_TEST_BUS0 all + $NDCTL disable-region -b $NFIT_TEST_BUS1 all + modprobe -r nfit_test +} + +# json2var +# stdin: json +# +json2var() +{ + sed -e "s/[{}\",]//g; s/:/=/g" +}
Signature · 6 lines
2.18.0.rc1 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v3 2/2 ndctl, test: cleanup test scripts
In reply to Masayoshi MizumaFrom: Masayoshi Mizuma <[email protected]>
Cleanup some test scripts by using helper functions.
--- test/blk-exhaust.sh | 21 ++++++---------- test/btt-check.sh | 52 ++++++++++++++++++--------------------- test/btt-errors.sh | 30 +++++++++++----------- test/btt-pad-compat.sh | 36 ++++++++++++--------------- test/clear.sh | 25 +++++++------------ test/create.sh | 26 +++++++++----------- test/daxdev-errors.sh | 29 ++++++++-------------- test/firmware-update.sh | 25 +++++-------------- test/inject-error.sh | 24 ++++++++---------- test/label-compat.sh | 17 +++++-------- test/multi-dax.sh | 23 ++++++----------- test/pmem-errors.sh | 19 +++++--------- test/rescan-partitions.sh | 22 ++++++++--------- test/sector-mode.sh | 22 ++++++----------- 14 files changed, 146 insertions(+), 225 deletions(-)
test/blk-exhaust.sh +8 -13
@@ -13,9 +13,6 @@ set -e -NDCTL="../ndctl/ndctl" -BUS="-b nfit_test.0" -BUS1="-b nfit_test.1" rc=77 . ./common
@@ -26,21 +23,19 @@ trap 'err $LINENO' ERR # setup (reset nfit_test dimms) modprobe nfit_test -$NDCTL disable-region $BUS all -$NDCTL zero-labels $BUS all -$NDCTL enable-region $BUS all +$NDCTL disable-region -b $NFIT_TEST_BUS0 all +$NDCTL zero-labels -b $NFIT_TEST_BUS0 all +$NDCTL enable-region -b $NFIT_TEST_BUS0 all # if the kernel accounting is correct we should be able to create two # pmem and two blk namespaces on nfit_test.0 rc=1 -$NDCTL create-namespace $BUS -t pmem -$NDCTL create-namespace $BUS -t pmem -$NDCTL create-namespace $BUS -t blk -m raw -$NDCTL create-namespace $BUS -t blk -m raw +$NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem +$NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem +$NDCTL create-namespace -b $NFIT_TEST_BUS0 -t blk -m raw +$NDCTL create-namespace -b $NFIT_TEST_BUS0 -t blk -m raw # clearnup and exit -$NDCTL disable-region $BUS all -$NDCTL disable-region $BUS1 all -modprobe -r nfit_test +_cleanup exit 0
test/btt-check.sh +24 -28
120 lines not on this page · raw message
test/btt-errors.sh +14 -16
@@ -11,11 +11,8 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. -NDCTL="../ndctl/ndctl" -BUS="nfit_test.0" MNT=test_btt_mnt FILE=image -json2var="s/[{}\",]//g; s/:/=/g" blockdev="" rc=77
@@ -57,16 +54,16 @@ trap 'err $LINENO cleanup' ERR # setup (reset nfit_test dimms) modprobe nfit_test -$NDCTL disable-region -b "$BUS" all -$NDCTL zero-labels -b "$BUS" all -$NDCTL enable-region -b "$BUS" all +$NDCTL disable-region -b $NFIT_TEST_BUS0 all +$NDCTL zero-labels -b $NFIT_TEST_BUS0 all +$NDCTL enable-region -b $NFIT_TEST_BUS0 all rc=1 # create a btt namespace and clear errors (if any) dev="x" -json=$($NDCTL create-namespace -b "$BUS" -t pmem -m sector) -eval "$(echo "$json" | sed -e "$json2var")" +json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m sector) +eval "$(echo "$json" | json2var)" [ $dev = "x" ] && echo "fail: $LINENO" && exit 1 force_raw 1
@@ -137,12 +134,12 @@ 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 "$BUS" all -$NDCTL zero-labels -b "$BUS" all -$NDCTL enable-region -b "$BUS" all +$NDCTL disable-region -b $NFIT_TEST_BUS0 all +$NDCTL zero-labels -b $NFIT_TEST_BUS0 all +$NDCTL enable-region -b $NFIT_TEST_BUS0 all dev="x" -json=$($NDCTL create-namespace -b "$BUS" -t pmem -m sector) -eval "$(echo "$json" | sed -e "$json2var")" +json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m sector) +eval "$(echo "$json" | json2var)" [ $dev = "x" ] && echo "fail: $LINENO" && exit 1 # insert error at an arbitrary offset in the map (sector 0)
@@ -158,7 +155,8 @@ 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 "$BUS" all -$NDCTL zero-labels -b "$BUS" all -$NDCTL enable-region -b "$BUS" all +$NDCTL disable-region -b $NFIT_TEST_BUS0 all +$NDCTL zero-labels -b $NFIT_TEST_BUS0 all +$NDCTL enable-region -b $NFIT_TEST_BUS0 all +_cleanup exit 0
test/btt-pad-compat.sh +16 -20
@@ -11,11 +11,6 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. -[ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ] && ndctl="../ndctl/ndctl" -[ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ] && ndctl="./ndctl/ndctl" -[ -z "$ndctl" ] && echo "Couldn't find an ndctl binary" && exit 1 -bus="nfit_test.0" -json2var="s/[{}\",]//g; s/:/=/g" dev="" size="" blockdev=""
@@ -36,9 +31,9 @@ trap 'err $LINENO' ERR create() { - json=$($ndctl create-namespace -b "$bus" -t pmem -m sector) + json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m sector) rc=2 - eval "$(echo "$json" | sed -e "$json2var")" + eval "$(echo "$json" | json2var)" [ -n "$dev" ] || err "$LINENO" [ -n "$size" ] || err "$LINENO" [ -n "$blockdev" ] || err "$LINENO"
@@ -52,9 +47,9 @@ create() reset() { - $ndctl disable-region -b "$bus" all - $ndctl zero-labels -b "$bus" all - $ndctl enable-region -b "$bus" all + $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()
@@ -90,16 +85,16 @@ cycle_ns() { local ns="$1" - $ndctl disable-namespace $ns - $ndctl enable-namespace $ns + $NDCTL disable-namespace $ns + $NDCTL enable-namespace $ns } force_raw() { raw="$1" - $ndctl disable-namespace "$dev" + $NDCTL disable-namespace "$dev" echo "$raw" > "/sys/bus/nd/devices/$dev/force_raw" - $ndctl enable-namespace "$dev" + $NDCTL enable-namespace "$dev" echo "Set $dev to raw mode: $raw" if [[ "$raw" == "1" ]]; then raw_bdev=${blockdev%s}
@@ -125,16 +120,16 @@ create_oldfmt_ns() # that supports a raw namespace with a 4K sector size, prior to # v4.13 raw namespaces are limited to 512-byte sector size. rc=77 - json=$($ndctl create-namespace -b "$bus" -s 64M -t pmem -m raw -l 4096 -u 00000000-0000-0000-0000-000000000000) + json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -s 64M -t pmem -m raw -l 4096 -u 00000000-0000-0000-0000-000000000000) rc=2 - eval "$(echo "$json" | sed -e "$json2var")" + eval "$(echo "$json" | json2var)" [ -n "$dev" ] || err "$LINENO" [ -n "$size" ] || err "$LINENO" [ $size -gt 0 ] || err "$LINENO" # reconfig it to sector mode - json=$($ndctl create-namespace -b "$bus" -e $dev -m sector --force) - eval "$(echo "$json" | sed -e "$json2var")" + json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -e $dev -m sector --force) + eval "$(echo "$json" | json2var)" [ -n "$dev" ] || err "$LINENO" [ -n "$size" ] || err "$LINENO" [ -n "$blockdev" ] || err "$LINENO"
@@ -178,13 +173,13 @@ do_tests() verify_idx 0 2 # rewrite log using ndctl, verify conversion to new format - $ndctl check-namespace --rewrite-log --repair --force --verbose $dev + $NDCTL check-namespace --rewrite-log --repair --force --verbose $dev do_random_io "/dev/$blockdev" cycle_ns "$dev" verify_idx 0 1 # check-namespace again to make sure everything is ok - $ndctl check-namespace --force --verbose $dev + $NDCTL check-namespace --force --verbose $dev # the old format btt metadata was created with a null parent uuid, # making it 'stickier' than a normally created btt. Be sure to clean
@@ -198,4 +193,5 @@ rc=1 reset do_tests reset +_cleanup exit 0
test/clear.sh +9 -16
@@ -13,11 +13,6 @@ set -e -DEV="" -NDCTL="../ndctl/ndctl" -BUS="-b nfit_test.0" -BUS1="-b nfit_test.1" -json2var="s/[{}\",]//g; s/:/=/g" rc=77 . ./common
@@ -28,16 +23,16 @@ trap 'err $LINENO' ERR # setup (reset nfit_test dimms) modprobe nfit_test -$NDCTL disable-region $BUS all -$NDCTL zero-labels $BUS all -$NDCTL enable-region $BUS all +$NDCTL disable-region -b $NFIT_TEST_BUS0 all +$NDCTL zero-labels -b $NFIT_TEST_BUS0 all +$NDCTL enable-region -b $NFIT_TEST_BUS0 all rc=1 # create pmem dev="x" -json=$($NDCTL create-namespace $BUS -t pmem -m raw) -eval $(echo $json | sed -e "$json2var") +json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m raw) +eval $(echo $json | json2var) [ $dev = "x" ] && echo "fail: $LINENO" && exit 1 [ $mode != "raw" ] && echo "fail: $LINENO" && exit 1
@@ -58,7 +53,7 @@ sector_raw=$sector # convert pmem to fsdax mode json=$($NDCTL create-namespace -m fsdax -f -e $dev) -eval $(echo $json | sed -e "$json2var") +eval $(echo $json | json2var) [ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1 # check for errors relative to the offset injected by the pfn device
@@ -77,8 +72,8 @@ fi if check_min_kver "4.9"; then # check for re-appearance of stale badblocks from poison_list - $NDCTL disable-region $BUS all - $NDCTL enable-region $BUS all + $NDCTL disable-region -b $NFIT_TEST_BUS0 all + $NDCTL enable-region -b $NFIT_TEST_BUS0 all # since we have cleared the errors, a disable/reenable shouldn't bring them back if read sector len < /sys/block/$blockdev/badblocks; then
@@ -87,8 +82,6 @@ if check_min_kver "4.9"; then fi fi -$NDCTL disable-region $BUS all -$NDCTL disable-region $BUS1 all -modprobe -r nfit_test +_cleanup exit 0
test/create.sh +12 -14
@@ -13,10 +13,6 @@ set -e -DEV="" -NDCTL="../ndctl/ndctl" -BUS="-b nfit_test.0" -json2var="s/[{}\",]//g; s/:/=/g" SECTOR_SIZE="4096" rc=77
@@ -28,27 +24,27 @@ trap 'err $LINENO' ERR # setup (reset nfit_test dimms) modprobe nfit_test -$NDCTL disable-region $BUS all -$NDCTL zero-labels $BUS all -$NDCTL enable-region $BUS all +$NDCTL disable-region -b $NFIT_TEST_BUS0 all +$NDCTL zero-labels -b $NFIT_TEST_BUS0 all +$NDCTL enable-region -b $NFIT_TEST_BUS0 all rc=1 # create pmem dev="x" -json=$($NDCTL create-namespace $BUS -t pmem -m raw) -eval $(echo $json | sed -e "$json2var") +json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m raw) +eval $(echo $json | json2var ) [ $dev = "x" ] && echo "fail: $LINENO" && exit 1 [ $mode != "raw" ] && echo "fail: $LINENO" && exit 1 # convert pmem to fsdax mode json=$($NDCTL create-namespace -m fsdax -f -e $dev) -eval $(echo $json | sed -e "$json2var") +eval $(echo $json | json2var) [ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1 # convert pmem to sector mode json=$($NDCTL create-namespace -m sector -l $SECTOR_SIZE -f -e $dev) -eval $(echo $json | sed -e "$json2var") +eval $(echo $json | json2var) [ $sector_size != $SECTOR_SIZE ] && echo "fail: $LINENO" && exit 1 [ $mode != "sector" ] && echo "fail: $LINENO" && exit 1
@@ -57,15 +53,17 @@ $NDCTL destroy-namespace -f $dev # create blk dev="x" -json=$($NDCTL create-namespace $BUS -t blk -m raw -v) -eval $(echo $json | sed -e "$json2var") +json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t blk -m raw -v) +eval $(echo $json | json2var) [ $dev = "x" ] && echo "fail: $LINENO" && exit 1 [ $mode != "raw" ] && echo "fail: $LINENO" && exit 1 # convert blk to sector mode json=$($NDCTL create-namespace -m sector -l $SECTOR_SIZE -f -e $dev) -eval $(echo $json | sed -e "$json2var") +eval $(echo $json | json2var) [ $sector_size != $SECTOR_SIZE ] && echo "fail: $LINENO" && exit 1 [ $mode != "sector" ] && echo "fail: $LINENO" && exit 1 +_cleanup + exit 0
test/daxdev-errors.sh +10 -19
@@ -13,12 +13,6 @@ set -e -DEV="" -NDCTL="../ndctl/ndctl" -DAXCTL="../daxctl/daxctl" -BUS="-b nfit_test.0" -BUS1="-b nfit_test.1" -json2var="s/[{}\",]//g; s/:/=/g" rc=77 . ./common
@@ -29,16 +23,16 @@ trap 'err $LINENO' ERR # setup (reset nfit_test dimms) modprobe nfit_test -$NDCTL disable-region $BUS all -$NDCTL zero-labels $BUS all -$NDCTL enable-region $BUS all +$NDCTL disable-region -b $NFIT_TEST_BUS0 all +$NDCTL zero-labels -b $NFIT_TEST_BUS0 all +$NDCTL enable-region -b $NFIT_TEST_BUS0 all rc=1 query=". | sort_by(.available_size) | reverse | .[0].dev" -region=$($NDCTL list $BUS -t pmem -Ri | jq -r "$query") +region=$($NDCTL list -b $NFIT_TEST_BUS0 -t pmem -Ri | jq -r "$query") -json=$($NDCTL create-namespace $BUS -r $region -t pmem -m devdax -a 4096) +json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a 4096) chardev=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices[0].chardev") #{
@@ -59,12 +53,12 @@ chardev=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices[ # } #} -json1=$($NDCTL list $BUS --mode=devdax --namespaces) -eval $(echo $json1 | sed -e "$json2var") +json1=$($NDCTL list -b $NFIT_TEST_BUS0 --mode=devdax --namespaces) +eval $(echo $json1 | json2var) nsdev=$dev -json1=$($NDCTL list $BUS) -eval $(echo $json1 | sed -e "$json2var") +json1=$($NDCTL list -b $NFIT_TEST_BUS0) +eval $(echo $json1 | json2var) busdev=$dev # inject errors in the middle of the namespace
@@ -87,9 +81,6 @@ if read sector len < /sys/bus/platform/devices/nfit_test.0/$busdev/$region/badbl fi [ -n "$sector" ] && echo "fail: $LINENO" && exit 1 -# cleanup -$NDCTL disable-region $BUS all -$NDCTL disable-region $BUS1 all -modprobe -r nfit_test +_cleanup exit 0
test/firmware-update.sh +6 -19
@@ -2,12 +2,6 @@ # SPDX-License-Identifier: GPL-2.0 # Copyright(c) 2018 Intel Corporation. All rights reserved. -[ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ] && ndctl="../ndctl/ndctl" -[ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ] && ndctl="./ndctl/ndctl" -[ -z "$ndctl" ] && echo "Couldn't find an ndctl binary" && exit 1 -bus="nfit_test.0" -bus1="nfit_test.1" -json2var="s/[{}\",]//g; s/:/=/g" rc=77 dev="" image="update-fw.img"
@@ -18,31 +12,24 @@ trap 'err $LINENO' ERR reset() { - $ndctl disable-region -b "$bus" all - $ndctl zero-labels -b "$bus" all - $ndctl enable-region -b "$bus" all + $NDCTL disable-region -b $NFIT_TEST_BUS0 all + $NDCTL zero-labels -b $NFIT_TEST_BUS0 all + $NDCTL enable-region -b $NFIT_TEST_BUS0 all if [ -f $image ]; then rm -f $image fi } -cleanup() -{ - $ndctl disable-region -b "$bus" all - $ndctl disable-region -b "$bus1" all - modprobe -r nfit_test -} - detect() { - dev=$($ndctl list -b "$bus" -D | jq .[0].dev | tr -d '"') + dev=$($NDCTL list -b $NFIT_TEST_BUS0 -D | jq .[0].dev | tr -d '"') [ -n "$dev" ] || err "$LINENO" } do_tests() { truncate -s 196608 $image - $ndctl update-firmware -f $image $dev + $NDCTL update-firmware -f $image $dev } check_min_kver "4.16" || do_skip "may lack firmware update test handling"
@@ -53,5 +40,5 @@ reset rc=2 detect do_tests -cleanup +_cleanup exit 0
test/inject-error.sh +10 -14
@@ -11,11 +11,6 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. -[ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ] && ndctl="../ndctl/ndctl" -[ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ] && ndctl="./ndctl/ndctl" -[ -z "$ndctl" ] && echo "Couldn't find an ndctl binary" && exit 1 -bus="nfit_test.0" -json2var="s/[{}\",]//g; s/:/=/g" dev="" size="" blockdev=""
@@ -40,9 +35,9 @@ check_min_kver "4.15" || do_skip "kernel $KVER may not support error injection" create() { - json=$($ndctl create-namespace -b "$bus" -t pmem --align=4k) + json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem --align=4k) rc=2 - eval "$(echo "$json" | sed -e "$json2var")" + eval "$(echo "$json" | json2var)" [ -n "$dev" ] || err "$LINENO" [ -n "$size" ] || err "$LINENO" [ -n "$blockdev" ] || err "$LINENO"
@@ -51,9 +46,9 @@ create() reset() { - $ndctl disable-region -b "$bus" all - $ndctl zero-labels -b "$bus" all - $ndctl enable-region -b "$bus" all + $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()
@@ -61,7 +56,7 @@ check_status() local sector="$1" local count="$2" - json="$($ndctl inject-error --status $dev)" + json="$($NDCTL inject-error --status $dev)" [[ "$sector" == "$(jq ".badblocks[0].block" <<< "$json")" ]] [[ "$count" == "$(jq ".badblocks[0].count" <<< "$json")" ]] }
@@ -69,7 +64,7 @@ check_status() do_tests() { # inject without notification - $ndctl inject-error --block=$err_block --count=$err_count --no-notify $dev + $NDCTL inject-error --block=$err_block --count=$err_count --no-notify $dev check_status "$err_block" "$err_count" if read -r sector len < /sys/block/$blockdev/badblocks; then # fail if reading badblocks returns data
@@ -77,11 +72,11 @@ do_tests() fi # clear via err-inj-clear - $ndctl inject-error --block=$err_block --count=$err_count --uninject $dev + $NDCTL inject-error --block=$err_block --count=$err_count --uninject $dev check_status # inject normally - $ndctl inject-error --block=$err_block --count=$err_count $dev + $NDCTL inject-error --block=$err_block --count=$err_count $dev check_status "$err_block" "$err_count" if read -r sector len < /sys/block/$blockdev/badblocks; then test "$sector" -eq "$err_block"
@@ -102,4 +97,5 @@ rc=1 reset && create do_tests reset +_cleanup exit 0
test/label-compat.sh +6 -11
@@ -13,9 +13,6 @@ set -e -NDCTL="../ndctl/ndctl" -BUS="-b nfit_test.0" -BUS1="-b nfit_test.1" rc=77 . ./common
@@ -26,12 +23,12 @@ trap 'err $LINENO' ERR # setup (reset nfit_test dimms) modprobe nfit_test -$NDCTL disable-region $BUS all -$NDCTL zero-labels $BUS all +$NDCTL disable-region -b $NFIT_TEST_BUS0 all +$NDCTL zero-labels -b $NFIT_TEST_BUS0 all -# grab the largest pmem region on $BUS +# grab the largest pmem region on -b $NFIT_TEST_BUS0 query=". | sort_by(.available_size) | reverse | .[0].dev" -region=$($NDCTL list $BUS -t pmem -Ri | jq -r "$query") +region=$($NDCTL list -b $NFIT_TEST_BUS0 -t pmem -Ri | jq -r "$query") # we assume that $region is comprised of 4 dimms query=". | .regions[0].mappings | sort_by(.dimm) | .[].dimm"
@@ -43,7 +40,7 @@ do i=$((i+1)) done -$NDCTL enable-region $BUS all +$NDCTL enable-region -b $NFIT_TEST_BUS0 all len=$($NDCTL list -r $region -N | jq -r "length")
@@ -53,8 +50,6 @@ if [ -z $len ]; then exit 1 fi -$NDCTL disable-region $BUS all -$NDCTL disable-region $BUS1 all -modprobe -r nfit_test +_cleanup exit 0
test/multi-dax.sh +7 -16
@@ -13,12 +13,6 @@ set -e -DEV="" -NDCTL="../ndctl/ndctl" -DAXCTL="../daxctl/daxctl" -BUS="-b nfit_test.0" -BUS1="-b nfit_test.1" -json2var="s/[{}\",]//g; s/:/=/g" rc=77 . ./common
@@ -29,22 +23,19 @@ trap 'err $LINENO' ERR # setup (reset nfit_test dimms) modprobe nfit_test -$NDCTL disable-region $BUS all -$NDCTL zero-labels $BUS all -$NDCTL enable-region $BUS all +$NDCTL disable-region -b $NFIT_TEST_BUS0 all +$NDCTL zero-labels -b $NFIT_TEST_BUS0 all +$NDCTL enable-region -b $NFIT_TEST_BUS0 all rc=1 query=". | sort_by(.available_size) | reverse | .[0].dev" -region=$($NDCTL list $BUS -t pmem -Ri | jq -r "$query") +region=$($NDCTL list -b $NFIT_TEST_BUS0 -t pmem -Ri | jq -r "$query") -json=$($NDCTL create-namespace $BUS -r $region -t pmem -m devdax -a 4096 -s 16M) +json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a 4096 -s 16M) chardev1=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices[0].chardev") -json=$($NDCTL create-namespace $BUS -r $region -t pmem -m devdax -a 4096 -s 16M) +json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a 4096 -s 16M) chardev2=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices[0].chardev") -# cleanup -$NDCTL disable-region $BUS all -$NDCTL disable-region $BUS1 all -modprobe -r nfit_test +_cleanup exit 0
test/pmem-errors.sh +6 -13
@@ -2,13 +2,8 @@ # SPDX-License-Identifier: GPL-2.0 # Copyright(c) 2015-2017 Intel Corporation. All rights reserved. -DEV="" -NDCTL="../ndctl/ndctl" -BUS="-b nfit_test.0" -BUS1="-b nfit_test.1" MNT=test_dax_mnt FILE=image -json2var="s/[{}\",]//g; s/:/=/g" rc=77 . ./common
@@ -33,16 +28,16 @@ trap 'err $LINENO cleanup' ERR # setup (reset nfit_test dimms) modprobe nfit_test -$NDCTL disable-region $BUS all -$NDCTL zero-labels $BUS all -$NDCTL enable-region $BUS all +$NDCTL disable-region -b $NFIT_TEST_BUS0 all +$NDCTL zero-labels -b $NFIT_TEST_BUS0 all +$NDCTL enable-region -b $NFIT_TEST_BUS0 all rc=1 # create pmem dev="x" -json=$($NDCTL create-namespace $BUS -t pmem -m raw) -eval $(echo $json | sed -e "$json2var") +json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m raw) +eval $(echo $json | json2var) [ $dev = "x" ] && echo "fail: $LINENO" && false [ $mode != "raw" ] && echo "fail: $LINENO" && false
@@ -126,8 +121,6 @@ if [ -n "$blockdev" ]; then fi rmdir $MNT -$NDCTL disable-region $BUS all -$NDCTL disable-region $BUS1 all -modprobe -r nfit_test +_cleanup exit 0
test/rescan-partitions.sh +10 -12
@@ -2,8 +2,6 @@ # SPDX-License-Identifier: GPL-2.0 # Copyright(c) 2018 Intel Corporation. All rights reserved. -bus="nfit_test.0" -json2var="s/[{}\",]//g; s/:/=/g" dev="" size="" blockdev=""
@@ -29,9 +27,9 @@ check_prereq "blockdev" reset() { - $ndctl disable-region -b "$bus" all - $ndctl zero-labels -b "$bus" all - $ndctl enable-region -b "$bus" all + $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()
@@ -39,9 +37,9 @@ test_mode() local mode="$1" # create namespace - json=$($ndctl create-namespace -b "$bus" -t pmem -m "$mode") + json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m "$mode") rc=2 - eval "$(echo "$json" | sed -e "$json2var")" + eval "$(echo "$json" | json2var)" [ -n "$dev" ] || err "$LINENO" [ -n "$size" ] || err "$LINENO" [ -n "$blockdev" ] || err "$LINENO"
@@ -60,8 +58,8 @@ test_mode() # cycle the namespace, and verify the partition is read # without needing to do a blockdev --rereadpt - $ndctl disable-namespace $dev - $ndctl enable-namespace $dev + $NDCTL disable-namespace $dev + $NDCTL enable-namespace $dev if [ -b /dev/$partdev ]; then echo "mode: $mode - partition read successful" else
@@ -70,8 +68,8 @@ test_mode() err "$LINENO" fi - $ndctl disable-namespace $dev - $ndctl destroy-namespace $dev + $NDCTL disable-namespace $dev + $NDCTL destroy-namespace $dev } modprobe nfit_test
@@ -80,5 +78,5 @@ reset test_mode "raw" test_mode "fsdax" test_mode "sector" - +_cleanup exit 0
test/sector-mode.sh +8 -14
@@ -11,10 +11,6 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. -NDCTL="../ndctl/ndctl" -BUS="-b nfit_test.0" -BUS1="-b nfit_test.1" -TEST=$0 rc=77 . ./common
@@ -24,25 +20,23 @@ trap 'err $LINENO' ERR # setup (reset nfit_test dimms) modprobe nfit_test -$NDCTL disable-region $BUS all -$NDCTL zero-labels $BUS all -$NDCTL enable-region $BUS all +$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 $BUS1 all -$NDCTL zero-labels $BUS1 all -$NDCTL enable-region $BUS1 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 rc=1 query=". | sort_by(.size) | reverse | .[0].dev" -NAMESPACE=$($NDCTL list $BUS1 -N | jq -r "$query") +NAMESPACE=$($NDCTL list -b $NFIT_TEST_BUS1 -N | jq -r "$query") REGION=$($NDCTL list -R --namespace=$NAMESPACE | jq -r ".dev") echo 0 > /sys/bus/nd/devices/$REGION/read_only $NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K $NDCTL create-namespace --no-autolabel -e $NAMESPACE -m dax -f -a 4K $NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K -$NDCTL disable-region $BUS all -$NDCTL disable-region $BUS1 all -modprobe -r nfit_test +_cleanup exit 0
Signature · 6 lines
2.18.0.rc1 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm