blob: 5e1f68d8235876e0432a81acd5b87b10a1b01c8f [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
Simon Glassfc3fe1c2013-04-03 11:07:16 +000014
15# Bring in the patman libraries
16our_path = os.path.dirname(os.path.realpath(__file__))
Simon Glass0ede00f2020-04-17 18:09:02 -060017sys.path.insert(1, os.path.join(our_path, '..'))
Simon Glassfc3fe1c2013-04-03 11:07:16 +000018
19# Our modules
Simon Glass0ede00f2020-04-17 18:09:02 -060020from buildman import board
21from buildman import bsettings
22from buildman import builder
23from buildman import cmdline
24from buildman import control
25from buildman import toolchain
Simon Glassbf776672020-04-17 18:09:04 -060026from patman import patchstream
27from patman import gitutil
Simon Glass4583c002023-02-23 18:18:04 -070028from u_boot_pylib import terminal
29from u_boot_pylib import test_util
Simon Glassfc3fe1c2013-04-03 11:07:16 +000030
Simon Glassd10dc402022-01-22 05:07:30 -070031def RunTests(skip_net_tests, verboose, args):
Simon Glassac053352022-02-11 13:23:19 -070032 from buildman import func_test
33 from buildman import test
Simon Glass4281ad82013-09-23 17:35:17 -060034 import doctest
35
Simon Glassd10dc402022-01-22 05:07:30 -070036 test_name = args and args[0] or None
Simon Glasscb39a102017-11-12 21:52:14 -070037 if skip_net_tests:
38 test.use_network = False
Simon Glassfc3fe1c2013-04-03 11:07:16 +000039
Simon Glassd10dc402022-01-22 05:07:30 -070040 # Run the entry tests first ,since these need to be the first to import the
41 # 'entry' module.
Alper Nebi Yasakd8318fe2022-04-02 20:06:06 +030042 result = test_util.run_test_suites(
43 'buildman', False, verboose, False, None, test_name, [],
Simon Glassd10dc402022-01-22 05:07:30 -070044 [test.TestBuild, func_test.TestFunctional,
45 'buildman.toolchain', 'patman.gitutil'])
Simon Glassfc3fe1c2013-04-03 11:07:16 +000046
Alper Nebi Yasakd8318fe2022-04-02 20:06:06 +030047 return (0 if result.wasSuccessful() else 1)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000048
Simon Glass793aa172023-02-23 18:18:09 -070049def run_buildman():
50 options, args = cmdline.ParseArgs()
Simon Glassfc3fe1c2013-04-03 11:07:16 +000051
Simon Glass793aa172023-02-23 18:18:09 -070052 if not options.debug:
53 sys.tracebacklimit = 0
Simon Glass433fa542022-01-22 05:07:29 -070054
Simon Glass793aa172023-02-23 18:18:09 -070055 # Run our meagre tests
56 if cmdline.HAS_TESTS and options.test:
57 RunTests(options.skip_net_tests, options.verbose, args)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000058
Simon Glass793aa172023-02-23 18:18:09 -070059 # Build selected commits for selected boards
60 else:
61 bsettings.Setup(options.config_file)
62 ret_code = control.DoBuildman(options, args)
63 sys.exit(ret_code)
64
65
66if __name__ == "__main__":
67 run_buildman()