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 |
| 14 | import unittest |
| 15 | |
| 16 | # Bring in the patman libraries |
| 17 | our_path = os.path.dirname(os.path.realpath(__file__)) |
Simon Glass | f0d9c10 | 2020-04-17 18:09:02 -0600 | [diff] [blame] | 18 | sys.path.insert(1, os.path.join(our_path, '..')) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 19 | |
| 20 | # Our modules |
Simon Glass | f0d9c10 | 2020-04-17 18:09:02 -0600 | [diff] [blame] | 21 | from buildman import board |
| 22 | from buildman import bsettings |
| 23 | from buildman import builder |
| 24 | from buildman import cmdline |
| 25 | from buildman import control |
| 26 | from buildman import toolchain |
Simon Glass | a997ea5 | 2020-04-17 18:09:04 -0600 | [diff] [blame] | 27 | from patman import patchstream |
| 28 | from patman import gitutil |
| 29 | from patman import terminal |
Simon Glass | 6f484e4 | 2022-01-22 05:07:30 -0700 | [diff] [blame] | 30 | from patman import test_util |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 31 | |
Simon Glass | 6f484e4 | 2022-01-22 05:07:30 -0700 | [diff] [blame] | 32 | def RunTests(skip_net_tests, verboose, args): |
Simon Glass | e36fe01 | 2022-02-11 13:23:19 -0700 | [diff] [blame] | 33 | from buildman import func_test |
| 34 | from buildman import test |
Simon Glass | cc246fb | 2013-09-23 17:35:17 -0600 | [diff] [blame] | 35 | import doctest |
| 36 | |
| 37 | result = unittest.TestResult() |
Simon Glass | 6f484e4 | 2022-01-22 05:07:30 -0700 | [diff] [blame] | 38 | test_name = args and args[0] or None |
Simon Glass | 2bfc697 | 2017-11-12 21:52:14 -0700 | [diff] [blame] | 39 | if skip_net_tests: |
| 40 | test.use_network = False |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 41 | |
Simon Glass | 6f484e4 | 2022-01-22 05:07:30 -0700 | [diff] [blame] | 42 | # Run the entry tests first ,since these need to be the first to import the |
| 43 | # 'entry' module. |
Simon Glass | 1b53d90 | 2022-01-29 14:14:14 -0700 | [diff] [blame] | 44 | test_util.run_test_suites( |
Simon Glass | 6f484e4 | 2022-01-22 05:07:30 -0700 | [diff] [blame] | 45 | result, False, verboose, False, None, test_name, [], |
| 46 | [test.TestBuild, func_test.TestFunctional, |
| 47 | 'buildman.toolchain', 'patman.gitutil']) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 48 | |
Simon Glass | 1b53d90 | 2022-01-29 14:14:14 -0700 | [diff] [blame] | 49 | return test_util.report_result('buildman', test_name, result) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 50 | |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 51 | options, args = cmdline.ParseArgs() |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 52 | |
Simon Glass | 838ddf3 | 2022-01-22 05:07:29 -0700 | [diff] [blame] | 53 | if not options.debug: |
| 54 | sys.tracebacklimit = 0 |
| 55 | |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 56 | # Run our meagre tests |
| 57 | if options.test: |
Simon Glass | 6f484e4 | 2022-01-22 05:07:30 -0700 | [diff] [blame] | 58 | RunTests(options.skip_net_tests, options.verbose, args) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 59 | |
| 60 | # Build selected commits for selected boards |
| 61 | else: |
Simon Glass | c88c895 | 2014-09-05 19:00:14 -0600 | [diff] [blame] | 62 | bsettings.Setup(options.config_file) |
Simon Glass | c2f9107 | 2014-08-28 09:43:39 -0600 | [diff] [blame] | 63 | ret_code = control.DoBuildman(options, args) |
| 64 | sys.exit(ret_code) |