]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Verify test case function documentation
authorJouni Malinen <j@w1.fi>
Sun, 17 Mar 2024 13:20:26 +0000 (15:20 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 17 Mar 2024 13:20:26 +0000 (15:20 +0200)
Check that each test case function includes a title in __doc__ and also
verify that the same test case is not added multiple times from
different files.

Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/run-tests.py

index 1fdd923c4f54e95607111d4729cac1644b81b293..3c0502002103e813e1d46edbc5a7b0d9c571f03f 100755 (executable)
@@ -231,6 +231,7 @@ def get_test_description(t):
 def main():
     tests = []
     test_modules = []
+    names = set()
     files = os.listdir(scriptsdir)
     for t in files:
         m = re.match(r'(test_.*)\.py$', t)
@@ -240,8 +241,15 @@ def main():
             test_modules.append(mod.__name__.replace('test_', '', 1))
             for key, val in mod.__dict__.items():
                 if key.startswith("test_"):
+                    if val.__doc__ is None:
+                        print(f"Test case {val.__name__} misses __doc__")
                     tests.append(val)
-    test_names = list(set([t.__name__.replace('test_', '', 1) for t in tests]))
+
+                    name = val.__name__.replace('test_', '', 1)
+                    if name in names:
+                        print(f"Test case {name} defined multiple times")
+                    names.add(name)
+    test_names = list(names)
 
     run = None