Skip to content

feat: Add custom_allowlist to verify_messages function#7

Open
KTokarze wants to merge 1 commit into
intel:mainfrom
KTokarze:add_custom_list
Open

feat: Add custom_allowlist to verify_messages function#7
KTokarze wants to merge 1 commit into
intel:mainfrom
KTokarze:add_custom_list

Conversation

@KTokarze
Copy link
Copy Markdown

@KTokarze KTokarze commented May 25, 2026

This pull request enhances the flexibility of the verify_messages method in the mfd_dmesg module by allowing users to provide a custom allowlist of benign error messages to ignore. It also adds comprehensive unit tests to verify this new functionality and ensure correct behavior in various scenarios.

Enhancements to allowlist functionality

  • The verify_messages method in base.py now accepts a custom_allowlist parameter, enabling callers to specify which error messages should be ignored during verification, instead of always using the default DMESG_WHITELIST.
  • The error filtering logic in verify_messages is updated to use the provided custom_allowlist rather than the static whitelist, making the error checking more customizable.

Testing improvements

  • Several new unit tests are added in test_base.py to cover cases with a custom allowlist, partial matches, and an empty allowlist, ensuring the new functionality works as intended and edge cases are handled. [1] [2]

Type hinting and imports

  • The type hints and imports in base.py are updated to support the new parameter and maintain type safety, specifically by adding Any to the imports.

Copilot AI review requested due to automatic review settings May 25, 2026 12:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for providing a custom allowlist when verifying dmesg messages, and extends unit tests to cover custom allowlist behavior.

Changes:

  • Extend verify_messages() to accept a custom_allowlist parameter instead of always using DMESG_WHITELIST.
  • Add unit tests validating full-match, partial-match, and empty allowlist behaviors.
  • Minor formatting fix in constants.py.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 10 comments.

File Description
mfd_dmesg/base.py Adds custom_allowlist parameter and uses it during benign-message filtering.
tests/unit/test_mfd_dmesg/test_base.py Adds new test cases for custom_allowlist scenarios (success/failure).
mfd_dmesg/constants.py Fixes import indentation/formatting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mfd_dmesg/base.py Outdated
Comment thread mfd_dmesg/base.py Outdated
Comment thread mfd_dmesg/base.py Outdated
Comment thread mfd_dmesg/base.py Outdated
Comment thread mfd_dmesg/base.py Outdated
Comment thread tests/unit/test_mfd_dmesg/test_base.py Outdated
Comment thread tests/unit/test_mfd_dmesg/test_base.py Outdated
Comment thread tests/unit/test_mfd_dmesg/test_base.py Outdated
Comment thread tests/unit/test_mfd_dmesg/test_base.py Outdated
Comment thread tests/unit/test_mfd_dmesg/test_base.py Outdated
@KTokarze KTokarze requested a review from Copilot May 25, 2026 12:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 7 comments.

Comment thread mfd_dmesg/base.py Outdated
return True

def verify_messages(self) -> dict:
def verify_messages(self, custom_allowlist: Optional[Iterable[str]] = None) -> dict:
Comment thread mfd_dmesg/base.py Outdated
Comment on lines +230 to +231
if custom_allowlist is None:
custom_allowlist = DMESG_WHITELIST
Comment thread mfd_dmesg/base.py Outdated
Comment on lines 240 to 241
for benign_message in custom_allowlist:
if benign_message in error:
Comment thread mfd_dmesg/base.py Outdated
return True

def verify_messages(self) -> dict:
def verify_messages(self, custom_allowlist: Optional[Iterable[str]] = None) -> dict:
Comment thread mfd_dmesg/base.py Outdated
Comment on lines 240 to 241
for benign_message in custom_allowlist:
if benign_message in error:
dmesg._connection.execute_command.return_value = ConnectionCompletedProcess(
return_code=0, args="command", stdout=output, stderr="stderr"
)
result = dmesg.verify_messages(custom_allowlist=custom_allowlist)
dmesg._connection.execute_command.return_value = ConnectionCompletedProcess(
return_code=0, args="command", stdout=output, stderr="stderr"
)
result = dmesg.verify_messages(custom_allowlist=custom_allowlist)
adrianlasota

This comment was marked as outdated.

Comment thread mfd_dmesg/base.py Outdated
return True

def verify_messages(self) -> dict:
def verify_messages(self, custom_allowlist: Optional[Iterable[str]] = None) -> dict:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use new typehints
Iterable[str] | None

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread mfd_dmesg/base.py Outdated
@KTokarze KTokarze force-pushed the add_custom_list branch 2 times, most recently from 39f0dde to 1242894 Compare May 28, 2026 12:19
@mchromin mchromin requested a review from Copilot May 28, 2026 13:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

Comment thread mfd_dmesg/base.py
Comment on lines 224 to +233
"""Verify if there are err level messages in dmesg output.

:param custom_allowlist: list of error messages to ignore in the dmesg output, if any.
By default, it uses DMESG_WHITELIST which contains known benign errors.
If this parameter is provided, it will be combined with DMESG_WHITELIST
to create the final allowlist.
:return: dictionary indicating success or failure and the error messages if present.
"""
if custom_allowlist is None:
allowlist = DMESG_WHITELIST
Comment on lines +389 to +402
def test_verify_messages_ignores_empty_lines(self, dmesg):
output = (
"[ 4.923735] SELinux: Runtime disable is not supported\n"
"\n"
"[ 321.327775] CIFS: VFS: unaligned rsize, making it a multiple of 4096 bytes"
)
custom_allowlist = ["SELinux", "unaligned rsize"]
dmesg._connection.execute_command.return_value = ConnectionCompletedProcess(
return_code=0, args="command", stdout=output, stderr="stderr"
)
result = dmesg.verify_messages(custom_allowlist=custom_allowlist)
assert result["successful"]
assert result["error"] == ""

Signed-off-by: Kacper Tokarzewski <kacper.tokarzewski@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants