public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/test check.sh
@ 2010-05-12  5:55 mornfall
  0 siblings, 0 replies; 2+ messages in thread
From: mornfall @ 2010-05-12  5:55 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2010-05-12 05:55:08

Modified files:
	test           : check.sh 

Log message:
	Improve the "check" testing utility: slightly refactor and provide
	active/inactive checks.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/check.sh.diff?cvsroot=lvm2&r1=1.3&r2=1.4

--- LVM2/test/check.sh	2010/05/06 19:01:26	1.3
+++ LVM2/test/check.sh	2010/05/12 05:55:08	1.4
@@ -2,8 +2,12 @@
 
 set -e -o pipefail
 
+lvl() {
+	lvs -a --noheadings "$@"
+}
+
 lvdevices() {
-	lvs -a -odevices --noheadings "$@" | sed 's/([^)]*)//g; s/,/ /g'
+	lvl -odevices "$@" | sed 's/([^)]*)//g; s/,/ /g'
 }
 
 mirror_images_redundant()
@@ -57,9 +61,9 @@
 
 lv_is_contiguous()
 {
-	test `lvs -a --segments --noheadings $1 | wc -l` -eq 1 || {
+	test `lvl --segments $1 | wc -l` -eq 1 || {
 		echo "LV $1 expected to be contiguous, but is not:"
-		lvs -a --segments --noheadings $1
+		lvl --segments $1
 		exit 1
 	}
 }
@@ -89,9 +93,9 @@
 
 mirror() {
 	lv="$1/$2"
-	lvs -oattr "$lv" | grep "m" || {
+	lvl -oattr "$lv" | grep "m" || {
 		echo "$lv expected a mirror, but is not:"
-		lvs -a $lv
+		lvl -a $lv
 		exit 1
 	}
 	mirror_images_redundant "$1" "$2"
@@ -108,9 +112,37 @@
 
 linear() {
 	lv="$1/$2"
-	lvs -ostripes "$lv" | grep -q "1" || {
+	lvl -ostripes "$lv" | grep -q "1" || {
 		echo "$lv expected linear, but is not:"
-		lvs -a "$lv" -o+devices
+		lvl "$lv" -o+devices
+		exit 1
+	}
+}
+
+active() {
+	lv="$1/$2"
+	lvl -oattr "$lv" 2> /dev/null | grep -q "^ *....a.$" || {
+		echo "$lv expected active, but lvs says it's not:"
+		lvl "$lv" -o+devices 2>/dev/null
+		exit 1
+	}
+	dmsetup table | egrep -q "$1-$2: *[^ ]+" || {
+		echo "$lv expected active, lvs thinks it is but there are no mappings!"
+		dmsetup table | grep $1-$2:
+		exit 1
+	}
+}
+
+inactive() {
+	lv="$1/$2"
+	lvl -oattr "$lv" 2> /dev/null | grep -q '^ *....[-isd].$' || {
+		echo "$lv expected inactive, but lvs says it's not:"
+		lvl "$lv" -o+devices 2>/dev/null
+		exit 1
+	}
+	dmsetup table | not egrep -q "$1-$2: *[^ ]+" || {
+		echo "$lv expected inactive, lvs thinks it is but there are mappings!"
+		dmsetup table | grep $1-$2:
 		exit 1
 	}
 }


^ permalink raw reply	[flat|nested] 2+ messages in thread

* LVM2/test check.sh
@ 2010-04-12 19:33 mornfall
  0 siblings, 0 replies; 2+ messages in thread
From: mornfall @ 2010-04-12 19:33 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2010-04-12 19:33:58

Modified files:
	test           : check.sh 

Log message:
	More testsuite helpers for check.sh.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/check.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2

--- LVM2/test/check.sh	2010/04/12 19:02:59	1.1
+++ LVM2/test/check.sh	2010/04/12 19:33:58	1.2
@@ -26,14 +26,33 @@
   }
 }
 
+mirror_images_on() {
+	lv=$1
+
+	for i in `lvdevices $lv`; do
+		shift
+		lv_on $lv $1
+	done
+}
+
+lv_on()
+{
+	lv="$1"
+	lvdevices $lv | grep -F "$2" || {
+		echo "LV $lv expected on $2 but is not:" >&2
+		lvdevices $lv >&2
+		exit 1
+	}
+	test `lvdevices $lv | grep -vF "$2" | wc -l` -eq 0 || {
+		echo "LV $lv contains unexpected devices:" >&2
+		lvdevices $lv >&2
+		exit 1
+	}
+}
+
 mirror_log_on()
 {
-  lv="$1"_mlog
-  lvdevices $lv | grep -F "$2" || {
-	  echo "mirror log $lv expected on $2 but found on:" >&2
-	  lvdevices $lv >&2
-	  exit 1
-  }
+	lv_on "${1}_mlog" "$2"
 }
 
 lv_is_contiguous()
@@ -81,7 +100,7 @@
 
 linear() {
 	lv="$1/$2"
-	lvs -ostripes "$lv" | grep "1" || {
+	lvs -ostripes "$lv" | grep -q "1" || {
 		echo "$lv expected linear, but is not:"
 		lvs -a "$lv" -o+devices
 		exit 1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-12  5:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-12  5:55 LVM2/test check.sh mornfall
  -- strict thread matches above, loose matches on Subject: below --
2010-04-12 19:33 mornfall

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 read-only IMAP folder(s) and NNTP newsgroup(s).