Skip to content

Commit

Permalink
Handle warnings in dkms status (BugFix) (#1415)
Browse files Browse the repository at this point in the history
* Handle warnings in dkms status

* When message is providing log it as warning
  • Loading branch information
jocave authored Aug 15, 2024
1 parent e76778e commit 21817f1
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
9 changes: 8 additions & 1 deletion providers/sru/bin/dkms_build_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ def parse_dkms_status(dkms_status: str, ubuntu_release: str) -> List[Dict]:
"""
kernel_info = []
for line in dkms_status.splitlines():
details, status = line.split(": ")
details, fullstatus = line.split(": ")
if " " in fullstatus:
(status, rest) = fullstatus.split(maxsplit=1)
logger.warning("dkms status included warning:")
logger.warning(" module: {}".format(details))
logger.warning(" message: {}".format(rest))
else:
status = fullstatus
# will only get comma separated info on two statuses
# https://github.com/dell/dkms/blob/master/dkms.in#L1866
if status in ("built", "installed"):
Expand Down
56 changes: 56 additions & 0 deletions providers/sru/tests/test_dkms_build_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,30 @@ class TestDKMSValidation(unittest.TestCase):
"tp_smapi/0.43, 6.8.0-40-generic, x86_64: installed"
)

dkms_status_with_warning = (
"fwts-efi-runtime-dkms/22.03.00, 6.0.0-1011-oem, x86_64: installed "
"(WARNING! Diff between built and installed module!)"
)

sorted_kernel_info = [
{"version": "6.5.0-15-generic", "status": "installed"},
{"version": "6.5.0-17-generic", "status": "installed"},
]

sorted_kernel_info_efi_test_driver = [
{"version": "6.1.0-1028-oem", "status": "installed"},
{"version": "6.1.0-1032-oem", "status": "installed"},
{"version": "6.1.0-1033-oem", "status": "installed"},
{"version": "6.1.0-1034-oem", "status": "installed"},
{"version": "6.1.0-1035-oem", "status": "installed"},
{"version": "6.5.0-1020-oem", "status": "installed"},
{"version": "6.5.0-1022-oem", "status": "installed"},
{"version": "6.5.0-1023-oem", "status": "installed"},
{"version": "6.5.0-1024-oem", "status": "installed"},
{"version": "6.5.0-1026-oem", "status": "installed"},
{"version": "6.8.0-40-generic", "status": "installed"},
]

@patch("dkms_build_validation.subprocess.check_output")
def test_run_command(self, mock_check_output):
mock_check_output.return_value = "output"
Expand Down Expand Up @@ -99,6 +118,16 @@ def test_parse_dkms_status_efi_test(self):
]
self.assertEqual(kernel_info, expected_kernel_info)

def test_parse_dkms_status_with_warning(self):
ubuntu_release = "22.04"
kernel_info = parse_dkms_status(
self.dkms_status_with_warning, ubuntu_release
)
expected_kernel_info = [
{"version": "6.0.0-1011-oem", "status": "installed"},
]
self.assertEqual(kernel_info, expected_kernel_info)

def test_parse_dkms_status_old(self):
old_dkms_status = (
"fwts, 24.01.00, 6.5.0-17-generic, x86_64: installed\n"
Expand Down Expand Up @@ -152,6 +181,33 @@ def test_check_kernel_version(self):
1,
)

self.assertEqual(
check_kernel_version(
"6.1.0-1028-oem",
self.sorted_kernel_info_efi_test_driver,
self.dkms_status_efi_test_driver,
),
1,
)

self.assertEqual(
check_kernel_version(
"6.5.0-1023-oem",
self.sorted_kernel_info_efi_test_driver,
self.dkms_status_efi_test_driver,
),
1,
)

self.assertEqual(
check_kernel_version(
"6.8.0-40-generic",
self.sorted_kernel_info_efi_test_driver,
self.dkms_status_efi_test_driver,
),
0,
)

def test_check_dkms_module_count(self):
# Test with the same number of modules
self.assertEqual(
Expand Down

0 comments on commit 21817f1

Please sign in to comment.