selftests: net: py: color the basics in the output
Subsystems (3)
Jakub Kicinski
maintainerPATCH v2 1/1 selftests: net: py: color the basics in the output
Sometimes it's hard to spot the ok / not ok lines in the output. This is especially true for the GRO tests which retries a lot so there's a wall of non-fatal output printed.
Try to color the crucial lines green / red / yellow when running in a terminal.
---
v2:
- use functools instead of open coding the caching (pylint)
v1: https://lore.kernel.org/[email protected]
--- tools/testing/selftests/net/lib/py/ksft.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
tools/testing/selftests/net/lib/py/ksft.py +20 -0
@@ -2,6 +2,7 @@ import functools import inspect +import os import signal import sys import time
@@ -31,6 +32,17 @@ KSFT_DISRUPTIVE = True pass [email protected]_cache() +def _ksft_supports_color(): + if os.environ.get("NO_COLOR") is not None: + return False + if not hasattr(sys.stdout, "isatty") or not sys.stdout.isatty(): + return False + if os.environ.get("TERM") == "dumb": + return False + return True + + def ksft_pr(*objs, **kwargs): """ Print logs to stdout.
@@ -165,6 +177,14 @@ KSFT_DISRUPTIVE = True res += "." + case_name if comment: res += " # " + comment + if _ksft_supports_color(): + if comment.startswith(("SKIP", "XFAIL")): + color = "\033[33m" + elif ok: + color = "\033[32m" + else: + color = "\033[31m" + res = color + res + "\033[0m" print(res, flush=True)
Signature · 1 line
2.53.0
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Thu, 2 Apr 2026 14:54:44 -0700 you wrote:
Sometimes it's hard to spot the ok / not ok lines in the output. This is especially true for the GRO tests which retries a lot so there's a wall of non-fatal output printed.
Try to color the crucial lines green / red / yellow when running in a terminal.
[...]
Here is the summary with links:
- [net-next,v2] selftests: net: py: color the basics in the output
https://git.kernel.org/netdev/net-next/c/3b45559f6c0a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html