* [ndctl PATCH 1/2] ndctl, test: fix tests for the array vs object listing fix
@ 2018-07-11 23:56 Vishal Verma
2018-07-11 23:56 ` [ndctl PATCH 2/2] ndctl, test: convert remaining tests to use test/common Vishal Verma
2018-07-12 15:43 ` [ndctl PATCH 1/2] ndctl, test: fix tests for the array vs object listing fix Ross Zwisler
0 siblings, 2 replies; 4+ messages in thread
From: Vishal Verma @ 2018-07-11 23:56 UTC (permalink / raw)
To: linux-nvdimm; +Cc: Masayoshi Mizuma
The commit below updated json listings to always be arrays unless,
potentially, --human was specified. As a fallout of the change, some
unit tests that used jq to look for certain elements, or the json2var
conversion broke in certain cases. Fix the jq query in sector-mode.sh,
and fix json2var in test/common. The 'destructive' class of unit tests
still need to be converted to the test/common scheme, and subsequently
have their own local json2var instances. These will be fixed in a future
commit by simply performing the test/common conversion.
Fixes: 72c46ab194d9 ("ndctl list: always output array without --human")
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
test/common | 2 +-
test/sector-mode.sh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/common b/test/common
index fb4e18e..1b9d3da 100644
--- a/test/common
+++ b/test/common
@@ -79,5 +79,5 @@ _cleanup()
#
json2var()
{
- sed -e "s/[{}\",]//g; s/:/=/g"
+ sed -e "s/[{}\",]//g; s/\[//g; s/\]//g; s/:/=/g"
}
diff --git a/test/sector-mode.sh b/test/sector-mode.sh
index 16c1ddf..4b964c5 100755
--- a/test/sector-mode.sh
+++ b/test/sector-mode.sh
@@ -31,7 +31,7 @@ $NDCTL enable-region -b $NFIT_TEST_BUS1 all
rc=1
query=". | sort_by(.size) | reverse | .[0].dev"
NAMESPACE=$($NDCTL list -b $NFIT_TEST_BUS1 -N | jq -r "$query")
-REGION=$($NDCTL list -R --namespace=$NAMESPACE | jq -r ".dev")
+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
--
2.14.4
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [ndctl PATCH 2/2] ndctl, test: convert remaining tests to use test/common
2018-07-11 23:56 [ndctl PATCH 1/2] ndctl, test: fix tests for the array vs object listing fix Vishal Verma
@ 2018-07-11 23:56 ` Vishal Verma
2018-07-12 20:15 ` Masayoshi Mizuma
2018-07-12 15:43 ` [ndctl PATCH 1/2] ndctl, test: fix tests for the array vs object listing fix Ross Zwisler
1 sibling, 1 reply; 4+ messages in thread
From: Vishal Verma @ 2018-07-11 23:56 UTC (permalink / raw)
To: linux-nvdimm; +Cc: Masayoshi Mizuma
The original test/common conversions missed the --enable-destructive
class of tests. The json single object vs. array changes prompted
changes to the json2var definitions, which these tests had a local copy
of. Instead of fixing up these local copies, take the change to properly
convert these tests to using test/common.
Fixes: 72c46ab194d9 ("ndctl list: always output array without --human")
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
test/dax.sh | 18 +++++++++---------
test/device-dax-fio.sh | 23 +++++------------------
test/mmap.sh | 12 +++++-------
3 files changed, 19 insertions(+), 34 deletions(-)
diff --git a/test/dax.sh b/test/dax.sh
index b63d563..d38fd01 100755
--- a/test/dax.sh
+++ b/test/dax.sh
@@ -11,13 +11,13 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
+. ./common
+
MNT=test_dax_mnt
FILE=image
-NDCTL="../ndctl/ndctl"
-json2var="s/[{}\",]//g; s/:/=/g"
blockdev=""
-err() {
+cleanup() {
echo "test-dax: failed at line $1"
if [ -n "$blockdev" ]; then
umount /dev/$blockdev
@@ -40,11 +40,11 @@ run_test() {
set -e
mkdir -p $MNT
-trap 'err $LINENO' ERR
+trap 'err $LINENO cleanup' ERR
dev=$(./dax-dev)
json=$($NDCTL list -N -n $dev)
-eval $(echo $json | sed -e "$json2var")
+eval $(json2var <<< "$json")
rc=1
mkfs.ext4 /dev/$blockdev
@@ -55,7 +55,7 @@ umount $MNT
# convert pmem to put the memmap on the device
json=$($NDCTL create-namespace -m fsdax -M dev -f -e $dev)
-eval $(echo $json | sed -e "$json2var")
+eval $(json2var <<< "$json")
[ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1
#note the blockdev returned from ndctl create-namespace lacks the /dev prefix
@@ -66,7 +66,7 @@ run_test
umount $MNT
json=$($NDCTL create-namespace -m raw -f -e $dev)
-eval $(echo $json | sed -e "$json2var")
+eval $(json2var <<< "$json")
[ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1
mkfs.xfs -f /dev/$blockdev
@@ -77,7 +77,7 @@ umount $MNT
# convert pmem to put the memmap on the device
json=$($NDCTL create-namespace -m fsdax -M dev -f -e $dev)
-eval $(echo $json | sed -e "$json2var")
+eval $(json2var <<< "$json")
[ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1
mkfs.xfs -f /dev/$blockdev
@@ -88,7 +88,7 @@ umount $MNT
# revert namespace to raw mode
json=$($NDCTL create-namespace -m raw -f -e $dev)
-eval $(echo $json | sed -e "$json2var")
+eval $(json2var <<< "$json")
[ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1
exit $rc
diff --git a/test/device-dax-fio.sh b/test/device-dax-fio.sh
index 6214030..b6d5e0e 100755
--- a/test/device-dax-fio.sh
+++ b/test/device-dax-fio.sh
@@ -11,30 +11,17 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
-NDCTL="../ndctl/ndctl"
+. ./common
+
rc=77
set -e
-err() {
- echo "test/device-dax-fio.sh: failed at line $1"
- exit $rc
-}
-
-check_min_kver()
-{
- local ver="$1"
- : "${KVER:=$(uname -r)}"
-
- [ -n "$ver" ] || return 1
- [[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)" ]]
-}
+check_min_kver "4.11" || do_skip "kernel may lack device-dax fixes"
-check_min_kver "4.11" || { echo "kernel $KVER may lack latest device-dax fixes"; exit $rc; }
-
-set -e
trap 'err $LINENO' ERR
+check_prereq "fio"
if ! fio --enghelp | grep -q "dev-dax"; then
echo "fio lacks dev-dax engine"
exit 77
@@ -79,7 +66,7 @@ do
# revert namespace to raw mode
json=$($NDCTL create-namespace -m raw -f -e $dev)
- mode=$(echo $json | jq -r ".mode")
+ eval $(json2var <<< "$json")
[ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1
done
diff --git a/test/mmap.sh b/test/mmap.sh
index 423c283..afe50fd 100755
--- a/test/mmap.sh
+++ b/test/mmap.sh
@@ -11,15 +11,15 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
+. ./common
+
MNT=test_mmap_mnt
FILE=image
DEV=""
TEST=./mmap
-NDCTL="../ndctl/ndctl"
-json2var="s/[{}\",]//g; s/:/=/g"
rc=77
-err() {
+cleanup() {
echo "test-mmap: failed at line $1"
if [ -n "$DEV" ]; then
umount $DEV
@@ -31,8 +31,6 @@ err() {
}
test_mmap() {
- trap 'err $LINENO' ERR
-
# SHARED
$TEST -Mrwps $MNT/$FILE # mlock, populate, shared (mlock fail)
$TEST -Arwps $MNT/$FILE # mlockall, populate, shared
@@ -58,11 +56,11 @@ test_mmap() {
set -e
mkdir -p $MNT
-trap 'err $LINENO' ERR
+trap 'err $LINENO cleanup' ERR
dev=$(./dax-dev)
json=$($NDCTL list -N -n $dev)
-eval $(echo $json | sed -e "$json2var")
+eval $(json2var <<< "$json")
DEV="/dev/${blockdev}"
rc=1
--
2.14.4
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [ndctl PATCH 1/2] ndctl, test: fix tests for the array vs object listing fix
2018-07-11 23:56 [ndctl PATCH 1/2] ndctl, test: fix tests for the array vs object listing fix Vishal Verma
2018-07-11 23:56 ` [ndctl PATCH 2/2] ndctl, test: convert remaining tests to use test/common Vishal Verma
@ 2018-07-12 15:43 ` Ross Zwisler
1 sibling, 0 replies; 4+ messages in thread
From: Ross Zwisler @ 2018-07-12 15:43 UTC (permalink / raw)
To: Vishal Verma; +Cc: Masayoshi Mizuma, linux-nvdimm
On Wed, Jul 11, 2018 at 05:56:43PM -0600, Vishal Verma wrote:
> The commit below updated json listings to always be arrays unless,
> potentially, --human was specified. As a fallout of the change, some
> unit tests that used jq to look for certain elements, or the json2var
> conversion broke in certain cases. Fix the jq query in sector-mode.sh,
> and fix json2var in test/common. The 'destructive' class of unit tests
> still need to be converted to the test/common scheme, and subsequently
> have their own local json2var instances. These will be fixed in a future
> commit by simply performing the test/common conversion.
>
> Fixes: 72c46ab194d9 ("ndctl list: always output array without --human")
> Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Nice, thanks for the fixes.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ndctl PATCH 2/2] ndctl, test: convert remaining tests to use test/common
2018-07-11 23:56 ` [ndctl PATCH 2/2] ndctl, test: convert remaining tests to use test/common Vishal Verma
@ 2018-07-12 20:15 ` Masayoshi Mizuma
0 siblings, 0 replies; 4+ messages in thread
From: Masayoshi Mizuma @ 2018-07-12 20:15 UTC (permalink / raw)
To: vishal.l.verma, linux-nvdimm; +Cc: m.mizuma
Hi Vishal,
Looks good to me. Please feel free to add:
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Thanks,
Masa
On 07/11/2018 07:56 PM, Vishal Verma wrote:
> The original test/common conversions missed the --enable-destructive
> class of tests. The json single object vs. array changes prompted
> changes to the json2var definitions, which these tests had a local copy
> of. Instead of fixing up these local copies, take the change to properly
> convert these tests to using test/common.
>
> Fixes: 72c46ab194d9 ("ndctl list: always output array without --human")
> Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> ---
> test/dax.sh | 18 +++++++++---------
> test/device-dax-fio.sh | 23 +++++------------------
> test/mmap.sh | 12 +++++-------
> 3 files changed, 19 insertions(+), 34 deletions(-)
>
> diff --git a/test/dax.sh b/test/dax.sh
> index b63d563..d38fd01 100755
> --- a/test/dax.sh
> +++ b/test/dax.sh
> @@ -11,13 +11,13 @@
> # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> # General Public License for more details.
>
> +. ./common
> +
> MNT=test_dax_mnt
> FILE=image
> -NDCTL="../ndctl/ndctl"
> -json2var="s/[{}\",]//g; s/:/=/g"
> blockdev=""
>
> -err() {
> +cleanup() {
> echo "test-dax: failed at line $1"
> if [ -n "$blockdev" ]; then
> umount /dev/$blockdev
> @@ -40,11 +40,11 @@ run_test() {
>
> set -e
> mkdir -p $MNT
> -trap 'err $LINENO' ERR
> +trap 'err $LINENO cleanup' ERR
>
> dev=$(./dax-dev)
> json=$($NDCTL list -N -n $dev)
> -eval $(echo $json | sed -e "$json2var")
> +eval $(json2var <<< "$json")
> rc=1
>
> mkfs.ext4 /dev/$blockdev
> @@ -55,7 +55,7 @@ umount $MNT
>
> # convert pmem to put the memmap on the device
> json=$($NDCTL create-namespace -m fsdax -M dev -f -e $dev)
> -eval $(echo $json | sed -e "$json2var")
> +eval $(json2var <<< "$json")
> [ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1
>
> #note the blockdev returned from ndctl create-namespace lacks the /dev prefix
> @@ -66,7 +66,7 @@ run_test
> umount $MNT
>
> json=$($NDCTL create-namespace -m raw -f -e $dev)
> -eval $(echo $json | sed -e "$json2var")
> +eval $(json2var <<< "$json")
> [ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1
>
> mkfs.xfs -f /dev/$blockdev
> @@ -77,7 +77,7 @@ umount $MNT
>
> # convert pmem to put the memmap on the device
> json=$($NDCTL create-namespace -m fsdax -M dev -f -e $dev)
> -eval $(echo $json | sed -e "$json2var")
> +eval $(json2var <<< "$json")
> [ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1
>
> mkfs.xfs -f /dev/$blockdev
> @@ -88,7 +88,7 @@ umount $MNT
>
> # revert namespace to raw mode
> json=$($NDCTL create-namespace -m raw -f -e $dev)
> -eval $(echo $json | sed -e "$json2var")
> +eval $(json2var <<< "$json")
> [ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1
>
> exit $rc
> diff --git a/test/device-dax-fio.sh b/test/device-dax-fio.sh
> index 6214030..b6d5e0e 100755
> --- a/test/device-dax-fio.sh
> +++ b/test/device-dax-fio.sh
> @@ -11,30 +11,17 @@
> # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> # General Public License for more details.
>
> -NDCTL="../ndctl/ndctl"
> +. ./common
> +
> rc=77
>
> set -e
>
> -err() {
> - echo "test/device-dax-fio.sh: failed at line $1"
> - exit $rc
> -}
> -
> -check_min_kver()
> -{
> - local ver="$1"
> - : "${KVER:=$(uname -r)}"
> -
> - [ -n "$ver" ] || return 1
> - [[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)" ]]
> -}
> +check_min_kver "4.11" || do_skip "kernel may lack device-dax fixes"
>
> -check_min_kver "4.11" || { echo "kernel $KVER may lack latest device-dax fixes"; exit $rc; }
> -
> -set -e
> trap 'err $LINENO' ERR
>
> +check_prereq "fio"
> if ! fio --enghelp | grep -q "dev-dax"; then
> echo "fio lacks dev-dax engine"
> exit 77
> @@ -79,7 +66,7 @@ do
>
> # revert namespace to raw mode
> json=$($NDCTL create-namespace -m raw -f -e $dev)
> - mode=$(echo $json | jq -r ".mode")
> + eval $(json2var <<< "$json")
> [ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1
> done
>
> diff --git a/test/mmap.sh b/test/mmap.sh
> index 423c283..afe50fd 100755
> --- a/test/mmap.sh
> +++ b/test/mmap.sh
> @@ -11,15 +11,15 @@
> # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> # General Public License for more details.
>
> +. ./common
> +
> MNT=test_mmap_mnt
> FILE=image
> DEV=""
> TEST=./mmap
> -NDCTL="../ndctl/ndctl"
> -json2var="s/[{}\",]//g; s/:/=/g"
> rc=77
>
> -err() {
> +cleanup() {
> echo "test-mmap: failed at line $1"
> if [ -n "$DEV" ]; then
> umount $DEV
> @@ -31,8 +31,6 @@ err() {
> }
>
> test_mmap() {
> - trap 'err $LINENO' ERR
> -
> # SHARED
> $TEST -Mrwps $MNT/$FILE # mlock, populate, shared (mlock fail)
> $TEST -Arwps $MNT/$FILE # mlockall, populate, shared
> @@ -58,11 +56,11 @@ test_mmap() {
>
> set -e
> mkdir -p $MNT
> -trap 'err $LINENO' ERR
> +trap 'err $LINENO cleanup' ERR
>
> dev=$(./dax-dev)
> json=$($NDCTL list -N -n $dev)
> -eval $(echo $json | sed -e "$json2var")
> +eval $(json2var <<< "$json")
> DEV="/dev/${blockdev}"
> rc=1
>
>
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-12 20:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-11 23:56 [ndctl PATCH 1/2] ndctl, test: fix tests for the array vs object listing fix Vishal Verma
2018-07-11 23:56 ` [ndctl PATCH 2/2] ndctl, test: convert remaining tests to use test/common Vishal Verma
2018-07-12 20:15 ` Masayoshi Mizuma
2018-07-12 15:43 ` [ndctl PATCH 1/2] ndctl, test: fix tests for the array vs object listing fix Ross Zwisler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).