1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

tests: move kernel_at_least to aux

Hide func processing and reuse existing
version_at_least().
This commit is contained in:
Zdenek Kabelac 2015-04-30 13:23:56 +02:00
parent f48a4c391c
commit 4daede06e5
6 changed files with 12 additions and 23 deletions

View File

@ -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

View File

@ -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)

View File

@ -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=( $(<DEVICES) )

View File

@ -67,7 +67,7 @@ check mirror $vg mirror2
vgs $vg
vgremove -ff $vg
if kernel_at_least 3 0 0; then
if aux kernel_at_least 3 0 0; then
# 2-way, mirrored log
# Double log failure, full replace
vgcreate $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" "$dev6"

View File

@ -175,7 +175,7 @@ fail lvcreate -Mn --major 234 -l1 $vg
fail lvcreate --persistent n --minor 234 -l1 $vg
# out-of-range minor value
fail lvcreate --minor 9999999 -l1 $vg
if kernel_at_least 2 4 0; then
if aux kernel_at_least 2 4 0; then
# On >2.4 we ignore --major
lvcreate --major 234 -l1 $vg |& tee err;
grep "Ignoring" err

View File

@ -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" <<EOF
,,83
@ -69,7 +69,7 @@ EOF
# Checking for 'alignment_offset' in sysfs implies Linux >= 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"