blob: 5cbdce7cf34d03a854cbc9794dadb942d0d40a17 [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 Glasseadbfa62023-07-19 17:48:10 -060031def RunTests(skip_net_tests, debug, verbose, args):
Simon Glass2ef22f82023-07-19 17:48:09 -060032 """Run the buildman tests
33
34 Args:
35 skip_net_tests (bool): True to skip tests which need the network
Simon Glasseadbfa62023-07-19 17:48:10 -060036 debug (bool): True to run in debugging mode (full traceback)
Simon Glass2ef22f82023-07-19 17:48:09 -060037 verbosity (int): Verbosity level to use (0-4)
38 args (list of str): List of tests to run, empty to run all
39 """
Simon Glassac053352022-02-11 13:23:19 -070040 from buildman import func_test
41 from buildman import test
Simon Glass4281ad82013-09-23 17:35:17 -060042 import doctest
43
Simon Glassd10dc402022-01-22 05:07:30 -070044 test_name = args and args[0] or None
Simon Glasscb39a102017-11-12 21:52:14 -070045 if skip_net_tests:
46 test.use_network = False
Simon Glassfc3fe1c2013-04-03 11:07:16 +000047
Simon Glassd10dc402022-01-22 05:07:30 -070048 # Run the entry tests first ,since these need to be the first to import the
49 # 'entry' module.
Alper Nebi Yasakd8318fe2022-04-02 20:06:06 +030050 result = test_util.run_test_suites(
Simon Glasseadbfa62023-07-19 17:48:10 -060051 'buildman', debug, verbose, False, None, test_name, [],
Simon Glassd10dc402022-01-22 05:07:30 -070052 [test.TestBuild, func_test.TestFunctional,
53 'buildman.toolchain', 'patman.gitutil'])
Simon Glassfc3fe1c2013-04-03 11:07:16 +000054
Alper Nebi Yasakd8318fe2022-04-02 20:06:06 +030055 return (0 if result.wasSuccessful() else 1)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000056
Simon Glass793aa172023-02-23 18:18:09 -070057def run_buildman():
58 options, args = cmdline.ParseArgs()
Simon Glassfc3fe1c2013-04-03 11:07:16 +000059
Simon Glass793aa172023-02-23 18:18:09 -070060 if not options.debug:
61 sys.tracebacklimit = 0
Simon Glass433fa542022-01-22 05:07:29 -070062
Simon Glass793aa172023-02-23 18:18:09 -070063 # Run our meagre tests
64 if cmdline.HAS_TESTS and options.test:
Simon Glasseadbfa62023-07-19 17:48:10 -060065 RunTests(options.skip_net_tests, options.debug, options.verbose, args)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000066
Simon Glass793aa172023-02-23 18:18:09 -070067 # Build selected commits for selected boards
68 else:
69 bsettings.Setup(options.config_file)
70 ret_code = control.DoBuildman(options, args)
71 sys.exit(ret_code)
72
73
74if __name__ == "__main__":
75 run_buildman()