aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests
diff options
context:
space:
mode:
authorJoerg Hofrichter <joerg.hofrichter@ni.com>2020-01-22 11:54:22 +0100
committerAaron Rossetto <aaron.rossetto@ni.com>2021-01-08 08:56:43 -0600
commit9f3ec1c5ab3cc4b5ced2048a8666dd66b743cc99 (patch)
tree6da91d56e82381a1df7351725426dcdf6f07b56a /host/tests
parent868de221e44315b8e6b11ccea12f5ce4aac66e29 (diff)
downloaduhd-9f3ec1c5ab3cc4b5ced2048a8666dd66b743cc99.tar.gz
uhd-9f3ec1c5ab3cc4b5ced2048a8666dd66b743cc99.tar.bz2
uhd-9f3ec1c5ab3cc4b5ced2048a8666dd66b743cc99.zip
devtest: optionally generate XML report when running devtests
If the unittests are invoked with an extra argument -x, an XML report is generated. This depends on the python module unittest-xml-reporting (aka. xmlrunner).
Diffstat (limited to 'host/tests')
-rwxr-xr-xhost/tests/devtest/run_testsuite.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/host/tests/devtest/run_testsuite.py b/host/tests/devtest/run_testsuite.py
index feb6d4b70..a5ece8ac6 100755
--- a/host/tests/devtest/run_testsuite.py
+++ b/host/tests/devtest/run_testsuite.py
@@ -15,6 +15,7 @@ import subprocess
import argparse
import logging
from usrp_probe import get_usrp_list
+import importlib.util
def setup_parser():
""" Set up argparser """
@@ -27,6 +28,8 @@ def setup_parser():
parser.add_argument('--build-dir', help='Build dir (where examples/ and utils/ are)')
parser.add_argument('--build-type', default='Release')
parser.add_argument('--python-interp', default=sys.executable)
+ parser.add_argument('--xml', '-x', dest='xml', action='store_true', default=False,
+ help='Generate XML report (using Python module unittest-xml-reporting)')
return parser
def setup_env(args):
@@ -113,9 +116,18 @@ def main():
env['_UHD_TEST_PRINT_LEVEL'] = str(logging.WARNING)
env['_UHD_BUILD_DIR'] = str(args.build_dir)
env['_UHD_DEVTEST_SRC_DIR'] = str(args.src_dir)
+ if args.xml:
+ if not importlib.util.find_spec("xmlrunner"):
+ print("Error: XML report is requested but Python unittest-xml-reporting (aka. xmlrunner)\n" \
+ " is not installed. Typically you can install it with:\n" \
+ " pip3 install unittest-xml-reporting")
+ sys.exit(1)
+ test_module = "xmlrunner"
+ else:
+ test_module = "unittest"
proc = subprocess.Popen(
[
- args.python_interp, "-m", "unittest", "discover", "-v",
+ args.python_interp, "-m", test_module, "discover", "-v",
"-s", args.src_dir,
"-p", devtest_pattern,
],