]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: net: py: explicitly forbid multiple ksft_run() calls
authorJakub Kicinski <kuba@kernel.org>
Wed, 8 Apr 2026 22:19:52 +0000 (15:19 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 10 Apr 2026 03:38:33 +0000 (20:38 -0700)
People (do people still write code or is it all AI?) seem to not
get that ksft_run() can only be called once. If we call it
multiple times KTAP parsers will likely cut off after the first
batch has finished.

Link: https://patch.msgid.link/20260408221952.819822-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/lib/py/ksft.py

index 7b8af463e35d20d5463dd47047b20aedd3468a0f..7083c99c944408e371272fe7de6fa517327716b6 100644 (file)
@@ -341,10 +341,13 @@ def ksft_run(cases=None, globs=None, case_pfx=None, args=()):
 
     totals = {"pass": 0, "fail": 0, "skip": 0, "xfail": 0}
 
+    global KSFT_RESULT
+    if KSFT_RESULT is not None:
+        raise RuntimeError("ksft_run() can't be called multiple times.")
+
     print("TAP version 13", flush=True)
     print("1.." + str(len(test_cases)), flush=True)
 
-    global KSFT_RESULT
     cnt = 0
     stop = False
     for func, args, name in test_cases: