blob: c6af311a69b8b46026fcbf6811a5008979145052 [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 Glassd10dc402022-01-22 05:07:30 -070030from patman import test_util
Simon Glassfc3fe1c2013-04-03 11:07:16 +000031
Simon Glassd10dc402022-01-22 05:07:30 -070032def RunTests(skip_net_tests, verboose, args):
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 Glassd10dc402022-01-22 05:07:30 -070038 test_name = args and args[0] or None
Simon Glasscb39a102017-11-12 21:52:14 -070039 if skip_net_tests:
40 test.use_network = False
Simon Glassfc3fe1c2013-04-03 11:07:16 +000041
Simon Glassd10dc402022-01-22 05:07:30 -070042 # Run the entry tests first ,since these need to be the first to import the
43 # 'entry' module.
44 test_util.RunTestSuites(
45 result, False, verboose, False, None, test_name, [],
46 [test.TestBuild, func_test.TestFunctional,
47 'buildman.toolchain', 'patman.gitutil'])
Simon Glassfc3fe1c2013-04-03 11:07:16 +000048
Simon Glassd10dc402022-01-22 05:07:30 -070049 return test_util.ReportResult('buildman', test_name, result)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000050
Simon Glassd3d5c122014-09-05 19:00:10 -060051options, args = cmdline.ParseArgs()
Simon Glassfc3fe1c2013-04-03 11:07:16 +000052
Simon Glass433fa542022-01-22 05:07:29 -070053if not options.debug:
54 sys.tracebacklimit = 0
55
Simon Glassfc3fe1c2013-04-03 11:07:16 +000056# Run our meagre tests
57if options.test:
Simon Glassd10dc402022-01-22 05:07:30 -070058 RunTests(options.skip_net_tests, options.verbose, args)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000059
60# Build selected commits for selected boards
61else:
Simon Glassfd03d632014-09-05 19:00:14 -060062 bsettings.Setup(options.config_file)
Simon Glass2c3deb92014-08-28 09:43:39 -060063 ret_code = control.DoBuildman(options, args)
64 sys.exit(ret_code)