summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-07-30 20:57:08 -0600
committerSimon Glass <sjg@chromium.org>2022-08-09 11:55:41 -0600
commita8ad9aacd34cc1fd1dc7c0c8703c9467d76676b9 (patch)
treece8fa06f8821b0be1180a5d24b277539e101bb4e
parentad744222f59e765ef9d6ee7efa2ee670a4ebd06d (diff)
dtoc: Move main program into its own function
Use a function for the main program so everything there doesn't look like a global variable to pylint. Signed-off-by: Simon Glass <sjg@chromium.org>
-rwxr-xr-xtools/dtoc/test_fdt.py44
1 files changed, 24 insertions, 20 deletions
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index afa0bb58850..e10fb528e81 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -799,23 +799,27 @@ def run_tests(args, processes):
return (0 if result.wasSuccessful() else 1)
-if __name__ != '__main__':
- sys.exit(1)
-
-parser = OptionParser()
-parser.add_option('-B', '--build-dir', type='string', default='b',
- help='Directory containing the build output')
-parser.add_option('-P', '--processes', type=int,
- help='set number of processes to use for running tests')
-parser.add_option('-t', '--test', action='store_true', dest='test',
- default=False, help='run tests')
-parser.add_option('-T', '--test-coverage', action='store_true',
- default=False, help='run tests and check for 100% coverage')
-(options, args) = parser.parse_args()
-
-# Run our meagre tests
-if options.test:
- ret_code = run_tests(args, options.processes)
- sys.exit(ret_code)
-elif options.test_coverage:
- run_test_coverage(options.build_dir)
+def main():
+ """Main program for this tool"""
+ parser = OptionParser()
+ parser.add_option('-B', '--build-dir', type='string', default='b',
+ help='Directory containing the build output')
+ parser.add_option('-P', '--processes', type=int,
+ help='set number of processes to use for running tests')
+ parser.add_option('-t', '--test', action='store_true', dest='test',
+ default=False, help='run tests')
+ parser.add_option('-T', '--test-coverage', action='store_true',
+ default=False, help='run tests and check for 100% coverage')
+ (options, args) = parser.parse_args()
+
+ # Run our meagre tests
+ if options.test:
+ ret_code = run_tests(args, options.processes)
+ return ret_code
+ if options.test_coverage:
+ run_test_coverage(options.build_dir)
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())
+sys.exit(1)