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