mirror of
https://github.com/smaeul/u-boot.git
synced 2025-10-14 04:46:01 +01:00
test_fdt: Convert to use argparse
Drop the deprecated OptionParser. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
a8ad9aacd3
commit
7640b16660
@ -4,7 +4,7 @@
|
|||||||
# Written by Simon Glass <sjg@chromium.org>
|
# Written by Simon Glass <sjg@chromium.org>
|
||||||
#
|
#
|
||||||
|
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
@ -778,12 +778,11 @@ def run_test_coverage(build_dir):
|
|||||||
['tools/patman/*.py', '*test_fdt.py'], build_dir)
|
['tools/patman/*.py', '*test_fdt.py'], build_dir)
|
||||||
|
|
||||||
|
|
||||||
def run_tests(args, processes):
|
def run_tests(names, processes):
|
||||||
"""Run all the test we have for the fdt model
|
"""Run all the test we have for the fdt model
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
args (list or str): List of positional args provided. This can hold a
|
names (list of str): List of test names provided. Only the first is used
|
||||||
test name to execute (as in 'test_fdt -t testFdt', for example)
|
|
||||||
processes (int): Number of processes to use (None means as many as there
|
processes (int): Number of processes to use (None means as many as there
|
||||||
are CPUs on the system. This must be set to 1 when running under
|
are CPUs on the system. This must be set to 1 when running under
|
||||||
the python3-coverage tool
|
the python3-coverage tool
|
||||||
@ -791,7 +790,7 @@ def run_tests(args, processes):
|
|||||||
Returns:
|
Returns:
|
||||||
int: Return code, 0 on success
|
int: Return code, 0 on success
|
||||||
"""
|
"""
|
||||||
test_name = args[0] if args else None
|
test_name = names[0] if names else None
|
||||||
result = test_util.run_test_suites(
|
result = test_util.run_test_suites(
|
||||||
'test_fdt', False, False, False, processes, test_name, None,
|
'test_fdt', False, False, False, processes, test_name, None,
|
||||||
[TestFdt, TestNode, TestProp, TestFdtUtil])
|
[TestFdt, TestNode, TestProp, TestFdtUtil])
|
||||||
@ -801,23 +800,25 @@ def run_tests(args, processes):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main program for this tool"""
|
"""Main program for this tool"""
|
||||||
parser = OptionParser()
|
parser = ArgumentParser()
|
||||||
parser.add_option('-B', '--build-dir', type='string', default='b',
|
parser.add_argument('-B', '--build-dir', type=str, default='b',
|
||||||
help='Directory containing the build output')
|
help='Directory containing the build output')
|
||||||
parser.add_option('-P', '--processes', type=int,
|
parser.add_argument('-P', '--processes', type=int,
|
||||||
help='set number of processes to use for running tests')
|
help='set number of processes to use for running tests')
|
||||||
parser.add_option('-t', '--test', action='store_true', dest='test',
|
parser.add_argument('-t', '--test', action='store_true', dest='test',
|
||||||
default=False, help='run tests')
|
default=False, help='run tests')
|
||||||
parser.add_option('-T', '--test-coverage', action='store_true',
|
parser.add_argument('-T', '--test-coverage', action='store_true',
|
||||||
default=False, help='run tests and check for 100% coverage')
|
default=False,
|
||||||
(options, args) = parser.parse_args()
|
help='run tests and check for 100% coverage')
|
||||||
|
parser.add_argument('name', nargs='*')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Run our meagre tests
|
# Run our meagre tests
|
||||||
if options.test:
|
if args.test:
|
||||||
ret_code = run_tests(args, options.processes)
|
ret_code = run_tests(args.name, args.processes)
|
||||||
return ret_code
|
return ret_code
|
||||||
if options.test_coverage:
|
if args.test_coverage:
|
||||||
run_test_coverage(options.build_dir)
|
run_test_coverage(args.build_dir)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user