blob: 30a8690f9352ce9620f05dc386768ec1bc11fe48 [file] [log] [blame]
Simon Glassc05aa032019-10-31 07:42:53 -06001#!/usr/bin/env python3
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
Simon Glassc05aa032019-10-31 07:42:53 -06009from __future__ import print_function
10
Simon Glassfc3fe1c2013-04-03 11:07:16 +000011import multiprocessing
Simon Glassfc3fe1c2013-04-03 11:07:16 +000012import os
13import re
14import sys
15import unittest
16
17# Bring in the patman libraries
18our_path = os.path.dirname(os.path.realpath(__file__))
Simon Glassa556eee2016-09-18 16:48:34 -060019sys.path.insert(1, os.path.join(our_path, '../patman'))
Simon Glassfc3fe1c2013-04-03 11:07:16 +000020
21# Our modules
22import board
Simon Glassfd03d632014-09-05 19:00:14 -060023import bsettings
Simon Glassfc3fe1c2013-04-03 11:07:16 +000024import builder
25import checkpatch
Simon Glassd3d5c122014-09-05 19:00:10 -060026import cmdline
Simon Glassfc3fe1c2013-04-03 11:07:16 +000027import control
28import doctest
29import gitutil
30import patchstream
31import terminal
32import toolchain
33
Simon Glasscb39a102017-11-12 21:52:14 -070034def RunTests(skip_net_tests):
Simon Glassd4144e42014-09-05 19:00:13 -060035 import func_test
Simon Glassfc3fe1c2013-04-03 11:07:16 +000036 import test
Simon Glass4281ad82013-09-23 17:35:17 -060037 import doctest
38
39 result = unittest.TestResult()
Simon Glassd4144e42014-09-05 19:00:13 -060040 for module in ['toolchain', 'gitutil']:
Simon Glass4281ad82013-09-23 17:35:17 -060041 suite = doctest.DocTestSuite(module)
42 suite.run(result)
43
Simon Glassfc3fe1c2013-04-03 11:07:16 +000044 sys.argv = [sys.argv[0]]
Simon Glasscb39a102017-11-12 21:52:14 -070045 if skip_net_tests:
46 test.use_network = False
Simon Glassd4144e42014-09-05 19:00:13 -060047 for module in (test.TestBuild, func_test.TestFunctional):
48 suite = unittest.TestLoader().loadTestsFromTestCase(module)
49 suite.run(result)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000050
Simon Glassc05aa032019-10-31 07:42:53 -060051 print(result)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000052 for test, err in result.errors:
Simon Glassc05aa032019-10-31 07:42:53 -060053 print(err)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000054 for test, err in result.failures:
Simon Glassc05aa032019-10-31 07:42:53 -060055 print(err)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000056
57
Simon Glassd3d5c122014-09-05 19:00:10 -060058options, args = cmdline.ParseArgs()
Simon Glassfc3fe1c2013-04-03 11:07:16 +000059
60# Run our meagre tests
61if options.test:
Simon Glasscb39a102017-11-12 21:52:14 -070062 RunTests(options.skip_net_tests)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000063
64# Build selected commits for selected boards
65else:
Simon Glassfd03d632014-09-05 19:00:14 -060066 bsettings.Setup(options.config_file)
Simon Glass2c3deb92014-08-28 09:43:39 -060067 ret_code = control.DoBuildman(options, args)
68 sys.exit(ret_code)