Masahiro Yamada | c05e791 | 2018-01-21 18:34:57 +0900 | [diff] [blame] | 1 | #!/usr/bin/env python2 |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 2 | # |
| 3 | # Copyright (c) 2012 The Chromium OS Authors. |
| 4 | # |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | # SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 6 | # |
| 7 | |
| 8 | """See README for more information""" |
| 9 | |
| 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 | 61a6749 | 2016-09-18 16:48:34 -0600 | [diff] [blame] | 18 | sys.path.insert(1, os.path.join(our_path, '../patman')) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 19 | |
| 20 | # Our modules |
| 21 | import board |
Simon Glass | c88c895 | 2014-09-05 19:00:14 -0600 | [diff] [blame] | 22 | import bsettings |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 23 | import builder |
| 24 | import checkpatch |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 25 | import cmdline |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 26 | import control |
| 27 | import doctest |
| 28 | import gitutil |
| 29 | import patchstream |
| 30 | import terminal |
| 31 | import toolchain |
| 32 | |
Simon Glass | 2bfc697 | 2017-11-12 21:52:14 -0700 | [diff] [blame] | 33 | def RunTests(skip_net_tests): |
Simon Glass | ed098bb | 2014-09-05 19:00:13 -0600 | [diff] [blame] | 34 | import func_test |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 35 | import test |
Simon Glass | cc246fb | 2013-09-23 17:35:17 -0600 | [diff] [blame] | 36 | import doctest |
| 37 | |
| 38 | result = unittest.TestResult() |
Simon Glass | ed098bb | 2014-09-05 19:00:13 -0600 | [diff] [blame] | 39 | for module in ['toolchain', 'gitutil']: |
Simon Glass | cc246fb | 2013-09-23 17:35:17 -0600 | [diff] [blame] | 40 | suite = doctest.DocTestSuite(module) |
| 41 | suite.run(result) |
| 42 | |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 43 | sys.argv = [sys.argv[0]] |
Simon Glass | 2bfc697 | 2017-11-12 21:52:14 -0700 | [diff] [blame] | 44 | if skip_net_tests: |
| 45 | test.use_network = False |
Simon Glass | ed098bb | 2014-09-05 19:00:13 -0600 | [diff] [blame] | 46 | for module in (test.TestBuild, func_test.TestFunctional): |
| 47 | suite = unittest.TestLoader().loadTestsFromTestCase(module) |
| 48 | suite.run(result) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 49 | |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 50 | print result |
| 51 | for test, err in result.errors: |
| 52 | print err |
| 53 | for test, err in result.failures: |
| 54 | print err |
| 55 | |
| 56 | |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 57 | options, args = cmdline.ParseArgs() |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 58 | |
| 59 | # Run our meagre tests |
| 60 | if options.test: |
Simon Glass | 2bfc697 | 2017-11-12 21:52:14 -0700 | [diff] [blame] | 61 | RunTests(options.skip_net_tests) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 62 | |
| 63 | # Build selected commits for selected boards |
| 64 | else: |
Simon Glass | c88c895 | 2014-09-05 19:00:14 -0600 | [diff] [blame] | 65 | bsettings.Setup(options.config_file) |
Simon Glass | c2f9107 | 2014-08-28 09:43:39 -0600 | [diff] [blame] | 66 | ret_code = control.DoBuildman(options, args) |
| 67 | sys.exit(ret_code) |