From 4c13694b261ff76754a9dd53e6582f65899f7b2f Mon Sep 17 00:00:00 2001 From: lawrencetroup Date: Wed, 11 Oct 2023 14:15:23 +0100 Subject: [PATCH] Modify Linux kernel version check to require at least version 4.6 (#35) Modify Linux kernel version check to require kernel version 4.6 or higher --- CHANGELOG.md | 4 ++++ scripts/host-check | 6 +++--- tests/test_host_check.py | 23 +++++++++++++++++------ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10b0bf3..a04f7b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ The v1 release supports Cisco IOS-XR release versions from 7.7.1 to 7.9.1. +### v1.1.13 (2023-10-11) + +- Modify Linux kernel version check to require kernel version 4.6 or higher. + ### v1.1.12 (2023-06-30) - Add Docker Compose v2 support to `host-check` and `xr-compose` scripts. diff --git a/scripts/host-check b/scripts/host-check index 1df214b..97fc9de 100755 --- a/scripts/host-check +++ b/scripts/host-check @@ -413,13 +413,13 @@ def check_kernel_version() -> CheckFuncReturn: except Exception: return ( CheckState.ERROR, - f"Unable to check the kernel version with command {cmd!r} - must be at least version 4.0", + f"Unable to check the kernel version with command {cmd!r} - must be at least version 4.6", ) - if version_tuple < (4, 0): + if version_tuple < (4, 6): return ( CheckState.FAILED, - f"The kernel version is {version}, but at least version 4.0 is required.", + f"The kernel version is {version}, but at least version 4.6 is required.", ) # Check for RHEL/CentOS 8.3 kernel version diff --git a/tests/test_host_check.py b/tests/test_host_check.py index 696ce81..d49eba1 100644 --- a/tests/test_host_check.py +++ b/tests/test_host_check.py @@ -970,8 +970,8 @@ class TestKernelVersion(_CheckTestBase): def test_success(self, capsys): """Test the success case.""" - result, output = self.perform_check(capsys, cmd_effects="4.1") - assert textwrap.dedent(output) == "PASS -- Kernel version (4.1)\n" + result, output = self.perform_check(capsys, cmd_effects="4.6") + assert textwrap.dedent(output) == "PASS -- Kernel version (4.6)\n" assert result is CheckState.SUCCESS def test_subproc_error(self, capsys): @@ -982,7 +982,7 @@ def test_subproc_error(self, capsys): assert textwrap.dedent(output) == textwrap.dedent( """\ ERROR -- Kernel version - Unable to check the kernel version with command 'uname -r' - must be at least version 4.0 + Unable to check the kernel version with command 'uname -r' - must be at least version 4.6 """ ) assert result is CheckState.ERROR @@ -995,18 +995,29 @@ def test_no_version_match(self, capsys): assert textwrap.dedent(output) == textwrap.dedent( """\ ERROR -- Kernel version - Unable to check the kernel version with command 'uname -r' - must be at least version 4.0 + Unable to check the kernel version with command 'uname -r' - must be at least version 4.6 """ ) assert result is CheckState.ERROR - def test_old_version(self, capsys): + def test_old_major_version(self, capsys): """Test the version being too old.""" result, output = self.perform_check(capsys, cmd_effects="3.9.8") assert textwrap.dedent(output) == textwrap.dedent( """\ FAIL -- Kernel version - The kernel version is 3.9, but at least version 4.0 is required. + The kernel version is 3.9, but at least version 4.6 is required. + """ + ) + assert result is CheckState.FAILED + + def test_old_minor_version(self, capsys): + """Test the version being too old.""" + result, output = self.perform_check(capsys, cmd_effects="4.5") + assert textwrap.dedent(output) == textwrap.dedent( + """\ + FAIL -- Kernel version + The kernel version is 4.5, but at least version 4.6 is required. """ ) assert result is CheckState.FAILED