Simon Glass | c78ed66 | 2019-10-31 07:42:53 -0600 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 2 | # SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 3 | # |
| 4 | # Copyright (c) 2012 The Chromium OS Authors. |
| 5 | # |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 6 | |
| 7 | """See README for more information""" |
| 8 | |
Simon Glass | f0d9c10 | 2020-04-17 18:09:02 -0600 | [diff] [blame] | 9 | import doctest |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 10 | import multiprocessing |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 11 | import os |
| 12 | import re |
| 13 | import sys |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 14 | |
| 15 | # Bring in the patman libraries |
| 16 | our_path = os.path.dirname(os.path.realpath(__file__)) |
Simon Glass | f0d9c10 | 2020-04-17 18:09:02 -0600 | [diff] [blame] | 17 | sys.path.insert(1, os.path.join(our_path, '..')) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 18 | |
| 19 | # Our modules |
Simon Glass | f0d9c10 | 2020-04-17 18:09:02 -0600 | [diff] [blame] | 20 | from buildman import board |
| 21 | from buildman import bsettings |
| 22 | from buildman import builder |
| 23 | from buildman import cmdline |
| 24 | from buildman import control |
| 25 | from buildman import toolchain |
Simon Glass | a997ea5 | 2020-04-17 18:09:04 -0600 | [diff] [blame] | 26 | from patman import patchstream |
| 27 | from patman import gitutil |
Simon Glass | 131444f | 2023-02-23 18:18:04 -0700 | [diff] [blame] | 28 | from u_boot_pylib import terminal |
| 29 | from u_boot_pylib import test_util |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 30 | |
Simon Glass | 6f484e4 | 2022-01-22 05:07:30 -0700 | [diff] [blame] | 31 | def RunTests(skip_net_tests, verboose, args): |
Simon Glass | e36fe01 | 2022-02-11 13:23:19 -0700 | [diff] [blame] | 32 | from buildman import func_test |
| 33 | from buildman import test |
Simon Glass | cc246fb | 2013-09-23 17:35:17 -0600 | [diff] [blame] | 34 | import doctest |
| 35 | |
Simon Glass | 6f484e4 | 2022-01-22 05:07:30 -0700 | [diff] [blame] | 36 | test_name = args and args[0] or None |
Simon Glass | 2bfc697 | 2017-11-12 21:52:14 -0700 | [diff] [blame] | 37 | if skip_net_tests: |
| 38 | test.use_network = False |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 39 | |
Simon Glass | 6f484e4 | 2022-01-22 05:07:30 -0700 | [diff] [blame] | 40 | # Run the entry tests first ,since these need to be the first to import the |
| 41 | # 'entry' module. |
Alper Nebi Yasak | ca1c588 | 2022-04-02 20:06:06 +0300 | [diff] [blame] | 42 | result = test_util.run_test_suites( |
| 43 | 'buildman', False, verboose, False, None, test_name, [], |
Simon Glass | 6f484e4 | 2022-01-22 05:07:30 -0700 | [diff] [blame] | 44 | [test.TestBuild, func_test.TestFunctional, |
| 45 | 'buildman.toolchain', 'patman.gitutil']) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 46 | |
Alper Nebi Yasak | ca1c588 | 2022-04-02 20:06:06 +0300 | [diff] [blame] | 47 | return (0 if result.wasSuccessful() else 1) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 48 | |
Simon Glass | 62043e3 | 2023-02-23 18:18:09 -0700 | [diff] [blame] | 49 | def run_buildman(): |
| 50 | options, args = cmdline.ParseArgs() |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 51 | |
Simon Glass | 62043e3 | 2023-02-23 18:18:09 -0700 | [diff] [blame] | 52 | if not options.debug: |
| 53 | sys.tracebacklimit = 0 |
Simon Glass | 838ddf3 | 2022-01-22 05:07:29 -0700 | [diff] [blame] | 54 | |
Simon Glass | 62043e3 | 2023-02-23 18:18:09 -0700 | [diff] [blame] | 55 | # Run our meagre tests |
| 56 | if cmdline.HAS_TESTS and options.test: |
| 57 | RunTests(options.skip_net_tests, options.verbose, args) |
| 58 | |
| 59 | # Build selected commits for selected boards |
| 60 | else: |
| 61 | bsettings.Setup(options.config_file) |
| 62 | ret_code = control.DoBuildman(options, args) |
| 63 | sys.exit(ret_code) |
| 64 | |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 65 | |
Simon Glass | 62043e3 | 2023-02-23 18:18:09 -0700 | [diff] [blame] | 66 | if __name__ == "__main__": |
| 67 | run_buildman() |