[PATCH blktests 1/2] common/rc: introduce _kver_gt_or_eq

Shin'ichiro Kawasaki shinichiro.kawasaki at wdc.com
Tue Nov 14 21:52:19 PST 2023


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 at wdc.com>
---
 common/rc | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/common/rc b/common/rc
index c3680f5..a3cdfa6 100644
--- a/common/rc
+++ b/common/rc
@@ -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() {
-- 
2.41.0




More information about the Linux-nvme mailing list