Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | #!/usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0+ # # Copyright (c) 2012 The Chromium OS Authors. # """See README for more information""" import importlib.resources import os import sys # Bring in the patman libraries # pylint: disable=C0413 our_path = os.path.dirname(os.path.realpath(__file__)) sys.path.insert(1, os.path.join(our_path, '..')) # Our modules from buildman import bsettings from buildman import cmdline from buildman import control from u_boot_pylib import test_util from u_boot_pylib import tools from u_boot_pylib import tout def run_tests(skip_net_tests, debug, verbose, args): """Run the buildman tests Args: skip_net_tests (bool): True to skip tests which need the network debug (bool): True to run in debugging mode (full traceback) verbose (int): Verbosity level to use (0-4) args (list of str): List of tests to run, empty to run all """ # These imports are here since tests are not available when buildman is # installed as a Python module # pylint: disable=C0415 from buildman import func_test from buildman import test from buildman import test_boards from buildman import test_bsettings from buildman import test_builder from buildman import test_cfgutil from buildman import test_machine from buildman import test_worker from buildman import test_boss test_name = args.terms and args.terms[0] or None if skip_net_tests: test.use_network = False # Run the entry tests first ,since these need to be the first to import the # 'entry' module. result = test_util.run_test_suites( 'buildman', debug, verbose, False, False, args.threads, test_name, [], [test.TestBuildOutput, test.TestBuildBoards, test.TestBuild, test.TestBuildMisc, test.TestBuilderFuncs, test_cfgutil.TestAdjustCfg, test_cfgutil.TestProcessConfig, func_test.TestFunctional, test_boards.TestBoards, test_bsettings.TestBsettings, test_builder.TestPrintFuncSizeDetail, test_builder.TestPrepareThread, test_builder.TestPrepareWorkingSpace, test_builder.TestShowNotBuilt, test_builder.TestPrepareOutputSpace, test_builder.TestCheckOutputForLoop, test_builder.TestMake, test_builder.TestPrintBuildSummary, test_machine, test_worker, test_boss, 'buildman.toolchain']) return (0 if result.wasSuccessful() else 1) def run_test_coverage(): """Run the tests and check that we get 100% coverage""" test_util.run_test_coverage( 'tools/buildman/buildman', None, ['tools/patman/*.py', 'tools/u_boot_pylib/*', '*test_fdt.py', 'tools/buildman/kconfiglib.py', 'tools/buildman/*test*.py', 'tools/buildman/main.py', 'tools/qconfig.py'], '/tmp/b', single_thread='-T1', allow_failures=['tools/buildman/builder.py', 'tools/buildman/builderthread.py', 'tools/buildman/cfgutil.py', 'tools/buildman/control.py', 'tools/buildman/resulthandler.py', 'tools/buildman/toolchain.py']) def run_buildman(): """Run bulidman This is the main program. It collects arguments and runs either the tests or the control module. """ args = cmdline.parse_args() if not args.debug: sys.tracebacklimit = 0 # Run our meagre tests if cmdline.HAS_TESTS and args.test: return run_tests(args.skip_net_tests, args.debug, args.verbose, args) if cmdline.HAS_TESTS and args.coverage: run_test_coverage() return 0 if args.full_help: if hasattr(importlib.resources, 'files'): dirpath = importlib.resources.files('buildman') tools.print_full_help(str(dirpath.joinpath('README.rst'))) else: with importlib.resources.path('buildman', 'README.rst') as readme: tools.print_full_help(str(readme)) return 0 # Build selected commits for selected boards try: tout.init(tout.INFO if args.verbose else tout.WARNING) bsettings.setup(args.config_file) ret_code = control.do_buildman(args) finally: tout.uninit() return ret_code if __name__ == "__main__": sys.exit(run_buildman()) |