From 29ad12df514d869a66c99019a2c58cd4f1ac18f8 Mon Sep 17 00:00:00 2001 From: Petr Rockai Date: Wed, 12 May 2010 05:55:08 +0000 Subject: [PATCH] Improve the "check" testing utility: slightly refactor and provide active/inactive checks. --- test/check.sh | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/test/check.sh b/test/check.sh index a8bebfd91..5da4c9e1a 100644 --- a/test/check.sh +++ b/test/check.sh @@ -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 @@ mirror_log_on() 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_images_clung() 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 @@ mirror_legs() { 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 } } -- 2.43.5