tests: Add support for getting corefile patterns on FreeBSD
[vpp.git] / test / discover_tests.py
index 99016e2..dbf23ef 100755 (executable)
@@ -1,10 +1,9 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import sys
 import os
 import unittest
 import importlib
-import argparse
 
 
 def discover_tests(directory, callback):
@@ -22,15 +21,17 @@ def discover_tests(directory, callback):
         if not _f.startswith("test_") or not _f.endswith(".py"):
             continue
         name = "".join(f.split("/")[-1].split(".")[:-1])
-        if name in sys.modules:
-            raise Exception("Duplicate test module `%s' found!" % name)
         module = importlib.import_module(name)
         for name, cls in module.__dict__.items():
             if not isinstance(cls, type):
                 continue
             if not issubclass(cls, unittest.TestCase):
                 continue
-            if name == "VppTestCase" or name.startswith("Template"):
+            if (
+                name == "VppTestCase"
+                or name == "VppAsfTestCase"
+                or name.startswith("Template")
+            ):
                 continue
             for method in dir(cls):
                 if not callable(getattr(cls, method)):
@@ -41,17 +42,3 @@ def discover_tests(directory, callback):
 
 def print_callback(file_name, cls, method):
     print("%s.%s.%s" % (file_name, cls.__name__, method))
-
-
-if __name__ == '__main__':
-    parser = argparse.ArgumentParser(description="Discover VPP unit tests")
-    parser.add_argument("-d", "--dir", action='append', type=str,
-                        help="directory containing test files "
-                             "(may be specified multiple times)")
-    args = parser.parse_args()
-    if args.dir is None:
-        args.dir = "."
-
-    suite = unittest.TestSuite()
-    for d in args.dir:
-        discover_tests(d, print_callback)