]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests: net: prevent Python from buffering the output
authorJakub Kicinski <kuba@kernel.org>
Wed, 16 Jul 2025 20:57:12 +0000 (13:57 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 17 Jul 2025 23:27:38 +0000 (16:27 -0700)
Make sure Python doesn't buffer the output, otherwise for some
tests we may see false positive timeouts in NIPA. NIPA thinks that
a machine has hung if the test doesn't print anything for 3min.
This is also nice to heave for running the tests manually,
especially in vng.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Link: https://patch.msgid.link/20250716205712.1787325-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/lib/py/ksft.py

index 61287c203b6e06b3b8fc87b0d78856d8f6745983..8e35ed12ed9e5667331e0b5025ea2f6afdd276af 100644 (file)
@@ -32,6 +32,7 @@ class KsftTerminate(KeyboardInterrupt):
 
 
 def ksft_pr(*objs, **kwargs):
+    kwargs["flush"] = True
     print("#", *objs, **kwargs)
 
 
@@ -139,7 +140,7 @@ def ktap_result(ok, cnt=1, case="", comment=""):
         res += "." + str(case.__name__)
     if comment:
         res += " # " + comment
-    print(res)
+    print(res, flush=True)
 
 
 def ksft_flush_defer():
@@ -227,8 +228,8 @@ def ksft_run(cases=None, globs=None, case_pfx=None, args=()):
 
     totals = {"pass": 0, "fail": 0, "skip": 0, "xfail": 0}
 
-    print("TAP version 13")
-    print("1.." + str(len(cases)))
+    print("TAP version 13", flush=True)
+    print("1.." + str(len(cases)), flush=True)
 
     global KSFT_RESULT
     cnt = 0