Skip to content

Commit

Permalink
changes to check kernel errors using function call
Browse files Browse the repository at this point in the history
  • Loading branch information
umfranci committed Feb 13, 2025
1 parent 40c5a99 commit b63da25
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lisa/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from lisa.nic import Nics, NicsBSD
from lisa.operating_system import OperatingSystem
from lisa.secret import add_secret
from lisa.tools import Chmod, Df, Echo, Lsblk, Mkfs, Mount, Reboot, Uname, Wsl
from lisa.tools import Chmod, Df, Dmesg, Echo, Lsblk, Mkfs, Mount, Reboot, Uname, Wsl
from lisa.tools.mkfs import FileSystem
from lisa.util import (
ContextMixin,
Expand Down Expand Up @@ -110,6 +110,7 @@ def __init__(
self._support_sudo: Optional[bool] = None
self._is_dirty: bool = False
self.capture_boot_time: bool = False
self.assert_kernel_error: bool = False
self.capture_azure_information: bool = False
self.capture_kernel_config: bool = False
self.has_checked_bash_prompt: bool = False
Expand Down Expand Up @@ -501,6 +502,19 @@ def get_information(self) -> Dict[str, str]:

return final_information

def exec_check_dmesg_oops(self) -> bool:
try:
dmesg = self.tools[Dmesg]
results = dmesg.check_kernel_errors(force_run=True, throw_error=False)
if results:
# If there are any results obtained from the Kernel Error Check, then return True
return True
else:
return False
except LisaException as ex:
self.log.error(f"Error: {ex}")
return True

def expand_env_path(self, raw_path: str) -> str:
echo = self.tools[Echo]
result = echo.run(raw_path, shell=True)
Expand Down
1 change: 1 addition & 0 deletions lisa/platform_.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def deploy_environment(self, environment: Environment) -> None:
node.features = Features(node, self)
node.capture_azure_information = platform_runbook.capture_azure_information
node.capture_boot_time = platform_runbook.capture_boot_time
node.assert_kernel_error = platform_runbook.assert_kernel_error
node.capture_kernel_config = (
platform_runbook.capture_kernel_config_information
)
Expand Down
2 changes: 2 additions & 0 deletions lisa/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,8 @@ class Platform(TypedSchema, ExtendableSchemaMixin):
capture_azure_information: bool = False
# capture boot time info or not
capture_boot_time: bool = False
# to check if dmesg logs need to be analyzed after each test case
assert_kernel_error: bool
# capture kernel config info or not
capture_kernel_config_information: bool = False
capture_vm_information: bool = True
Expand Down
9 changes: 9 additions & 0 deletions lisa/testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,10 +857,19 @@ def __run_case(
test_kwargs=test_kwargs,
)
case_result.set_status(TestStatus.PASSED, "")
if node.assert_kernel_error:
nodes = case_result.environment.nodes
for node in nodes.list():
self.__node_kernel_error_check(node, log)
except Exception as identifier:
case_result.handle_exception(exception=identifier, log=log)
log.debug(f"case end in {timer}")

def __node_kernel_error_check(self, node: schema.NodeSpace, log: Logger) -> None:
dmesg_check_result = node.exec_check_dmesg_oops()[0]
if dmesg_check_result:
raise LisaException(f"failed. Kernel Errors found in the DMesg logs after test case execution. Please check the same!")


def get_suites_metadata() -> Dict[str, TestSuiteMetadata]:
return _all_suites
Expand Down

0 comments on commit b63da25

Please sign in to comment.