* [PATCH net-next] selftests: net: py: color the basics in the output
@ 2026-04-01 18:33 Jakub Kicinski
2026-04-01 21:29 ` Stanislav Fomichev
2026-04-02 0:00 ` Joe Damato
0 siblings, 2 replies; 5+ messages in thread
From: Jakub Kicinski @ 2026-04-01 18:33 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, Jakub Kicinski,
shuah, petrm, willemb, linux-kselftest
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.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
This is a bit of RFC, I'm not super convinced this is worth
carrying in the tree? Please Ack/Review I'll apply if we get
3 supporting tags.
---
CC: shuah@kernel.org
CC: petrm@nvidia.com
CC: willemb@google.com
CC: linux-kselftest@vger.kernel.org
---
tools/testing/selftests/net/lib/py/ksft.py | 29 ++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/tools/testing/selftests/net/lib/py/ksft.py b/tools/testing/selftests/net/lib/py/ksft.py
index 28a7a994526d..2a6e9113ef5b 100644
--- a/tools/testing/selftests/net/lib/py/ksft.py
+++ b/tools/testing/selftests/net/lib/py/ksft.py
@@ -4,6 +4,7 @@ import argparse
import fnmatch
import functools
import inspect
+import os
import signal
import sys
import time
@@ -17,6 +18,26 @@ KSFT_RESULT_ALL = True
KSFT_DISRUPTIVE = True
+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
+
+
+_KSFT_COLOR = None
+
+
+def _ksft_color():
+ global _KSFT_COLOR
+ if _KSFT_COLOR is None:
+ _KSFT_COLOR = _ksft_supports_color()
+ return _KSFT_COLOR
+
+
class KsftFailEx(Exception):
pass
@@ -167,6 +188,14 @@ KSFT_DISRUPTIVE = True
res += "." + case_name
if comment:
res += " # " + comment
+ if _ksft_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)
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH net-next] selftests: net: py: color the basics in the output
2026-04-01 18:33 [PATCH net-next] selftests: net: py: color the basics in the output Jakub Kicinski
@ 2026-04-01 21:29 ` Stanislav Fomichev
2026-04-01 23:58 ` Jakub Kicinski
2026-04-02 0:03 ` Willem de Bruijn
2026-04-02 0:00 ` Joe Damato
1 sibling, 2 replies; 5+ messages in thread
From: Stanislav Fomichev @ 2026-04-01 21:29 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, shuah,
petrm, willemb, linux-kselftest
On 04/01, Jakub Kicinski 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.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> This is a bit of RFC, I'm not super convinced this is worth
> carrying in the tree? Please Ack/Review I'll apply if we get
> 3 supporting tags.
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
(not sure why you think this might be controversial)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] selftests: net: py: color the basics in the output
2026-04-01 21:29 ` Stanislav Fomichev
@ 2026-04-01 23:58 ` Jakub Kicinski
2026-04-02 0:03 ` Willem de Bruijn
1 sibling, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2026-04-01 23:58 UTC (permalink / raw)
To: Stanislav Fomichev
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, shuah,
petrm, willemb, linux-kselftest
On Wed, 1 Apr 2026 14:29:10 -0700 Stanislav Fomichev wrote:
> (not sure why you think this might be controversial)
I'd like the "libraries" to be minimal, so any increase in LoC has to
strongly justify itself. Whenever I work on something in ksft I tend
to produce a bunch of "improvements" of this sort but usually lose
confidence and don't send them out. The coloring thing has been
annoying me for a while but mostly in NIPA context (on the web).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] selftests: net: py: color the basics in the output
2026-04-01 21:29 ` Stanislav Fomichev
2026-04-01 23:58 ` Jakub Kicinski
@ 2026-04-02 0:03 ` Willem de Bruijn
1 sibling, 0 replies; 5+ messages in thread
From: Willem de Bruijn @ 2026-04-02 0:03 UTC (permalink / raw)
To: Stanislav Fomichev, Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, shuah,
petrm, willemb, linux-kselftest
Stanislav Fomichev wrote:
> On 04/01, Jakub Kicinski 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.
> >
> > Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> > ---
> > This is a bit of RFC, I'm not super convinced this is worth
> > carrying in the tree? Please Ack/Review I'll apply if we get
> > 3 supporting tags.
>
> Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Minor aside: I don't know exactly how to exhaustively test whether a
terminal supports colors. If unsure, an inverse approach to err on the
side of caution may be safer. But overall +1 on the intent.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] selftests: net: py: color the basics in the output
2026-04-01 18:33 [PATCH net-next] selftests: net: py: color the basics in the output Jakub Kicinski
2026-04-01 21:29 ` Stanislav Fomichev
@ 2026-04-02 0:00 ` Joe Damato
1 sibling, 0 replies; 5+ messages in thread
From: Joe Damato @ 2026-04-02 0:00 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, shuah,
petrm, willemb, linux-kselftest
On Wed, Apr 01, 2026 at 11:33:09AM -0700, Jakub Kicinski 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.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> This is a bit of RFC, I'm not super convinced this is worth
> carrying in the tree? Please Ack/Review I'll apply if we get
> 3 supporting tags.
> ---
> CC: shuah@kernel.org
> CC: petrm@nvidia.com
> CC: willemb@google.com
> CC: linux-kselftest@vger.kernel.org
> ---
> tools/testing/selftests/net/lib/py/ksft.py | 29 ++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
Colorized output is nice.
Acked-by: Joe Damato <joe@dama.to>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-02 0:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-01 18:33 [PATCH net-next] selftests: net: py: color the basics in the output Jakub Kicinski
2026-04-01 21:29 ` Stanislav Fomichev
2026-04-01 23:58 ` Jakub Kicinski
2026-04-02 0:03 ` Willem de Bruijn
2026-04-02 0:00 ` Joe Damato
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox