summaryrefslogtreecommitdiff
path: root/tests/topotests/lib/common_config.py
diff options
context:
space:
mode:
authornaveen <nguggarigoud@vmware.com>2020-08-18 19:52:45 +0530
committernguggarigoud <nguggarigoud@vmware.com>2020-09-15 15:44:10 +0530
commit3dfd384ec4f3d7cdcc43373c6ff6c197fe81c81b (patch)
tree80bc4523d2ca96067188a934a41df7f858f1fa9e /tests/topotests/lib/common_config.py
parenteb5e807234ae269614887097507f7a82206478e3 (diff)
tests: Moving kernel version check to API.
Signed-off-by: naveen <nguggarigoud@vmware.com>
Diffstat (limited to 'tests/topotests/lib/common_config.py')
-rw-r--r--tests/topotests/lib/common_config.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py
index 1846d43138..5a6d3f3899 100644
--- a/tests/topotests/lib/common_config.py
+++ b/tests/topotests/lib/common_config.py
@@ -36,6 +36,8 @@ import ConfigParser
import traceback
import socket
import ipaddress
+import platform
+
if sys.version_info[0] > 2:
import io
@@ -46,7 +48,7 @@ else:
from lib.topolog import logger, logger_config
from lib.topogen import TopoRouter, get_topogen
-from lib.topotest import interface_set_status
+from lib.topotest import interface_set_status, version_cmp
FRRCFG_FILE = "frr_json.conf"
FRRCFG_BKUP_FILE = "frr_json_initial.conf"
@@ -3973,3 +3975,30 @@ def verify_vrf_vni(tgen, input_dict):
logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
return False
+
+
+def required_linux_kernel_version(required_version):
+ """
+ This API is used to check linux version compatibility of the test suite.
+ If version mentioned in required_version is higher than the linux kernel
+ of the system, test suite will be skipped. This API returns true or errormsg.
+
+ Parameters
+ ----------
+ * `required_version` : Kernel version required for the suites to run.
+
+ Usage
+ -----
+ result = linux_kernel_version_lowerthan('4.15')
+
+ Returns
+ -------
+ errormsg(str) or True
+ """
+ system_kernel = platform.release()
+ if version_cmp(system_kernel, required_version) < 0:
+ error_msg = ('These tests will not run on kernel "{}", '
+ 'they require kernel >= {})'.format(system_kernel,
+ required_version ))
+ return error_msg
+ return True \ No newline at end of file