@@ -206,15 +206,22 @@ _have_kernel_option() {
# Check whether the version of the running kernel is greater than or equal to
# $1.$2.$3
-_have_kver() {
+_kver_gt_or_eq() {
+ local a b c
local d=$1 e=$2 f=$3
IFS='.' read -r a b c < <(uname -r | sed 's/-.*//;s/[^.0-9]//')
- if [ $((a * 65536 + b * 256 + c)) -lt $((d * 65536 + e * 256 + f)) ];
- then
- SKIP_REASONS+=("Kernel version too old")
- return 1
+ (((a * 65536 + b * 256 + c) >= (d * 65536 + e * 256 + f)))
+}
+
+# Check whether the version of the running kernel is greater than or equal to
+# $1.$2.$3 and set SKIP_REASONS.
+_have_kver() {
+ if _kver_gt_or_eq "$1" "$2" "$3"; then
+ return 0
fi
+ SKIP_REASONS+=("Kernel version too old")
+ return 1
}
_have_tracefs() {
To adjust test conditions per kernel version, introduce the new helper function _kver_gt_or_eq. Also simplify the similar function _have_kver using _kver_gt_or_eq. Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> --- common/rc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)