summaryrefslogtreecommitdiffstats
path: root/test/lib
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2012-03-28 11:10:08 +0000
committerZdenek Kabelac <zkabelac@redhat.com>2012-03-28 11:10:08 +0000
commita59c3731c3f68561b1b9aa015d59155976c7a6a3 (patch)
tree8a19c221b29f6c4df02442db518088c4406e6659 /test/lib
parent9e072e70723544190b5fbfbfae9e6683fcf5f644 (diff)
downloadlvm2-a59c3731c3f68561b1b9aa015d59155976c7a6a3.tar.gz
lvm2-a59c3731c3f68561b1b9aa015d59155976c7a6a3.tar.xz
lvm2-a59c3731c3f68561b1b9aa015d59155976c7a6a3.zip
Improve test suite
Add make help target. Add LVM_TEST_PARALLEL to support parallel runs of tests Work around the problem the dmsetup table/info may return error by using dmtable and dminfo function that will use 'should'. (Error happens when some concurently running process removes table entry while dmsetup command resolves table entries inside the loop.)
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/aux.sh18
-rw-r--r--test/lib/check.sh12
-rw-r--r--test/lib/utils.sh10
3 files changed, 23 insertions, 17 deletions
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index a2579701..49df9dd6 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -89,7 +89,7 @@ teardown_devs_prefixed() {
local dm
# Resume suspended devices first
- for dm in $(dmsetup info -c -o suspended,name --noheadings | grep "^Suspended:.*$prefix"); do
+ for dm in $(dm_info suspended,name | grep "^Suspended:.*$prefix"); do
echo "dmsetup resume \"${dm#Suspended:}\""
dmsetup resume "${dm#Suspended:}" || true
done
@@ -106,7 +106,7 @@ teardown_devs_prefixed() {
local remfail=no
local need_udev_wait=0
init_udev_transaction
- for dm in $(dmsetup info -c -o name --sort open --noheadings | grep "$prefix"); do
+ for dm in $(dm_info name --sort open | grep "$prefix"); do
dmsetup remove "$dm" &>/dev/null || remfail=yes
need_udev_wait=1
done
@@ -116,10 +116,10 @@ teardown_devs_prefixed() {
if test $remfail = yes; then
local num_devs
local num_remaining_devs=999
- while num_devs=$(dmsetup table | grep "$prefix" | wc -l) && \
+ while num_devs=$(dm_table | grep "$prefix" | wc -l) && \
test $num_devs -lt $num_remaining_devs -a $num_devs -ne 0; do
test "$stray" -eq 0 || echo "Removing $num_devs stray mapped devices with names beginning with $prefix: "
- for dm in $(dmsetup info -c -o name --sort open --noheadings | grep "$prefix") ; do
+ for dm in $(dm_info name --sort open | grep "$prefix") ; do
dmsetup remove -f "$dm" || true
done
num_remaining_devs=$num_devs
@@ -139,7 +139,7 @@ teardown_devs() {
# NOTE: SCSI_DEBUG_DEV test must come before the LOOP test because
# prepare_scsi_debug_dev() also sets LOOP to short-circuit prepare_loop()
if test -f SCSI_DEBUG_DEV; then
- modprobe -r scsi_debug
+ test ${LVM_TEST_PARALLEL:-0} -eq 1 || modprobe -r scsi_debug
else
test ! -f LOOP || losetup -d $(cat LOOP) || true
test ! -f LOOPFILE || rm -f $(cat LOOPFILE)
@@ -148,7 +148,7 @@ teardown_devs() {
rm -f LOOP
# Attempt to remove any loop devices that failed to get torn down if earlier tests aborted
- test -z "$COMMON_PREFIX" || {
+ test ${LVM_TEST_PARALLEL:-0} -eq 1 -o -z "$COMMON_PREFIX" || {
teardown_devs_prefixed "$COMMON_PREFIX" 1
local stray_loops=( $(losetup -a | grep "$COMMON_PREFIX" | cut -d: -f1) )
test ${#stray_loops[@]} -eq 0 || {
@@ -161,9 +161,9 @@ teardown_devs() {
teardown() {
echo -n "## teardown..."
- dmsetup table | not egrep -q "$vg|$vg1|$vg2|$vg3|$vg4" || {
+ dm_table | not egrep -q "$vg|$vg1|$vg2|$vg3|$vg4" || {
# Avoid activation of dmeventd if there is no pid
- cfg=$(test -s LOCAL_DMEVENTD || echo "--config 'activation { monitoring = 0 }'")
+ cfg=$(test -s LOCAL_DMEVENTD || echo "--config activation{monitoring=0}")
vgremove -ff $cfg \
$vg $vg1 $vg2 $vg3 $vg4 &>/dev/null || rm -f debug.log
}
@@ -194,7 +194,7 @@ teardown() {
echo "ok"
- test -n "$RUNNING_DMEVENTD" || not pgrep dmeventd &>/dev/null
+ test ${LVM_TEST_PARALLEL:-0} -eq 1 -o -n "$RUNNING_DMEVENTD" || not pgrep dmeventd #&>/dev/null
}
make_ioerror() {
diff --git a/test/lib/check.sh b/test/lib/check.sh
index be1c11f9..9c787285 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -153,12 +153,11 @@ linear() {
active() {
local lv=$1/$2
- (get lv_field $lv attr $lv | grep "^....a...$" >/dev/null) || \
+ (get lv_field $lv attr | grep "^....a...$" >/dev/null) || \
die "$lv expected active, but lvs says it's not:" \
$(lvl $lv -o+devices)
- (dmsetup table | egrep "$1-$2: *[^ ]+" >/dev/null) || \
- die "$lv expected active, lvs thinks it is but there are no mappings!" \
- $(dmsetup table | grep $1-$2:)
+ dmsetup info $1-$2 >/dev/null ||
+ die "$lv expected active, lvs thinks it is but there are no mappings!"
}
inactive() {
@@ -166,9 +165,8 @@ inactive() {
(get lv_field $lv attr | grep "^....[-isd]...$" >/dev/null) || \
die "$lv expected inactive, but lvs says it's not:" \
$(lvl $lv -o+devices)
- (dmsetup table | not egrep "$1-$2: *[^ ]+" >/dev/null) || \
- die "$lv expected inactive, lvs thinks it is but there are mappings!" \
- $(dmsetup table | grep $1-$2:)
+ not dmsetup info $1-$2 2>/dev/null || \
+ die "$lv expected inactive, lvs thinks it is but there are mappings!"
}
# Check for list of LVs from given VG
diff --git a/test/lib/utils.sh b/test/lib/utils.sh
index a5f82bcf..70d9f66f 100644
--- a/test/lib/utils.sh
+++ b/test/lib/utils.sh
@@ -109,7 +109,7 @@ STACKTRACE() {
i=$(($i + 1))
done
- test -n "$RUNNING_DMEVENTD" -o -f LOCAL_DMEVENTD || {
+ test ${LVM_TEST_PARALLEL:-0} -eq 1 -o -n "$RUNNING_DMEVENTD" -o -f LOCAL_DMEVENTD || {
pgrep dmeventd &>/dev/null && \
die "** During test dmeventd has been started!"
}
@@ -157,6 +157,14 @@ teardown_udev_cookies() {
fi
}
+dm_info() {
+ should dmsetup info --noheadings -c -o "$@"
+}
+
+dm_table() {
+ should dmsetup table "$@"
+}
+
skip() {
touch SKIP_THIS_TEST
exit 200