Jakub Kicinski wrote:
On Thu, 18 Apr 2024 10:26:19 -0400 Willem de Bruijn wrote:
-def ksft_run(cases, args=()): +def ksft_run(cases=None, globs=None, case_pfx=None, args=()):
- cases = cases or []
- if globs and case_pfx:
for key, value in globs.items():stats_with_pfx = bool([pfx for pfx in case_pfx if key.startswith(pfx)])stats -> starts
for the reader, just spell out prefix instead of pfx?
perhaps less pythonic, but just
if key.startswith(prefix) and callable(value): cases.append(value)like this?
diff --git a/tools/testing/selftests/net/lib/py/ksft.py b/tools/testing/selftests/net/lib/py/ksft.py index fe4025dc5a16..8018bf98a9d2 100644 --- a/tools/testing/selftests/net/lib/py/ksft.py +++ b/tools/testing/selftests/net/lib/py/ksft.py @@ -86,9 +86,12 @@ KSFT_RESULT_ALL = True if globs and case_pfx: for key, value in globs.items():
stats_with_pfx = bool([pfx for pfx in case_pfx if key.startswith(pfx)])if callable(value) and stats_with_pfx:cases.append(value)
if not callable(value):continuefor prefix in case_pfx:if key.startswith(prefix):cases.append(value)break
Yes. I would not have brought this up if it wasn't for the typo as well. Python developers perhaps find this less pythonic, but I do find it easier to follow.