blob: 2b714739a20546647333e9e1addeecafdc2bcc70 [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 Glass0ede00f2020-04-17 18:09:02 -06009import doctest
Simon Glassfc3fe1c2013-04-03 11:07:16 +000010import multiprocessing
Simon Glassfc3fe1c2013-04-03 11:07:16 +000011import os
12import re
13import sys
14import unittest
15
16# Bring in the patman libraries
17our_path = os.path.dirname(os.path.realpath(__file__))
Simon Glass0ede00f2020-04-17 18:09:02 -060018sys.path.insert(1, os.path.join(our_path, '..'))
Simon Glassfc3fe1c2013-04-03 11:07:16 +000019
20# Our modules
Simon Glass0ede00f2020-04-17 18:09:02 -060021from buildman import board
22from buildman import bsettings
23from buildman import builder
24from buildman import cmdline
25from buildman import control
26from buildman import toolchain
Simon Glassbf776672020-04-17 18:09:04 -060027from patman import patchstream
28from patman import gitutil
29from patman import terminal
Simon Glassfc3fe1c2013-04-03 11:07:16 +000030
Simon Glasscb39a102017-11-12 21:52:14 -070031def RunTests(skip_net_tests):
Simon Glassd4144e42014-09-05 19:00:13 -060032 import func_test
Simon Glassfc3fe1c2013-04-03 11:07:16 +000033 import test
Simon Glass4281ad82013-09-23 17:35:17 -060034 import doctest
35
36 result = unittest.TestResult()
Simon Glassb4fa9492020-04-17 18:09:05 -060037 for module in ['buildman.toolchain', 'patman.gitutil']:
Simon Glass4281ad82013-09-23 17:35:17 -060038 suite = doctest.DocTestSuite(module)
39 suite.run(result)
40
Simon Glassfc3fe1c2013-04-03 11:07:16 +000041 sys.argv = [sys.argv[0]]
Simon Glasscb39a102017-11-12 21:52:14 -070042 if skip_net_tests:
43 test.use_network = False
Simon Glassd4144e42014-09-05 19:00:13 -060044 for module in (test.TestBuild, func_test.TestFunctional):
45 suite = unittest.TestLoader().loadTestsFromTestCase(module)
46 suite.run(result)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000047
Simon Glassc05aa032019-10-31 07:42:53 -060048 print(result)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000049 for test, err in result.errors:
Simon Glassc05aa032019-10-31 07:42:53 -060050 print(err)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000051 for test, err in result.failures:
Simon Glassc05aa032019-10-31 07:42:53 -060052 print(err)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000053
54
Simon Glassd3d5c122014-09-05 19:00:10 -060055options, args = cmdline.ParseArgs()
Simon Glassfc3fe1c2013-04-03 11:07:16 +000056
57# Run our meagre tests
58if options.test:
Simon Glasscb39a102017-11-12 21:52:14 -070059 RunTests(options.skip_net_tests)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000060
61# Build selected commits for selected boards
62else:
Simon Glassfd03d632014-09-05 19:00:14 -060063 bsettings.Setup(options.config_file)
Simon Glass2c3deb92014-08-28 09:43:39 -060064 ret_code = control.DoBuildman(options, args)
65 sys.exit(ret_code)