From 419c0a8bea4c36a6bead0173d6ae4f811a9480de Mon Sep 17 00:00:00 2001 From: Santhosh Date: Wed, 4 May 2016 12:03:34 +0530 Subject: [PATCH] Renamed kernel_build.py to kernel.py and added check_version and updated module name in examples/tests/linuxbuild.py --- avocado/utils/{kernel_build.py => kernel.py} | 14 ++++++++++++++ examples/tests/linuxbuild.py | 8 ++++---- 2 files changed, 18 insertions(+), 4 deletions(-) rename avocado/utils/{kernel_build.py => kernel.py} (87%) diff --git a/avocado/utils/kernel_build.py b/avocado/utils/kernel.py similarity index 87% rename from avocado/utils/kernel_build.py rename to avocado/utils/kernel.py index bf7894fb..6caab063 100755 --- a/avocado/utils/kernel_build.py +++ b/avocado/utils/kernel.py @@ -13,11 +13,13 @@ # # Copyright: Red Hat Inc. 2014 # Author: Ruda Moura +# Author: Santhosh G import os import shutil import logging import tempfile +from distutils.version import LooseVersion from . import download, archive, build @@ -100,3 +102,15 @@ class KernelBuild(object): def __del__(self): shutil.rmtree(self.work_dir) + + +def check_version(version): + """ + This utility function compares the current kernel version with + the version parameter and gives assertion error if the version + parameter is greater. + + :type version: string + :param version: version to be compared with current kernel version + """ + assert LooseVersion(os.uname()[2]) > LooseVersion(version), "Old kernel" diff --git a/examples/tests/linuxbuild.py b/examples/tests/linuxbuild.py index c1354fe0..c956a382 100755 --- a/examples/tests/linuxbuild.py +++ b/examples/tests/linuxbuild.py @@ -2,7 +2,7 @@ from avocado import Test from avocado import main -from avocado.utils import kernel_build +from avocado.utils import kernel class LinuxBuildTest(Test): @@ -20,9 +20,9 @@ class LinuxBuildTest(Test): if linux_config is not None: linux_config = os.path.join(self.datadir, linux_config) - self.linux_build = kernel_build.KernelBuild(kernel_version, - linux_config, - self.srcdir) + self.linux_build = kernel.KernelBuild(kernel_version, + linux_config, + self.srcdir) self.linux_build.download() self.linux_build.uncompress() self.linux_build.configure() -- GitLab