[ovs-dev] [PATCH v2 2/4] test: Add two m4 functions to skip tests for certain kernel versions

Yifeng Sun pkusunyifeng at gmail.com
Wed Aug 15 13:24:48 UTC 2018


Some tests depend on native Linux gre modules to setup testing environments.
However, some kernel versions require OVS to use compatable gre modules. In
this case, these tests always fail.

This patch helps to skip a test if it fails due to this reason. The new m4
functions will be used by later patches.

Signed-off-by: Yifeng Sun <pkusunyifeng at gmail.com>
---
v1->v2: Let tests skip in check-system-userspace when they always fail.

 tests/system-kmod-macros.at      | 22 ++++++++++++++++++++++
 tests/system-userspace-macros.at | 16 ++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/tests/system-kmod-macros.at b/tests/system-kmod-macros.at
index 61911ac..770703b 100644
--- a/tests/system-kmod-macros.at
+++ b/tests/system-kmod-macros.at
@@ -132,3 +132,25 @@ m4_define([CHECK_CT_DPIF_GET_NCONNS],
 [
     AT_SKIP_IF([:])
 ])
+
+# OVS_CHECK_KERNEL([minversion], [minsublevel], [maxversion], [maxsublevel])
+#
+# Check if kernel version falls between minversion.minsublevel and
+# maxversion.maxsublevel, skip this test if it is not.
+m4_define([OVS_CHECK_KERNEL],
+[
+    version=$(uname -r | sed -e 's/\./ /g' | awk '{print $ 1}')
+    sublevel=$(uname -r | sed -e 's/\./ /g' | awk '{print $ 2}')
+    AT_SKIP_IF([test $version -lt $1 || ( test $version -eq $1 && test $sublevel -lt $2 ) || test $version -gt $3 || ( test $version -eq $3 && test $sublevel -gt $4 )])
+])
+
+# OVS_CHECK_KERNEL_EXCL([minversion], [minsublevel], [maxversion], [maxsublevel])
+#
+# Check that kernel version doesn't fall between minversion.minsublevel and
+# maxversion.maxsublevel, skip this test if it is.
+m4_define([OVS_CHECK_KERNEL_EXCL],
+[
+    version=$(uname -r | sed -e 's/\./ /g' | awk '{print $ 1}')
+    sublevel=$(uname -r | sed -e 's/\./ /g' | awk '{print $ 2}')
+    AT_SKIP_IF([ ! ( test $version -lt $1 || ( test $version -eq $1 && test $sublevel -lt $2 ) || test $version -gt $3 || ( test $version -eq $3 && test $sublevel -gt $4 ) ) ])
+])
diff --git a/tests/system-userspace-macros.at b/tests/system-userspace-macros.at
index fb7b09c..968a95e 100644
--- a/tests/system-userspace-macros.at
+++ b/tests/system-userspace-macros.at
@@ -127,3 +127,19 @@ m4_define([CHECK_CT_DPIF_SET_GET_MAXCONNS])
 # Perform requirements checks for running ovs-dpctl ct-get-nconns. The
 # userspace datapath does support this feature.
 m4_define([CHECK_CT_DPIF_GET_NCONNS])
+
+# OVS_CHECK_KERNEL([minversion], [maxversion], [minsublevel], [maxsublevel])
+#
+# The userspace skips all tests that check kernel version.
+m4_define([OVS_CHECK_KERNEL],
+[
+    AT_SKIP_IF([:])
+])
+
+# OVS_CHECK_KERNEL_EXCL([minversion], [maxversion], [minsublevel], [maxsublevel])
+#
+# The userspace skips all tests that check kernel version.
+m4_define([OVS_CHECK_KERNEL_EXCL],
+[
+    AT_SKIP_IF([:])
+])
-- 
2.7.4



More information about the dev mailing list