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

Fix kernel tainted test #3818

Merged
merged 1 commit into from
Jan 21, 2025
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
2 changes: 1 addition & 1 deletion tests/smoke_test/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ def test_kernel_not_tainted(shell):
"""Check if the kernel is not tainted - do it at the end of the
test suite to increase the chance of catching issues."""
output = shell.run_check("cat /proc/sys/kernel/tainted")
assert output == "0\n", f"Kernel tainted: {output}"
assert "\n".join(output) == "0", f"Kernel tainted: {output}"
Copy link
Member

Choose a reason for hiding this comment

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

Isn't that fixing it on both sides? 🤔

How about:

Suggested change
assert "\n".join(output) == "0", f"Kernel tainted: {output}"
assert output.strip() == "0", f"Kernel tainted: {output}"

Copy link
Member Author

Choose a reason for hiding this comment

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

That won't work, the thing is the return type is a list of strings. This time I actually checked the test doesn't fail 🙈

Copy link
Member

Choose a reason for hiding this comment

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

Hm, I see, and "\n".join(output) won't add a newline if there is only one element. Yeah make sense.

2 changes: 1 addition & 1 deletion tests/supervisor_test/test_supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,4 @@ def test_kernel_not_tainted(shell):
"""Check if the kernel is not tainted - do it at the end of the
test suite to increase the chance of catching issues."""
output = shell.run_check("cat /proc/sys/kernel/tainted")
assert output == "0\n", f"Kernel tainted: {output}"
assert "\n".join(output) == "0", f"Kernel tainted: {output}"