[Fuego] [PATCH 06/11] LTP: add a kernel version check using version_lt

Daniel Sangorrin daniel.sangorrin at toshiba.co.jp
Fri May 18 02:48:51 UTC 2018


Signed-off-by: Daniel Sangorrin <daniel.sangorrin at toshiba.co.jp>
---
 engine/tests/Functional.LTP/fuego_test.sh | 35 +++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/engine/tests/Functional.LTP/fuego_test.sh b/engine/tests/Functional.LTP/fuego_test.sh
index aa166da..82fafad 100755
--- a/engine/tests/Functional.LTP/fuego_test.sh
+++ b/engine/tests/Functional.LTP/fuego_test.sh
@@ -110,6 +110,31 @@ function skip_if_command_unavailable {
     fi
 }
 
+# $1: minimum kernel version
+# $2: string with LTP test names separated by spaces
+# FIXTHIS: do not skip tests by kernel version if the kernel is an LTS kernel
+function skip_if_kver_lt {
+    local MIN_KVER="$1"
+    local TESTS="$2"
+    local KVER=$(cmd "uname -r")
+
+    if version_lt "${KVER}" "${MIN_KVER}"; then
+        skip_tests "${TESTS}"
+    fi
+}
+
+# $1: maximum kernel version
+# $2: string with LTP test names separated by spaces
+function skip_if_kver_gt {
+    local MAX_KVER="$1"
+    local TESTS="$2"
+    local KVER=$(cmd "uname -r")
+
+    if version_lt "${MAX_KVER}" "${KVER}"; then
+        skip_tests "${TESTS}"
+    fi
+}
+
 # $1: a HAVE_xxx option to grep from ltp's include/config.h (after ./configure)
 # $2: string with LTP test names separated by spaces
 # $3: optional message
@@ -200,12 +225,10 @@ function test_pre_check {
     rm -f $target_mounts
 
     echo "Tests skipped by Linux kernel version"
-    # FIXTHIS: compare with the kernel version before adding tests to the skiplist
-    kver=$(cmd "uname -r")
-    echo "kernel version: $kver"
-    skip_tests "fallocate04" # needs Linux 3.15 or newer
-    skip_tests "inotify06" # will loop/crash kernels that dont have commit 8f2f3eb59dff (<4.2)
-    skip_tests "ptrace03" # Only works for <2.6.26, above that the kernel allows to trace init
+    # FIXTHIS: grep tst_kvercmp on LTP to check for other tests that require specific versions
+    skip_if_kver_gt "2.6.26" "ptrace03" # Only works for <2.6.26, above that the kernel allows to trace init
+    skip_if_kver_lt "3.15" "fallocate04" # The test needs Linux 3.15 or newer
+    skip_if_kver_lt "4.2" "inotify06" # will loop/crash kernels that dont have commit 8f2f3eb59dff (<4.2)
 
     echo "Tests skipped depending on the availability of a command on the target"
     # FIXTHIS: only check the necessary ones
-- 
2.7.4




More information about the Fuego mailing list