From: Mauro Carvalho Chehab Date: Tue, 17 Mar 2026 18:09:29 +0000 (+0100) Subject: unittests: add a runner to execute all unittests X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bd167a2122600ac787913275ad1eb5dd38698d9f;p=thirdparty%2Fkernel%2Flinux.git unittests: add a runner to execute all unittests We'll soon have multiple unit tests, add a runner that will discover all of them and execute all tests. It was opted to discover only files that starts with "test", as this way unittest discover won't try adding libraries or other stuff that might not contain unittest classes. Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Jonathan Corbet Message-ID: <2d9dd14f03d3d6394346fdaceeb3167d54d1dd0c.1773770483.git.mchehab+huawei@kernel.org> --- diff --git a/tools/unittests/run.py b/tools/unittests/run.py new file mode 100755 index 0000000000000..8c19036d43a1d --- /dev/null +++ b/tools/unittests/run.py @@ -0,0 +1,17 @@ +#!/bin/env python3 +import os +import unittest +import sys + +TOOLS_DIR=os.path.join(os.path.dirname(os.path.realpath(__file__)), "..") +sys.path.insert(0, TOOLS_DIR) + +from lib.python.unittest_helper import TestUnits + +if __name__ == "__main__": + loader = unittest.TestLoader() + + suite = loader.discover(start_dir=os.path.join(TOOLS_DIR, "unittests"), + pattern="test*.py") + + TestUnits().run("", suite=suite)