diff mbox

[ndctl,1/2] ndctl, test: fix tests for the array vs object listing fix

Message ID 20180711235644.26998-1-vishal.l.verma@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Verma, Vishal L July 11, 2018, 11:56 p.m. UTC
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(-)

Comments

Ross Zwisler July 12, 2018, 3:43 p.m. UTC | #1
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.
diff mbox

Patch

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