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 | c78ed66 | 2019-10-31 07:42:53 -0600 | [diff] [blame] | 9 | from __future__ import print_function |
| 10 | |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 11 | import multiprocessing |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 12 | import os |
| 13 | import re |
| 14 | import sys |
| 15 | import unittest |
| 16 | |
| 17 | # Bring in the patman libraries |
| 18 | our_path = os.path.dirname(os.path.realpath(__file__)) |
Simon Glass | 61a6749 | 2016-09-18 16:48:34 -0600 | [diff] [blame] | 19 | sys.path.insert(1, os.path.join(our_path, '../patman')) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 20 | |
| 21 | # Our modules |
| 22 | import board |
Simon Glass | c88c895 | 2014-09-05 19:00:14 -0600 | [diff] [blame] | 23 | import bsettings |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 24 | import builder |
| 25 | import checkpatch |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 26 | import cmdline |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 27 | import control |
| 28 | import doctest |
| 29 | import gitutil |
| 30 | import patchstream |
| 31 | import terminal |
| 32 | import toolchain |
| 33 | |
Simon Glass | 2bfc697 | 2017-11-12 21:52:14 -0700 | [diff] [blame] | 34 | def RunTests(skip_net_tests): |
Simon Glass | ed098bb | 2014-09-05 19:00:13 -0600 | [diff] [blame] | 35 | import func_test |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 36 | import test |
Simon Glass | cc246fb | 2013-09-23 17:35:17 -0600 | [diff] [blame] | 37 | import doctest |
| 38 | |
| 39 | result = unittest.TestResult() |
Simon Glass | ed098bb | 2014-09-05 19:00:13 -0600 | [diff] [blame] | 40 | for module in ['toolchain', 'gitutil']: |
Simon Glass | cc246fb | 2013-09-23 17:35:17 -0600 | [diff] [blame] | 41 | suite = doctest.DocTestSuite(module) |
| 42 | suite.run(result) |
| 43 | |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 44 | sys.argv = [sys.argv[0]] |
Simon Glass | 2bfc697 | 2017-11-12 21:52:14 -0700 | [diff] [blame] | 45 | if skip_net_tests: |
| 46 | test.use_network = False |
Simon Glass | ed098bb | 2014-09-05 19:00:13 -0600 | [diff] [blame] | 47 | for module in (test.TestBuild, func_test.TestFunctional): |
| 48 | suite = unittest.TestLoader().loadTestsFromTestCase(module) |
| 49 | suite.run(result) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 50 | |
Simon Glass | c78ed66 | 2019-10-31 07:42:53 -0600 | [diff] [blame] | 51 | print(result) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 52 | for test, err in result.errors: |
Simon Glass | c78ed66 | 2019-10-31 07:42:53 -0600 | [diff] [blame] | 53 | print(err) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 54 | for test, err in result.failures: |
Simon Glass | c78ed66 | 2019-10-31 07:42:53 -0600 | [diff] [blame] | 55 | print(err) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 56 | |
| 57 | |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 58 | options, args = cmdline.ParseArgs() |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 59 | |
| 60 | # Run our meagre tests |
| 61 | if options.test: |
Simon Glass | 2bfc697 | 2017-11-12 21:52:14 -0700 | [diff] [blame] | 62 | RunTests(options.skip_net_tests) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 63 | |
| 64 | # Build selected commits for selected boards |
| 65 | else: |
Simon Glass | c88c895 | 2014-09-05 19:00:14 -0600 | [diff] [blame] | 66 | bsettings.Setup(options.config_file) |
Simon Glass | c2f9107 | 2014-08-28 09:43:39 -0600 | [diff] [blame] | 67 | ret_code = control.DoBuildman(options, args) |
| 68 | sys.exit(ret_code) |