Simon Glass | c05aa03 | 2019-10-31 07:42:53 -0600 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
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 | |
Simon Glass | 0ede00f | 2020-04-17 18:09:02 -0600 | [diff] [blame] | 9 | import doctest |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 10 | import multiprocessing |
Simon Glass | fc3fe1c | 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 | 0ede00f | 2020-04-17 18:09:02 -0600 | [diff] [blame] | 18 | sys.path.insert(1, os.path.join(our_path, '..')) |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 19 | |
| 20 | # Our modules |
Simon Glass | 0ede00f | 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 | bf77667 | 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 | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 30 | |
Simon Glass | cb39a10 | 2017-11-12 21:52:14 -0700 | [diff] [blame] | 31 | def RunTests(skip_net_tests): |
Simon Glass | d4144e4 | 2014-09-05 19:00:13 -0600 | [diff] [blame] | 32 | import func_test |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 33 | import test |
Simon Glass | 4281ad8 | 2013-09-23 17:35:17 -0600 | [diff] [blame] | 34 | import doctest |
| 35 | |
| 36 | result = unittest.TestResult() |
Simon Glass | b4fa949 | 2020-04-17 18:09:05 -0600 | [diff] [blame] | 37 | for module in ['buildman.toolchain', 'patman.gitutil']: |
Simon Glass | 4281ad8 | 2013-09-23 17:35:17 -0600 | [diff] [blame] | 38 | suite = doctest.DocTestSuite(module) |
| 39 | suite.run(result) |
| 40 | |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 41 | sys.argv = [sys.argv[0]] |
Simon Glass | cb39a10 | 2017-11-12 21:52:14 -0700 | [diff] [blame] | 42 | if skip_net_tests: |
| 43 | test.use_network = False |
Simon Glass | d4144e4 | 2014-09-05 19:00:13 -0600 | [diff] [blame] | 44 | for module in (test.TestBuild, func_test.TestFunctional): |
| 45 | suite = unittest.TestLoader().loadTestsFromTestCase(module) |
| 46 | suite.run(result) |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 47 | |
Simon Glass | c05aa03 | 2019-10-31 07:42:53 -0600 | [diff] [blame] | 48 | print(result) |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 49 | for test, err in result.errors: |
Simon Glass | c05aa03 | 2019-10-31 07:42:53 -0600 | [diff] [blame] | 50 | print(err) |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 51 | for test, err in result.failures: |
Simon Glass | c05aa03 | 2019-10-31 07:42:53 -0600 | [diff] [blame] | 52 | print(err) |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 53 | |
| 54 | |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 55 | options, args = cmdline.ParseArgs() |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 56 | |
| 57 | # Run our meagre tests |
| 58 | if options.test: |
Simon Glass | cb39a10 | 2017-11-12 21:52:14 -0700 | [diff] [blame] | 59 | RunTests(options.skip_net_tests) |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 60 | |
| 61 | # Build selected commits for selected boards |
| 62 | else: |
Simon Glass | fd03d63 | 2014-09-05 19:00:14 -0600 | [diff] [blame] | 63 | bsettings.Setup(options.config_file) |
Simon Glass | 2c3deb9 | 2014-08-28 09:43:39 -0600 | [diff] [blame] | 64 | ret_code = control.DoBuildman(options, args) |
| 65 | sys.exit(ret_code) |