blob: f17aa15e7c548bbe9bb34402f072867c76c768fc [file] [log] [blame]
Masahiro Yamada94b13bb2018-01-21 18:34:57 +09001#!/usr/bin/env python2
Tom Rini83d290c2018-05-06 17:58:06 -04002# SPDX-License-Identifier: GPL-2.0+
Simon Glassfc3fe1c2013-04-03 11:07:16 +00003#
4# Copyright (c) 2012 The Chromium OS Authors.
5#
Simon Glassfc3fe1c2013-04-03 11:07:16 +00006
7"""See README for more information"""
8
9import multiprocessing
Simon Glassfc3fe1c2013-04-03 11:07:16 +000010import os
11import re
12import sys
13import unittest
14
15# Bring in the patman libraries
16our_path = os.path.dirname(os.path.realpath(__file__))
Simon Glassa556eee2016-09-18 16:48:34 -060017sys.path.insert(1, os.path.join(our_path, '../patman'))
Simon Glassfc3fe1c2013-04-03 11:07:16 +000018
19# Our modules
20import board
Simon Glassfd03d632014-09-05 19:00:14 -060021import bsettings
Simon Glassfc3fe1c2013-04-03 11:07:16 +000022import builder
23import checkpatch
Simon Glassd3d5c122014-09-05 19:00:10 -060024import cmdline
Simon Glassfc3fe1c2013-04-03 11:07:16 +000025import control
26import doctest
27import gitutil
28import patchstream
29import terminal
30import toolchain
31
Simon Glasscb39a102017-11-12 21:52:14 -070032def RunTests(skip_net_tests):
Simon Glassd4144e42014-09-05 19:00:13 -060033 import func_test
Simon Glassfc3fe1c2013-04-03 11:07:16 +000034 import test
Simon Glass4281ad82013-09-23 17:35:17 -060035 import doctest
36
37 result = unittest.TestResult()
Simon Glassd4144e42014-09-05 19:00:13 -060038 for module in ['toolchain', 'gitutil']:
Simon Glass4281ad82013-09-23 17:35:17 -060039 suite = doctest.DocTestSuite(module)
40 suite.run(result)
41
Simon Glassfc3fe1c2013-04-03 11:07:16 +000042 sys.argv = [sys.argv[0]]
Simon Glasscb39a102017-11-12 21:52:14 -070043 if skip_net_tests:
44 test.use_network = False
Simon Glassd4144e42014-09-05 19:00:13 -060045 for module in (test.TestBuild, func_test.TestFunctional):
46 suite = unittest.TestLoader().loadTestsFromTestCase(module)
47 suite.run(result)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000048
Simon Glassfc3fe1c2013-04-03 11:07:16 +000049 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 Glassd3d5c122014-09-05 19:00:10 -060056options, args = cmdline.ParseArgs()
Simon Glassfc3fe1c2013-04-03 11:07:16 +000057
58# Run our meagre tests
59if options.test:
Simon Glasscb39a102017-11-12 21:52:14 -070060 RunTests(options.skip_net_tests)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000061
62# Build selected commits for selected boards
63else:
Simon Glassfd03d632014-09-05 19:00:14 -060064 bsettings.Setup(options.config_file)
Simon Glass2c3deb92014-08-28 09:43:39 -060065 ret_code = control.DoBuildman(options, args)
66 sys.exit(ret_code)