master - tests: inittest.sh double quote and mixing string
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=32be18959d7899822d8...
Commit: 32be18959d7899822d80c715fd271410f05462f1
Parent: b45ca523ecbba006d2982ae085140c69edbe084e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 29 10:38:06 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:17 2017 +0200
tests: inittest.sh double quote and mixing string
---
test/lib/inittest.sh | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index b75eddc..f959b71 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
-# Copyright (C) 2011-2015 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2011-2017 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
@@ -10,7 +10,7 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
initskip() {
- test "$#" -eq 0 || echo "TEST SKIPPED: $@"
+ test "$#" -eq 0 || echo "TEST SKIPPED: " "$@"
exit 200
}
@@ -26,7 +26,7 @@ PS4='#${BASH_SOURCE[0]##*/}:${LINENO}+ '
export TESTNAME PS4
if test -n "$LVM_TEST_FLAVOUR"; then
- . lib/flavour-$LVM_TEST_FLAVOUR
+ . "lib/flavour-$LVM_TEST_FLAVOUR"
fi
test -n "$SKIP_WITHOUT_CLVMD" && test "$LVM_TEST_LOCKING" -ne 3 && initskip
6 years, 10 months
master - tests: check.sh eliminate useless cat
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b45ca523ecbba006d29...
Commit: b45ca523ecbba006d2982ae085140c69edbe084e
Parent: 51237cb5047a93382f8d239e9aa9d3899154300f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 29 11:56:47 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:17 2017 +0200
tests: check.sh eliminate useless cat
Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
---
test/lib/check.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/lib/check.sh b/test/lib/check.sh
index 64019da..a43aef7 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -49,7 +49,7 @@ mirror_images_redundant() {
(grep -v ^# check.tmp.all || true) | sort | uniq -d > check.tmp
- test "$(cat check.tmp | wc -l)" -eq 0 || \
+ test "$(wc -l < check.tmp)" -eq 0 || \
die "mirror images of $lv expected redundant, but are not:" \
"$(cat check.tmp.all)"
}
6 years, 10 months
master - tests: check.sh better if
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=51237cb5047a93382f8...
Commit: 51237cb5047a93382f8d239e9aa9d3899154300f
Parent: db338c2b42abb6b5274fba5f93a982241afa8ecf
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 29 09:40:01 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:17 2017 +0200
tests: check.sh better if
Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
---
test/lib/check.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/lib/check.sh b/test/lib/check.sh
index 8555235..64019da 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -225,7 +225,7 @@ in_sync() {
b=( $(echo "${a[$idx]}" | sed s:/:' ':) )
- if [ "${b[0]}" -eq 0 -o "${b[0]}" != "${b[1]}" ]; then
+ if [ "${b[0]}" -eq 0 ] || [ "${b[0]}" != "${b[1]}" ]; then
echo "$lvm_name ($type$snap) is not in-sync"
return 1
fi
6 years, 10 months
master - tests: check.sh drop unnecessary $
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=db338c2b42abb6b5274...
Commit: db338c2b42abb6b5274fba5f93a982241afa8ecf
Parent: c0197040a5c68af8314b5466c8b1f61b381044f6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 29 09:37:20 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:17 2017 +0200
tests: check.sh drop unnecessary $
$/${} is unnecessary on arithmetic variables.
---
test/lib/check.sh | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/lib/check.sh b/test/lib/check.sh
index 1ec1bab..8555235 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -208,14 +208,14 @@ in_sync() {
# 6th argument is the sync ratio for RAID
idx=6
type=${a[3]}
- if [ "${a[$(($idx + 1))]}" != "idle" ]; then
+ if [ "${a[$(( idx + 1 ))]}" != "idle" ]; then
echo "$lvm_name ($type$snap) is not in-sync"
return 1
fi
;;
"mirror")
# 4th Arg tells us how far to the sync ratio
- idx=$((${a[3]} + 4))
+ idx=$(( a[3] + 4 ))
type=${a[2]}
;;
*)
@@ -230,7 +230,7 @@ in_sync() {
return 1
fi
- if [[ ${a[$(($idx - 1))]} =~ a ]] ; then
+ if [[ ${a[$(( idx - 1 ))]} =~ a ]] ; then
[ $ignore_a -eq 0 ] && \
die "$lvm_name ($type$snap) in-sync, but 'a' characters in health status"
echo "$lvm_name ($type$snap) is not in-sync"
6 years, 10 months
master - tests: check.sh using grep -F
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c0197040a5c68af8314...
Commit: c0197040a5c68af8314b5466c8b1f61b381044f6
Parent: 824db54128ef6831629d86ef3b472164048fc227
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 29 08:41:43 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:17 2017 +0200
tests: check.sh using grep -F
fgrep is non-standard and deprecated. Use grep -F instead.
---
test/lib/check.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/lib/check.sh b/test/lib/check.sh
index 6f56ea3..1ec1bab 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -148,7 +148,7 @@ mirror_nonredundant() {
attr=$(get lv_field "$lv" attr)
(echo "$attr" | grep "^......m...$" >/dev/null) || {
if (echo "$attr" | grep "^o.........$" >/dev/null) &&
- lvs -a | fgrep "[${2}_mimage" >/dev/null; then
+ lvs -a | grep -F "[${2}_mimage" >/dev/null; then
echo "TEST WARNING: $lv is a snapshot origin and looks like a mirror,"
echo "assuming it is actually a mirror"
else
6 years, 10 months
master - tests: check.sh no mixing string
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=824db54128ef6831629...
Commit: 824db54128ef6831629d86ef3b472164048fc227
Parent: 810f856c2490eb1d5db858f26a26621c4a3477e0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 29 08:40:55 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:17 2017 +0200
tests: check.sh no mixing string
Argument mixes string and array. Use * or separate argument.
---
test/lib/check.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/lib/check.sh b/test/lib/check.sh
index 0ad48a9..6f56ea3 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -237,7 +237,7 @@ in_sync() {
return 1
fi
- echo "$lvm_name ($type$snap) is in-sync \"${a[@]}\""
+ echo "$lvm_name ($type$snap) is in-sync" "${a[@]}"
}
active() {
@@ -434,7 +434,7 @@ raid_leg_status() {
grep_dmsetup() {
dmsetup "$1" "$2" | tee out
- grep -q "${@:3}" out || die "Expected output \"${@:3}\" from dmsetup $1 not found!"
+ grep -q "${@:3}" out || die "Expected output \"" "${@:3}" "\" from dmsetup $1 not found!"
}
#set -x
6 years, 10 months
master - tests: check.sh assign separately
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=810f856c2490eb1d5db...
Commit: 810f856c2490eb1d5db858f26a26621c4a3477e0
Parent: 02729202f38825c672412f49e1073d38cdf0772b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 29 08:39:21 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:17 2017 +0200
tests: check.sh assign separately
Declare and assign separately to avoid masking return values.
---
test/lib/check.sh | 57 +++++++++++++++++++++++++++++++++++-----------------
1 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/test/lib/check.sh b/test/lib/check.sh
index 2eb24a5..0ad48a9 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -144,7 +144,8 @@ mirror() {
mirror_nonredundant() {
local lv="$1/$2"
- local attr=$(get lv_field "$lv" attr)
+ local attr
+ attr=$(get lv_field "$lv" attr)
(echo "$attr" | grep "^......m...$" >/dev/null) || {
if (echo "$attr" | grep "^o.........$" >/dev/null) &&
lvs -a | fgrep "[${2}_mimage" >/dev/null; then
@@ -188,8 +189,9 @@ in_sync() {
local snap=""
local lvm_name="$1/$2"
local ignore_a="$3"
- local dm_name=$(echo "$lvm_name" | sed s:-:--: | sed s:/:-:)
+ local dm_name
+ dm_name=$(echo "$lvm_name" | sed s:-:--: | sed s:/:-:)
[ -z "$ignore_a" ] && ignore_a=0
a=( $(dmsetup status "$dm_name") ) || \
@@ -285,20 +287,23 @@ lv_not_exists() {
}
pv_field() {
- local actual=$(get pv_field "$1" "$2" "${@:4}")
+ local actual
+ actual=$(get pv_field "$1" "$2" "${@:4}")
test "$actual" = "$3" || \
die "pv_field: PV=\"$1\", field=\"$2\", actual=\"$actual\", expected=\"$3\""
}
vg_field() {
- local actual=$(get vg_field "$1" "$2" "${@:4}")
+ local actual
+ actual=$(get vg_field "$1" "$2" "${@:4}")
test "$actual" = "$3" || \
die "vg_field: vg=$1, field=\"$2\", actual=\"$actual\", expected=\"$3\""
}
vg_attr_bit() {
- local actual=$(get vg_field "$2" vg_attr "${@:4}")
+ local actual
local offset=$1
+ actual=$(get vg_field "$2" vg_attr "${@:4}")
case "$offset" in
perm*) offset=0 ;;
resiz*) offset=1 ;;
@@ -312,32 +317,37 @@ vg_attr_bit() {
}
lv_field() {
- local actual=$(get lv_field "$1" "$2" "${@:4}")
+ local actual
+ actual=$(get lv_field "$1" "$2" "${@:4}")
test "$actual" = "$3" || \
die "lv_field: lv=$1, field=\"$2\", actual=\"$actual\", expected=\"$3\""
}
lv_first_seg_field() {
- local actual=$(get lv_first_seg_field "$1" "$2" "${@:4}")
+ local actual
+ actual=$(get lv_first_seg_field "$1" "$2" "${@:4}")
test "$actual" = "$3" || \
die "lv_field: lv=$1, field=\"$2\", actual=\"$actual\", expected=\"$3\""
}
lvh_field() {
- local actual=$(get lvh_field "$1" "$2" "${@:4}")
+ local actual
+ actual=$(get lvh_field "$1" "$2" "${@:4}")
test "$actual" = "$3" || \
die "lvh_field: lv=$1, field=\"$2\", actual=\"$actual\", expected=\"$3\""
}
lva_field() {
- local actual=$(get lva_field "$1" "$2" "${@:4}")
+ local actual
+ actual=$(get lva_field "$1" "$2" "${@:4}")
test "$actual" = "$3" || \
die "lva_field: lv=$1, field=\"$2\", actual=\"$actual\", expected=\"$3\""
}
lv_attr_bit() {
- local actual=$(get lv_field "$2" lv_attr "${@:4}")
+ local actual
local offset=$1
+ actual=$(get lv_field "$2" lv_attr "${@:4}")
case "$offset" in
type) offset=0 ;;
perm*) offset=1 ;;
@@ -361,8 +371,10 @@ compare_fields() {
local cmd2=$4
local obj2=$5
local field2=$6
- local val1=$($cmd1 --noheadings -o "$field1" "$obj1")
- local val2=$($cmd2 --noheadings -o "$field2" "$obj2")
+ local val1
+ local val2
+ val1=$($cmd1 --noheadings -o "$field1" "$obj1")
+ val2=$($cmd2 --noheadings -o "$field2" "$obj2")
test "$val1" = "$val2" || \
die "compare_fields $obj1($field1): $val1 $obj2($field2): $val2"
}
@@ -371,8 +383,10 @@ compare_vg_field() {
local vg1=$1
local vg2=$2
local field=$3
- local val1=$(vgs --noheadings -o "$field" "$vg1")
- local val2=$(vgs --noheadings -o "$field" "$vg2")
+ local val1
+ local val2
+ val1=$(vgs --noheadings -o "$field" "$vg1")
+ val2=$(vgs --noheadings -o "$field" "$vg2")
test "$val1" = "$val2" || \
die "compare_vg_field: $vg1: $val1, $vg2: $val2"
}
@@ -397,18 +411,23 @@ dev_md5sum() {
sysfs() {
# read maj min and also convert hex to decimal
- local maj=$(($(stat -L --printf=0x%t "$1")))
- local min=$(($(stat -L --printf=0x%T "$1")))
+ local maj
+ local min
local P="/sys/dev/block/$maj:$min/$2"
- local val=$(< "$P") || return 0 # no sysfs ?
+ local val
+ maj=$(($(stat -L --printf=0x%t "$1")))
+ min=$(($(stat -L --printf=0x%T "$1")))
+ val=$(< "$P") || return 0 # no sysfs ?
test "$val" -eq "$3" || \
die "$1: $P = $val differs from expected value $3!"
}
# check raid_leg_status $vg $lv "Aaaaa"
raid_leg_status() {
- local st=$(dmsetup status "$1-$2")
- local val=$(echo "$st" | cut -d ' ' -f 6)
+ local st
+ local val
+ st=$(dmsetup status "$1-$2")
+ val=$(echo "$st" | cut -d ' ' -f 6)
test "$val" = "$3" || \
die "$1-$2 status $val != $3 ($st)"
}
6 years, 10 months
master - tests: check.sh double quote
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=02729202f38825c6724...
Commit: 02729202f38825c672412f49e1073d38cdf0772b
Parent: 491fcd2a921bea6d63bbb243bfd972fda3bb6c67
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 29 08:23:23 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:17 2017 +0200
tests: check.sh double quote
---
test/lib/check.sh | 114 ++++++++++++++++++++++++++--------------------------
1 files changed, 57 insertions(+), 57 deletions(-)
diff --git a/test/lib/check.sh b/test/lib/check.sh
index f2e5ff4..2eb24a5 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -41,17 +41,17 @@ lvdevices() {
mirror_images_redundant() {
local vg=$1
local lv=$vg/$2
- lvs -a $vg -o+devices
- for i in $(lvdevices $lv); do
+ lvs -a "$vg" -o+devices
+ for i in $(lvdevices "$lv"); do
echo "# $i:"
- lvdevices $vg/$i | sort | uniq
+ lvdevices "$vg/$i" | sort | uniq
done > check.tmp.all
(grep -v ^# check.tmp.all || true) | sort | uniq -d > check.tmp
- test $(cat check.tmp | wc -l) -eq 0 || \
+ test "$(cat check.tmp | wc -l)" -eq 0 || \
die "mirror images of $lv expected redundant, but are not:" \
- $(cat check.tmp.all)
+ "$(cat check.tmp.all)"
}
lv_err_list_() {
@@ -94,8 +94,8 @@ mirror_images_on() {
local vg=$1
local lv=$2
shift 2
- for i in $(lvdevices $lv); do
- lv_on $vg $lv $1
+ for i in $(lvdevices "$lv"); do
+ lv_on "$vg" "$lv" "$1"
shift
done
}
@@ -105,46 +105,46 @@ mirror_log_on() {
local lv=$2
local where=$3
if test "$where" = "core"; then
- get lv_field $vg/$lv mirror_log | not grep mlog
+ get lv_field "$vg/$lv" mirror_log | not grep mlog
else
- lv_on $vg ${lv}_mlog "$where"
+ lv_on "$vg" "${lv}_mlog" "$where"
fi
}
lv_is_contiguous() {
local lv=$1/$2
- test $(lvl --segments $lv | wc -l) -eq 1 || \
+ test "$(lvl --segments "$lv" | wc -l)" -eq 1 || \
die "LV $lv expected to be contiguous, but is not:" \
- $(lvl --segments $lv)
+ "$(lvl --segments "$lv")"
}
lv_is_clung() {
local lv=$1/$2
- test $(lvdevices $lv | sort | uniq | wc -l) -eq 1 || \
+ test "$(lvdevices "$lv" | sort | uniq | wc -l)" -eq 1 || \
die "LV $lv expected to be clung, but is not:" \
- $(lvdevices $lv | sort | uniq)
+ "$(lvdevices "$lv" | sort | uniq)"
}
mirror_images_contiguous() {
- for i in $(lvdevices $1/$2); do
- lv_is_contiguous $1 $i
+ for i in $(lvdevices "$1/$2"); do
+ lv_is_contiguous "$1" "$i"
done
}
mirror_images_clung() {
- for i in $(lvdevices $1/$2); do
- lv_is_clung $1 $i
+ for i in $(lvdevices "$1/$2"); do
+ lv_is_clung "$1" "$i"
done
}
mirror() {
mirror_nonredundant "$@"
- mirror_images_redundant $1 $2
+ mirror_images_redundant "$1" "$2"
}
mirror_nonredundant() {
- local lv=$1/$2
- local attr=$(get lv_field $lv attr)
+ local lv="$1/$2"
+ local attr=$(get lv_field "$lv" attr)
(echo "$attr" | grep "^......m...$" >/dev/null) || {
if (echo "$attr" | grep "^o.........$" >/dev/null) &&
lvs -a | fgrep "[${2}_mimage" >/dev/null; then
@@ -152,30 +152,30 @@ mirror_nonredundant() {
echo "assuming it is actually a mirror"
else
die "$lv expected a mirror, but is not:" \
- $(lvs $lv)
+ "$(lvs "$lv")"
fi
}
- test -z "$3" || mirror_log_on $1 $2 "$3"
+ test -z "$3" || mirror_log_on "$1" "$2" "$3"
}
mirror_legs() {
- local expect=$3
- test "$expect" -eq $(lvdevices $1/$2 | wc -w)
+ local expect_legs=$3
+ test "$expect_legs" -eq "$(lvdevices "$1/$2" | wc -w)"
}
mirror_no_temporaries() {
local vg=$1
local lv=$2
- (lvl -o name $vg | grep $lv | not grep "tmp") || \
+ (lvl -o name "$vg" | grep "$lv" | not grep "tmp") || \
die "$lv has temporary mirror images unexpectedly:" \
- $(lvl $vg | grep $lv)
+ "$(lvl "$vg" | grep "$lv")"
}
linear() {
- local lv=$1/$2
- test $(get lv_field $lv stripes -a) -eq 1 || \
+ local lv="$1/$2"
+ test "$(get lv_field "$lv" stripes -a)" -eq 1 || \
die "$lv expected linear, but is not:" \
- $(lvl $lv -o+devices)
+ "$(lvl "$lv" -o+devices)"
}
# in_sync <VG> <LV> <ignore 'a'>
@@ -188,25 +188,25 @@ in_sync() {
local snap=""
local lvm_name="$1/$2"
local ignore_a="$3"
- local dm_name=$(echo $lvm_name | sed s:-:--: | sed s:/:-:)
+ local dm_name=$(echo "$lvm_name" | sed s:-:--: | sed s:/:-:)
[ -z "$ignore_a" ] && ignore_a=0
- a=( $(dmsetup status $dm_name) ) || \
+ a=( $(dmsetup status "$dm_name") ) || \
die "Unable to get sync status of $1"
- if [ ${a[2]} = "snapshot-origin" ]; then
- a=( $(dmsetup status ${dm_name}-real) ) || \
+ if [ "${a[2]}" = "snapshot-origin" ]; then
+ a=( $(dmsetup status "${dm_name}-real") ) || \
die "Unable to get sync status of $1"
snap=": under snapshot"
fi
- case ${a[2]} in
+ case "${a[2]}" in
"raid")
# 6th argument is the sync ratio for RAID
idx=6
type=${a[3]}
- if [ ${a[$(($idx + 1))]} != "idle" ]; then
+ if [ "${a[$(($idx + 1))]}" != "idle" ]; then
echo "$lvm_name ($type$snap) is not in-sync"
return 1
fi
@@ -221,9 +221,9 @@ in_sync() {
;;
esac
- b=( $(echo ${a[$idx]} | sed s:/:' ':) )
+ b=( $(echo "${a[$idx]}" | sed s:/:' ':) )
- if [ ${b[0]} -eq 0 -o ${b[0]} != ${b[1]} ]; then
+ if [ "${b[0]}" -eq 0 -o "${b[0]}" != "${b[1]}" ]; then
echo "$lvm_name ($type$snap) is not in-sync"
return 1
fi
@@ -239,20 +239,20 @@ in_sync() {
}
active() {
- local lv=$1/$2
- (get lv_field $lv attr | grep "^....a.....$" >/dev/null) || \
+ local lv="$1/$2"
+ (get lv_field "$lv" attr | grep "^....a.....$" >/dev/null) || \
die "$lv expected active, but lvs says it's not:" \
- $(lvl $lv -o+devices)
- dmsetup info $1-$2 >/dev/null ||
+ "$(lvl "$lv" -o+devices)"
+ dmsetup info "$1-$2" >/dev/null ||
die "$lv expected active, lvs thinks it is but there are no mappings!"
}
inactive() {
- local lv=$1/$2
- (get lv_field $lv attr | grep "^....[-isd].....$" >/dev/null) || \
+ local lv="$1/$2"
+ (get lv_field "$lv" attr | grep "^....[-isd].....$" >/dev/null) || \
die "$lv expected inactive, but lvs says it's not:" \
- $(lvl $lv -o+devices)
- not dmsetup info $1-$2 2>/dev/null || \
+ "$(lvl "$lv" -o+devices)"
+ not dmsetup info "$1-$2" 2>/dev/null || \
die "$lv expected inactive, lvs thinks it is but there are mappings!"
}
@@ -265,20 +265,20 @@ lv_exists() {
lv="$lv $vg/$1"
done
test -n "$lv" || lv=$vg
- lvl $lv &>/dev/null || \
+ lvl "$lv" &>/dev/null || \
die "$lv expected to exist but does not"
}
lv_not_exists() {
local vg=$1
if test $# -le 1 ; then
- if lvl $vg &>/dev/null ; then
+ if lvl "$vg" &>/dev/null ; then
die "$vg expected to not exist but it does!"
fi
else
while [ $# -gt 1 ]; do
shift
- not lvl $vg/$1 &>/dev/null || die "$vg/$1 expected to not exist but it does!"
+ not lvl "$vg/$1" &>/dev/null || die "$vg/$1 expected to not exist but it does!"
done
fi
rm -f debug.log
@@ -371,8 +371,8 @@ compare_vg_field() {
local vg1=$1
local vg2=$2
local field=$3
- local val1=$(vgs --noheadings -o "$field" $vg1)
- local val2=$(vgs --noheadings -o "$field" $vg2)
+ local val1=$(vgs --noheadings -o "$field" "$vg1")
+ local val2=$(vgs --noheadings -o "$field" "$vg2")
test "$val1" = "$val2" || \
die "compare_vg_field: $vg1: $val1, $vg2: $val2"
}
@@ -382,16 +382,16 @@ pvlv_counts() {
local num_pvs=$2
local num_lvs=$3
local num_snaps=$4
- lvs -o+devices $local_vg
- vg_field $local_vg pv_count $num_pvs
- vg_field $local_vg lv_count $num_lvs
- vg_field $local_vg snap_count $num_snaps
+ lvs -o+devices "$local_vg"
+ vg_field "$local_vg" pv_count "$num_pvs"
+ vg_field "$local_vg" lv_count "$num_lvs"
+ vg_field "$local_vg" snap_count "$num_snaps"
}
# Compare md5 check generated from get dev_md5sum
dev_md5sum() {
md5sum -c "md5.$1-$2" || \
- (get lv_field $1/$2 "name,size,seg_pe_ranges"
+ (get lv_field "$1/$2" "name,size,seg_pe_ranges"
die "LV $1/$2 has different MD5 check sum!")
}
@@ -407,14 +407,14 @@ sysfs() {
# check raid_leg_status $vg $lv "Aaaaa"
raid_leg_status() {
- local st=$(dmsetup status $1-$2)
+ local st=$(dmsetup status "$1-$2")
local val=$(echo "$st" | cut -d ' ' -f 6)
test "$val" = "$3" || \
die "$1-$2 status $val != $3 ($st)"
}
grep_dmsetup() {
- dmsetup $1 $2 | tee out
+ dmsetup "$1" "$2" | tee out
grep -q "${@:3}" out || die "Expected output \"${@:3}\" from dmsetup $1 not found!"
}
6 years, 10 months
master - tests: aux.sh fix pid handling
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=491fcd2a921bea6d63b...
Commit: 491fcd2a921bea6d63bbb243bfd972fda3bb6c67
Parent: 96fcf82dddd7bcc7b5c09de09d49d70a04ae8b12
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 29 21:00:17 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:17 2017 +0200
tests: aux.sh fix pid handling
Modification of pids is local (to subshell caused by pipeline).
pids was modified in a subshell. That change might be lost.
---
test/lib/aux.sh | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index f39d400..4e2b246 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -500,17 +500,20 @@ kill_tagged_processes() {
local wait
# read uses all vars within pipe subshell
+ rm -f PIDS
print_procs_by_tag_ "$@" | while read -r pid wait; do
if test -n "$pid" ; then
echo "Killing tagged process: $pid ${wait:0:120}..."
kill -TERM "$pid" 2>/dev/null || true
fi
- pids="$pids $pid"
+ echo "$pid" >> PIDS
done
+ test -f PIDS || return 0
+
# wait if process exited and eventually -KILL
wait=0
- for pid in $pids ; do
+ for pid in $(< PIDS) ; do
while ps "$pid" > /dev/null && test "$wait" -le 10; do
sleep .2
wait=$(( wait + 1 ))
6 years, 10 months
master - tests: aux.sh add -r to read
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=96fcf82dddd7bcc7b5c...
Commit: 96fcf82dddd7bcc7b5c09de09d49d70a04ae8b12
Parent: ec02307e952ef29d4a28fe134c807ac79a61908a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 29 20:50:06 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:17 2017 +0200
tests: aux.sh add -r to read
---
test/lib/aux.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 5e7340e..f39d400 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -877,7 +877,7 @@ common_dev_() {
local pvdev
local offset
- read pos size type pvdev offset < "$name.table"
+ read -r pos size type pvdev offset < "$name.table"
for fromlen in "${offsets[@]}"; do
from=${fromlen%%:*}
6 years, 10 months