vpp/test/discover_tests.py
Saima Yunus c7f93b321d tests: move "venv" to "build-root" directory from "test" directory
Type: refactor

- refactored VPP test code to remove "ignore_path" variable
  from "discover_tests" function and "run_test" code
- configured VPP test makefile, config file, and 'run.sh' shell script
  to move "venv" directory from "test" dir to "build-root" dir

Signed-off-by: Saima Yunus <yunus.saima.234@gmail.com>
Change-Id: Id2beecbb99f24ce13ed118a1869c5adbef247e50
2022-08-16 20:27:37 +00:00

42 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python3
import sys
import os
import unittest
import importlib
import argparse
def discover_tests(directory, callback):
do_insert = True
for _f in os.listdir(directory):
f = "%s/%s" % (directory, _f)
if os.path.isdir(f):
discover_tests(f, callback)
continue
if not os.path.isfile(f):
continue
if do_insert:
sys.path.insert(0, directory)
do_insert = False
if not _f.startswith("test_") or not _f.endswith(".py"):
continue
name = "".join(f.split("/")[-1].split(".")[:-1])
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"):
continue
for method in dir(cls):
if not callable(getattr(cls, method)):
continue
if method.startswith("test_"):
callback(_f, cls, method)
def print_callback(file_name, cls, method):
print("%s.%s.%s" % (file_name, cls.__name__, method))