[lvm-devel] master - tests: lvmconf update

Zdenek Kabelac zkabelac at fedoraproject.org
Thu Apr 30 09:17:11 UTC 2015


Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3706abde5e7703562bad3072cca13faf31b6b8b6
Commit:        3706abde5e7703562bad3072cca13faf31b6b8b6
Parent:        13fea879606c4dfdeb8d7686ca2ab606a70a5cd4
Author:        Zdenek Kabelac <zkabelac at redhat.com>
AuthorDate:    Thu Apr 30 11:12:19 2015 +0200
Committer:     Zdenek Kabelac <zkabelac at redhat.com>
CommitterDate: Thu Apr 30 11:16:14 2015 +0200

tests: lvmconf update

New lvmconf function is using bash associative arrays - however
older systems like RHEL5 doesn't provide this feature. In this case
stay with older variant.

Restore support for use case like this:
aux lvmconf 'tags/@foo {}'
---
 test/lib/aux.sh |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 373909a..67df0f5 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -786,14 +786,28 @@ EOF
 	    echo "$v"
 	done >> "$config_values"
 
-	declare -A CONF
+	declare -A CONF || {
+		# Associative arrays is not available
+		local s
+		for s in $(cut -f1 -d/ "$config_values" | sort | uniq); do
+			echo "$s {"
+			local k
+			for k in $(grep ^"$s"/ "$config_values" | cut -f1 -d= | sed -e 's, *$,,' | sort | uniq); do
+				grep "^$k" "$config_values" | tail -n 1 | sed -e "s,^$s/,	 ,"
+			done
+			echo "}"
+			echo
+		done | tee "$config" | sed -e "s,^,## LVMCONF: ,"
+		return 0
+	}
+
 	local sec
 	local last_sec
 
 	# read sequential list and put into associative array
 	while IFS=$IFS_NL read -r v; do
 		# trim white-space-chars via echo when inserting
-		CONF[$(echo ${v%%=*})]=${v##*=}
+		CONF[$(echo ${v%%[={]*})]=${v#*/}
 	done < "$config_values"
 
 	# sort by section and iterate through them
@@ -804,7 +818,7 @@ EOF
 			echo "$sec {"
 			last_sec=$sec
 		}
-		echo "	${v#*/} =${CONF[$v]}"
+		echo "    ${CONF[$v]}"
 	done > "$config"
 	echo "}" >> "$config"
 




More information about the lvm-devel mailing list