summaryrefslogtreecommitdiff
path: root/tools/dtoc/test_fdt.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-03-19 03:01:50 +0300
committerSimon Glass <sjg@chromium.org>2022-06-28 05:09:51 +0300
commit42ae363ddd99c38ab26434b9d1c8b68610844e79 (patch)
tree7c8d1f5a654e229f4a544ece3e1f8fc190dd129a /tools/dtoc/test_fdt.py
parent68ff6d365539fd0bb13a219bb4c5bb885ee1f30f (diff)
downloadu-boot-42ae363ddd99c38ab26434b9d1c8b68610844e79.tar.xz
dtoc: Update fdt tests to use test_util
Use the common functions to run tests and report results. Ensure that the result code indicates success or failure. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Diffstat (limited to 'tools/dtoc/test_fdt.py')
-rwxr-xr-xtools/dtoc/test_fdt.py27
1 files changed, 10 insertions, 17 deletions
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index 914ed6aed5..3859af8d03 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -780,25 +780,17 @@ def RunTests(args):
Args:
args: List of positional args provided to fdt. This can hold a test
name to execute (as in 'fdt -t testFdt', for example)
+
+ Returns:
+ Return code, 0 on success
"""
result = unittest.TestResult()
- sys.argv = [sys.argv[0]]
test_name = args and args[0] or None
- for module in (TestFdt, TestNode, TestProp, TestFdtUtil):
- if test_name:
- try:
- suite = unittest.TestLoader().loadTestsFromName(test_name, module)
- except AttributeError:
- continue
- else:
- suite = unittest.TestLoader().loadTestsFromTestCase(module)
- suite.run(result)
-
- print(result)
- for _, err in result.errors:
- print(err)
- for _, err in result.failures:
- print(err)
+ test_util.run_test_suites(
+ result, False, False, False, None, test_name, None,
+ [TestFdt, TestNode, TestProp, TestFdtUtil])
+
+ return test_util.report_result('fdt', test_name, result)
if __name__ != '__main__':
sys.exit(1)
@@ -816,6 +808,7 @@ parser.add_option('-T', '--test-coverage', action='store_true',
# Run our meagre tests
if options.test:
- RunTests(args)
+ ret_code = RunTests(args)
+ sys.exit(ret_code)
elif options.test_coverage:
RunTestCoverage()