diff mbox

[ndctl] test: fix kernel version detection in dax-errors.sh

Message ID 149107487750.16325.8238092319248519520.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit 0cd15aa1e6fa
Headers show

Commit Message

Dan Williams April 1, 2017, 7:27 p.m. UTC
Honor the KVER environment variable for overriding kernel version
detection.

Reported-by: Linda Knippers <linda.knippers@hpe.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/dax-errors.sh |   18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/test/dax-errors.sh b/test/dax-errors.sh
index a383b14fcd5e..25615df44180 100755
--- a/test/dax-errors.sh
+++ b/test/dax-errors.sh
@@ -23,14 +23,16 @@  err() {
 	exit $rc
 }
 
-eval $(uname -r | awk -F. '{print "maj="$1 ";" "min="$2}')
-if [ $maj -lt 4 ]; then
-	echo "kernel $maj.$min lacks dax error handling"
-	exit $rc
-elif [ $maj -eq 4 -a $min -lt 7 ]; then
-	echo "kernel $maj.$min lacks dax error handling"
-	exit $rc
-fi
+check_min_kver()
+{
+	local ver="$1"
+	: "${KVER:=$(uname -r)}"
+
+	[ -n "$ver" ] || return 1
+	[[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)" ]]
+}
+
+check_min_kver "4.7" || { echo "kernel $KVER may lack dax error handling"; exit $rc; }
 
 set -e
 mkdir -p $MNT