Skip to contentSkip to conversation

ndctl/test: Fix region selection in align.sh

PATCH New Vishal Verma 1 participant 2 messages May 21, 2020 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Vishal Verma

author maintainer
#0 lore raw

PATCH 1/2 ndctl/test: Fix region selection in align.sh

Fix the region filtering/selection for the align.sh test. The current jq filter falls over if two regions match the criteria because array elements got flattened to the top level.

---
 test/align.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/align.sh +1 -1
index 0129255..81d1fbc 100755
@@ -34,7 +34,7 @@ is_aligned() {
 set -e
 trap 'err $LINENO cleanup' ERR
 
-region=$($NDCTL list -R -b ACPI.NFIT | jq -r '.[] | [select(.available_size == .size)] | .[0].dev')
+region=$($NDCTL list -R -b ACPI.NFIT | jq -r '[.[] | select(.available_size == .size)][0] | .dev')
 
 if [ "x$region" = "xnull"  ]; then
 	unset $region
Signature · 4 lines
2.26.2
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
author maintainer
#1 lore raw

PATCH 2/2 ndctl/test: fix align.sh to not expect initialized labels

A fresh qemu based system may not have its labels initialized. In this case, align.sh would get skipped because the label-less namespaces would be using all available region capacity.

Fix this by initializing labels if a usable region is not found the first time around, and try again.

---
 test/align.sh | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
test/align.sh +12 -1
index 81d1fbc..37b2a1d 100755
@@ -34,8 +34,19 @@ is_aligned() {
 set -e
 trap 'err $LINENO cleanup' ERR
 
-region=$($NDCTL list -R -b ACPI.NFIT | jq -r '[.[] | select(.available_size == .size)][0] | .dev')
+find_region()
+{
+	$NDCTL list -R -b ACPI.NFIT | jq -r '[.[] | select(.available_size == .size)][0] | .dev'
+}
 
+region=$(find_region)
+if [ "x$region" = "xnull"  ]; then
+	# this is destructive
+	$NDCTL disable-region -b ACPI.NFIT all
+	$NDCTL init-labels -f -b ACPI.NFIT all
+	$NDCTL enable-region -b ACPI.NFIT all
+fi
+region=$(find_region)
 if [ "x$region" = "xnull"  ]; then
 	unset $region
 	echo "unable to find empty region"
Signature · 4 lines
2.26.2
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]