mirror of
https://xff.cz/git/u-boot/
synced 2025-09-28 14:01:16 +02:00
dtoc: Run tests using test_util
Use the standard function for running tests and reported results. This allows the tests to run in parallel, which is a significant speed-up on most machines (e.g. 4.5 seconds -> 1.5s on mine). Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -38,10 +38,11 @@ sys.path.insert(0, os.path.join(our_path,
|
|||||||
from dtoc import dtb_platdata
|
from dtoc import dtb_platdata
|
||||||
from patman import test_util
|
from patman import test_util
|
||||||
|
|
||||||
def run_tests(args):
|
def run_tests(processes, args):
|
||||||
"""Run all the test we have for dtoc
|
"""Run all the test we have for dtoc
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
processes: Number of processes to use to run tests (None=same as #CPUs)
|
||||||
args: List of positional args provided to dtoc. This can hold a test
|
args: List of positional args provided to dtoc. This can hold a test
|
||||||
name to execute (as in 'dtoc -t test_empty_file', for example)
|
name to execute (as in 'dtoc -t test_empty_file', for example)
|
||||||
"""
|
"""
|
||||||
@@ -50,25 +51,13 @@ def run_tests(args):
|
|||||||
result = unittest.TestResult()
|
result = unittest.TestResult()
|
||||||
sys.argv = [sys.argv[0]]
|
sys.argv = [sys.argv[0]]
|
||||||
test_name = args and args[0] or None
|
test_name = args and args[0] or None
|
||||||
for module in (test_dtoc.TestDtoc,):
|
|
||||||
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)
|
test_util.RunTestSuites(
|
||||||
for _, err in result.errors:
|
result, debug=True, verbosity=1, test_preserve_dirs=False,
|
||||||
print(err)
|
processes=processes, test_name=test_name, toolpath=[],
|
||||||
for _, err in result.failures:
|
test_class_list=[test_dtoc.TestDtoc,])
|
||||||
print(err)
|
|
||||||
if result.errors or result.failures:
|
return test_util.ReportResult('binman', test_name, result)
|
||||||
print('dtoc tests FAILED')
|
|
||||||
return 1
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def RunTestCoverage():
|
def RunTestCoverage():
|
||||||
"""Run the tests and check that we get 100% coverage"""
|
"""Run the tests and check that we get 100% coverage"""
|
||||||
@@ -103,7 +92,7 @@ parser.add_option('-T', '--test-coverage', action='store_true',
|
|||||||
|
|
||||||
# Run our meagre tests
|
# Run our meagre tests
|
||||||
if options.test:
|
if options.test:
|
||||||
ret_code = run_tests(args)
|
ret_code = run_tests(options.processes, args)
|
||||||
sys.exit(ret_code)
|
sys.exit(ret_code)
|
||||||
|
|
||||||
elif options.test_coverage:
|
elif options.test_coverage:
|
||||||
|
Reference in New Issue
Block a user