forked from Mirrors/btrfs-progs
btrfs-progs: tests: add helper to compare kernel versions
Return succcess if runnning kernel >= parameter. Most callers will want to skip the test. Signed-off-by: David Sterba <dsterba@suse.com>master
parent
06f075976e
commit
201ad5c9e5
22
tests/common
22
tests/common
|
@ -528,6 +528,28 @@ check_kernel_support()
|
|||
return 0
|
||||
}
|
||||
|
||||
# compare running kernel version to the given parameter, return success
|
||||
# if running is newer than requested (let caller decide if to fail or skip)
|
||||
# $1: minimum version of running kernel in major.minor format (eg. 4.19)
|
||||
check_min_kernel_version()
|
||||
{
|
||||
local unamemajor
|
||||
local unameminor
|
||||
local argmajor
|
||||
local argminor
|
||||
|
||||
# 4.19.1-1-default
|
||||
uname=$(uname -r)
|
||||
# 4.19.1
|
||||
uname=${uname%%-*}
|
||||
IFS=. read unamemajor unameminor tmp <<< "$uname"
|
||||
IFS=. read argmajor argminor tmp <<< "$1"
|
||||
# "compare versions: ${unamemajor}.${unameminor} ? ${argmajor}.${argminor}"
|
||||
[ "$unamemajor" -lt "$argmajor" ] || return 1
|
||||
[ "$unameminor" -lt "$argminor" ] || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
# how many files to create.
|
||||
DATASET_SIZE=50
|
||||
|
||||
|
|
Loading…
Reference in New Issue