summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Broz <mbroz@redhat.com>2011-06-09 18:58:00 +0000
committerMilan Broz <mbroz@redhat.com>2011-06-09 18:58:00 +0000
commit96e7ca3c785c23f299555159ffa0819301805411 (patch)
tree2ed7002be58e99d5853ba4f3bbf294d8c8ca485c
parentb39fdcf45b947a6acda4d8d31ce9386f724b0817 (diff)
downloadlvm2-96e7ca3c785c23f299555159ffa0819301805411.tar.gz
lvm2-96e7ca3c785c23f299555159ffa0819301805411.tar.xz
lvm2-96e7ca3c785c23f299555159ffa0819301805411.zip
Fix kernel version parsing in tests, use common function.
-rw-r--r--test/api/percent.sh3
-rw-r--r--test/lib/utils.sh17
-rw-r--r--test/t-pvcreate-operation-md.sh12
3 files changed, 23 insertions, 9 deletions
diff --git a/test/api/percent.sh b/test/api/percent.sh
index e93e4ccf..70949071 100644
--- a/test/api/percent.sh
+++ b/test/api/percent.sh
@@ -13,8 +13,7 @@
. lib/test
-linux_minor=$(echo `uname -r` | cut -d'.' -f3 | cut -d'-' -f1)
-test $linux_minor -le 32 && skip
+kernel_at_least 2 6 33 || skip
aux prepare_devs 2
vgcreate -c n -s 4k $vg $(cat DEVICES)
diff --git a/test/lib/utils.sh b/test/lib/utils.sh
index 69ae2afb..3f38cd43 100644
--- a/test/lib/utils.sh
+++ b/test/lib/utils.sh
@@ -152,6 +152,23 @@ skip() {
exit 200
}
+kernel_at_least() {
+ major=$(uname -r |cut -d. -f1)
+ minor=$(uname -r |cut -d. -f2 | cut -d- -f1)
+
+ test $major -gt $1 && return 0
+ test $major -lt $1 && return 1
+ test $minor -gt $2 && return 0
+ test $minor -lt $2 && return 1
+ test -z "$3" && return 0
+
+ minor2=$(uname -r | cut -d. -f3)
+ test -z "$minor2" && return 0
+ test $minor2 -ge $3 2>/dev/null && return 0
+
+ return 1
+}
+
. lib/paths || { echo >&2 you must run make first; exit 1; }
PATH=$abs_top_builddir/test/lib:$PATH
diff --git a/test/t-pvcreate-operation-md.sh b/test/t-pvcreate-operation-md.sh
index 5085ce14..dc48917e 100644
--- a/test/t-pvcreate-operation-md.sh
+++ b/test/t-pvcreate-operation-md.sh
@@ -70,12 +70,10 @@ pvcreate --metadatasize 128k \
$mddev
check pv_field $mddev pe_start $pv_align
-# Get linux minor version
-linux_minor=$(echo `uname -r` | cut -d'.' -f3 | cut -d'-' -f1)
# Test newer topology-aware alignment detection
# - first added to 2.6.31 but not "reliable" until 2.6.33
-if [ $linux_minor -ge 33 ]; then
+if kernel_at_least 2 6 33 ; then
pv_align="1.00m"
# optimal_io_size=131072, minimum_io_size=65536
pvcreate --metadatasize 128k \
@@ -84,7 +82,7 @@ if [ $linux_minor -ge 33 ]; then
fi
# partition MD array directly, depends on blkext in Linux >= 2.6.28
-if [ $linux_minor -ge 28 ]; then
+if kernel_at_least 2 6 28 ; then
# create one partition
sfdisk $mddev <<EOF
,,83
@@ -111,11 +109,11 @@ EOF
# Checking for 'alignment_offset' in sysfs implies Linux >= 2.6.31
# but reliable alignment_offset support requires kernel.org Linux >= 2.6.33
sysfs_alignment_offset=/sys/dev/block/${mddev_maj_min}/${base_mddev_p}/alignment_offset
- [ -f $sysfs_alignment_offset -a $linux_minor -ge 33 ] && \
+ [ -f $sysfs_alignment_offset ] && kernel_at_least 2 6 33 && \
alignment_offset=`cat $sysfs_alignment_offset` || \
alignment_offset=0
- if [ $alignment_offset -gt 0 ]; then
+ if [ $alignment_offset -gt 0 ]; then
# default alignment is 1M, add alignment_offset
pv_align=$((1048576+$alignment_offset))B
pvcreate --metadatasize 128k $mddev_p
@@ -125,7 +123,7 @@ EOF
fi
# Test newer topology-aware alignment detection w/ --dataalignment override
-if [ $linux_minor -ge 33 ]; then
+if kernel_at_least 2 6 33 ; then
cleanup_md
pvcreate -f $dev1
pvcreate -f $dev2