2019-10-31 13:42:53 +00:00
|
|
|
#!/usr/bin/env python3
|
2018-05-06 21:58:06 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
2013-04-03 11:07:16 +00:00
|
|
|
#
|
|
|
|
# Copyright (c) 2012 The Chromium OS Authors.
|
|
|
|
#
|
|
|
|
|
|
|
|
"""See README for more information"""
|
|
|
|
|
2020-04-18 00:09:02 +00:00
|
|
|
import doctest
|
2013-04-03 11:07:16 +00:00
|
|
|
import multiprocessing
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
|
|
|
# Bring in the patman libraries
|
|
|
|
our_path = os.path.dirname(os.path.realpath(__file__))
|
2020-04-18 00:09:02 +00:00
|
|
|
sys.path.insert(1, os.path.join(our_path, '..'))
|
2013-04-03 11:07:16 +00:00
|
|
|
|
|
|
|
# Our modules
|
2020-04-18 00:09:02 +00:00
|
|
|
from buildman import board
|
|
|
|
from buildman import bsettings
|
|
|
|
from buildman import builder
|
|
|
|
from buildman import cmdline
|
|
|
|
from buildman import control
|
|
|
|
from buildman import toolchain
|
2020-04-18 00:09:04 +00:00
|
|
|
from patman import patchstream
|
|
|
|
from patman import gitutil
|
2023-02-24 01:18:04 +00:00
|
|
|
from u_boot_pylib import terminal
|
|
|
|
from u_boot_pylib import test_util
|
2013-04-03 11:07:16 +00:00
|
|
|
|
2023-07-19 23:48:10 +00:00
|
|
|
def RunTests(skip_net_tests, debug, verbose, args):
|
2023-07-19 23:48:09 +00:00
|
|
|
"""Run the buildman tests
|
|
|
|
|
|
|
|
Args:
|
|
|
|
skip_net_tests (bool): True to skip tests which need the network
|
2023-07-19 23:48:10 +00:00
|
|
|
debug (bool): True to run in debugging mode (full traceback)
|
2023-07-19 23:48:09 +00:00
|
|
|
verbosity (int): Verbosity level to use (0-4)
|
|
|
|
args (list of str): List of tests to run, empty to run all
|
|
|
|
"""
|
2022-02-11 20:23:19 +00:00
|
|
|
from buildman import func_test
|
|
|
|
from buildman import test
|
2013-09-23 23:35:17 +00:00
|
|
|
import doctest
|
|
|
|
|
2022-01-22 12:07:30 +00:00
|
|
|
test_name = args and args[0] or None
|
2017-11-13 04:52:14 +00:00
|
|
|
if skip_net_tests:
|
|
|
|
test.use_network = False
|
2013-04-03 11:07:16 +00:00
|
|
|
|
2022-01-22 12:07:30 +00:00
|
|
|
# Run the entry tests first ,since these need to be the first to import the
|
|
|
|
# 'entry' module.
|
2022-04-02 17:06:06 +00:00
|
|
|
result = test_util.run_test_suites(
|
2023-07-19 23:48:10 +00:00
|
|
|
'buildman', debug, verbose, False, None, test_name, [],
|
2022-01-22 12:07:30 +00:00
|
|
|
[test.TestBuild, func_test.TestFunctional,
|
|
|
|
'buildman.toolchain', 'patman.gitutil'])
|
2013-04-03 11:07:16 +00:00
|
|
|
|
2022-04-02 17:06:06 +00:00
|
|
|
return (0 if result.wasSuccessful() else 1)
|
2013-04-03 11:07:16 +00:00
|
|
|
|
2023-02-24 01:18:09 +00:00
|
|
|
def run_buildman():
|
|
|
|
options, args = cmdline.ParseArgs()
|
2013-04-03 11:07:16 +00:00
|
|
|
|
2023-02-24 01:18:09 +00:00
|
|
|
if not options.debug:
|
|
|
|
sys.tracebacklimit = 0
|
2022-01-22 12:07:29 +00:00
|
|
|
|
2023-02-24 01:18:09 +00:00
|
|
|
# Run our meagre tests
|
|
|
|
if cmdline.HAS_TESTS and options.test:
|
2023-07-19 23:48:11 +00:00
|
|
|
return RunTests(options.skip_net_tests, options.debug, options.verbose,
|
|
|
|
args)
|
2013-04-03 11:07:16 +00:00
|
|
|
|
2023-02-24 01:18:09 +00:00
|
|
|
# Build selected commits for selected boards
|
|
|
|
else:
|
|
|
|
bsettings.Setup(options.config_file)
|
|
|
|
ret_code = control.DoBuildman(options, args)
|
2023-07-19 23:48:11 +00:00
|
|
|
return ret_code
|
|
|
|
return 0
|
2023-02-24 01:18:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-07-19 23:48:11 +00:00
|
|
|
sys.exit(run_buildman())
|