From 4daede06e50bc87e7d5e0b9645e239a9fb03adc0 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 30 Apr 2015 13:23:56 +0200 Subject: [PATCH] tests: move kernel_at_least to aux Hide func processing and reuse existing version_at_least(). --- test/api/percent.sh | 2 +- test/lib/aux.sh | 6 +++++- test/lib/utils.sh | 15 --------------- test/shell/lvconvert-repair-replace.sh | 2 +- test/shell/lvcreate-usage.sh | 2 +- test/shell/pvcreate-operation-md.sh | 8 ++++---- 6 files changed, 12 insertions(+), 23 deletions(-) diff --git a/test/api/percent.sh b/test/api/percent.sh index a503ca345..e099497f3 100644 --- a/test/api/percent.sh +++ b/test/api/percent.sh @@ -13,7 +13,7 @@ . lib/inittest -kernel_at_least 2 6 33 || skip +aux kernel_at_least 2 6 33 || skip aux prepare_pvs 2 diff --git a/test/lib/aux.sh b/test/lib/aux.sh index 6fceb68b1..276bb3518 100644 --- a/test/lib/aux.sh +++ b/test/lib/aux.sh @@ -936,7 +936,7 @@ version_at_least() { local major local minor local revision - IFS=. read -r major minor revision <<< "$1" + IFS=".-" read -r major minor revision <<< "$1" shift test -z "$1" && return 0 @@ -1073,6 +1073,10 @@ total_mem() { done < /proc/meminfo } +kernel_at_least() { + version_at_least "$(uname -r)" "$@" +} + test -z "$LVM_TEST_AUX_TRACE" || set -x test -f DEVICES && devs=$(< DEVICES) diff --git a/test/lib/utils.sh b/test/lib/utils.sh index 80e5922b5..ba3ba34ac 100644 --- a/test/lib/utils.sh +++ b/test/lib/utils.sh @@ -214,21 +214,6 @@ skip() { exit 200 } -kernel_at_least() { - local major=$(uname -r | cut -d. -f1) - local minor=$(uname -r | cut -d. -f2 | cut -d- -f1) - - test "$major" -gt "$1" && return 0 - test "$major" -eq "$1" || return 1 - test "$minor" -gt "$2" && return 0 - test "$minor" -eq "$2" || return 1 - test -z "$3" && return 0 - - local minor2=$(uname -r | cut -d. -f3 | cut -d- -f1) - test -z "$minor2" -a "$3" -ne 0 && return 1 - test "$minor2" -ge "$3" 2>/dev/null || return 1 -} - get_devs() { local IFS=$IFS_NL DEVICES=( $(2.4 we ignore --major lvcreate --major 234 -l1 $vg |& tee err; grep "Ignoring" err diff --git a/test/shell/pvcreate-operation-md.sh b/test/shell/pvcreate-operation-md.sh index 810fc539a..52a2c37bf 100644 --- a/test/shell/pvcreate-operation-md.sh +++ b/test/shell/pvcreate-operation-md.sh @@ -45,7 +45,7 @@ check pv_field "$pvdev" pe_start "1.00m" # Test newer topology-aware alignment detection # - first added to 2.6.31 but not "reliable" until 2.6.33 -if kernel_at_least 2 6 33 ; then +if aux kernel_at_least 2 6 33 ; then # optimal_io_size=131072, minimum_io_size=65536 pvcreate --metadatasize 128k \ --config 'devices { md_chunk_alignment=0 }' "$pvdev" @@ -53,7 +53,7 @@ if kernel_at_least 2 6 33 ; then fi # partition MD array directly, depends on blkext in Linux >= 2.6.28 -if kernel_at_least 2 6 28 ; then +if aux kernel_at_least 2 6 28 ; then # create one partition sfdisk "$mddev" <= 2.6.31 # but reliable alignment_offset support requires kernel.org Linux >= 2.6.33 - if kernel_at_least 2 6 33 ; then + if aux kernel_at_least 2 6 33 ; then # in case the system is running without devtmpfs /dev # wait here for created device node on tmpfs test "$DM_DEV_DIR" != "/dev" && cp -LR "${mddev}p1" "$DM_DEV_DIR" @@ -94,7 +94,7 @@ EOF fi # Test newer topology-aware alignment detection w/ --dataalignment override -if kernel_at_least 2 6 33 ; then +if aux kernel_at_least 2 6 33 ; then # make sure we're clean for another test dd if=/dev/zero of="$mddev" bs=512 count=1 aux prepare_md_dev 0 1024 2 "$dev1" "$dev2"