Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle warnings in dkms status (BugFix) #1415

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
jocave marked this conversation as resolved.
Show resolved Hide resolved
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
Loading