2 # SPDX-License-Identifier: GPL-2.0+
4 # Copyright (c) 2012 The Chromium OS Authors.
7 """See README for more information"""
10 from importlib.resources import files
13 import importlib_resources
17 # Bring in the patman libraries
18 # pylint: disable=C0413
19 our_path = os.path.dirname(os.path.realpath(__file__))
20 sys.path.insert(1, os.path.join(our_path, '..'))
23 from buildman import bsettings
24 from buildman import cmdline
25 from buildman import control
26 from u_boot_pylib import test_util
27 from u_boot_pylib import tools
29 def run_tests(skip_net_tests, debug, verbose, args):
30 """Run the buildman tests
33 skip_net_tests (bool): True to skip tests which need the network
34 debug (bool): True to run in debugging mode (full traceback)
35 verbosity (int): Verbosity level to use (0-4)
36 args (list of str): List of tests to run, empty to run all
38 # These imports are here since tests are not available when buildman is
39 # installed as a Python module
40 # pylint: disable=C0415
41 from buildman import func_test
42 from buildman import test
44 test_name = args.terms and args.terms[0] or None
46 test.use_network = False
48 # Run the entry tests first ,since these need to be the first to import the
50 result = test_util.run_test_suites(
51 'buildman', debug, verbose, False, None, test_name, [],
52 [test.TestBuild, func_test.TestFunctional,
53 'buildman.toolchain', 'patman.gitutil'])
55 return (0 if result.wasSuccessful() else 1)
60 This is the main program. It collects arguments and runs either the tests or
63 args = cmdline.parse_args()
66 sys.tracebacklimit = 0
68 # Run our meagre tests
69 if cmdline.HAS_TESTS and args.test:
70 return run_tests(args.skip_net_tests, args.debug, args.verbose, args)
73 tools.print_full_help(str(files('buildman').joinpath('README.rst')))
75 # Build selected commits for selected boards
77 bsettings.setup(args.config_file)
78 ret_code = control.do_buildman(args)
82 if __name__ == "__main__":
83 sys.exit(run_buildman())