]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests: tc-testing: fix list_categories() crash on list type
authorNaveen Anandhan <mr.navi8680@gmail.com>
Sat, 28 Feb 2026 07:47:35 +0000 (13:17 +0530)
committerDavid S. Miller <davem@davemloft.net>
Wed, 4 Mar 2026 05:42:57 +0000 (05:42 +0000)
list_categories() builds a set directly from the 'category'
field of each test case. Since 'category' is a list,
set(map(...)) attempts to insert lists into a set, which
raises:

  TypeError: unhashable type: 'list'

Flatten category lists and collect unique category names
using set.update() instead.

Signed-off-by: Naveen Anandhan <mr.navi8680@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/tc-testing/tdc_helper.py

index 0440d252c4c5f168cfef81dc4835cd85ae76e17c..bc447ca573337bb6dd452a6d71a0f1d6be6dff33 100644 (file)
@@ -38,10 +38,14 @@ def list_test_cases(testlist):
 
 
 def list_categories(testlist):
-    """ Show all categories that are present in a test case file. """
-    categories = set(map(lambda x: x['category'], testlist))
+    """Show all unique categories present in the test cases."""
+    categories = set()
+    for t in testlist:
+        if 'category' in t:
+            categories.update(t['category'])
+
     print("Available categories:")
-    print(", ".join(str(s) for s in categories))
+    print(", ".join(sorted(categories)))
     print("")