diff mbox series

[ndctl,2/2] ndctl/test: fix align.sh to not expect initialized labels

Message ID 20200521005848.7272-2-vishal.l.verma@intel.com (mailing list archive)
State Accepted
Commit f5b635a34a7d59095303493f05bdd448742449e9
Headers show
Series [ndctl,1/2] ndctl/test: Fix region selection in align.sh | expand

Commit Message

Verma, Vishal L May 21, 2020, 12:58 a.m. UTC
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.

Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 test/align.sh | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/test/align.sh b/test/align.sh
index 81d1fbc..37b2a1d 100755
--- a/test/align.sh
+++ b/test/align.sh
@@ -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"