blob: 94d495c40b8566d6fbce071de52c63949e992bd7 [file] [log] [blame]
Simon Glassc78ed662019-10-31 07:42:53 -06001#!/usr/bin/env python3
Tom Rini10e47792018-05-06 17:58:06 -04002# SPDX-License-Identifier: GPL-2.0+
Simon Glassc05694f2013-04-03 11:07:16 +00003#
4# Copyright (c) 2012 The Chromium OS Authors.
5#
Simon Glassc05694f2013-04-03 11:07:16 +00006
7"""See README for more information"""
8
Simon Glassf0d9c102020-04-17 18:09:02 -06009import doctest
Simon Glassc05694f2013-04-03 11:07:16 +000010import multiprocessing
Simon Glassc05694f2013-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 Glassf0d9c102020-04-17 18:09:02 -060018sys.path.insert(1, os.path.join(our_path, '..'))
19sys.path.insert(2, os.path.join(our_path, '../patman'))
Simon Glassc05694f2013-04-03 11:07:16 +000020
21# Our modules
Simon Glassf0d9c102020-04-17 18:09:02 -060022from buildman import board
23from buildman import bsettings
24from buildman import builder
25from buildman import cmdline
26from buildman import control
27from buildman import toolchain
Simon Glassc05694f2013-04-03 11:07:16 +000028import patchstream
Simon Glassf0d9c102020-04-17 18:09:02 -060029import gitutil
Simon Glassc05694f2013-04-03 11:07:16 +000030import terminal
Simon Glassc05694f2013-04-03 11:07:16 +000031
Simon Glass2bfc6972017-11-12 21:52:14 -070032def RunTests(skip_net_tests):
Simon Glassed098bb2014-09-05 19:00:13 -060033 import func_test
Simon Glassc05694f2013-04-03 11:07:16 +000034 import test
Simon Glasscc246fb2013-09-23 17:35:17 -060035 import doctest
36
37 result = unittest.TestResult()
Simon Glassed098bb2014-09-05 19:00:13 -060038 for module in ['toolchain', 'gitutil']:
Simon Glasscc246fb2013-09-23 17:35:17 -060039 suite = doctest.DocTestSuite(module)
40 suite.run(result)
41
Simon Glassc05694f2013-04-03 11:07:16 +000042 sys.argv = [sys.argv[0]]
Simon Glass2bfc6972017-11-12 21:52:14 -070043 if skip_net_tests:
44 test.use_network = False
Simon Glassed098bb2014-09-05 19:00:13 -060045 for module in (test.TestBuild, func_test.TestFunctional):
46 suite = unittest.TestLoader().loadTestsFromTestCase(module)
47 suite.run(result)
Simon Glassc05694f2013-04-03 11:07:16 +000048
Simon Glassc78ed662019-10-31 07:42:53 -060049 print(result)
Simon Glassc05694f2013-04-03 11:07:16 +000050 for test, err in result.errors:
Simon Glassc78ed662019-10-31 07:42:53 -060051 print(err)
Simon Glassc05694f2013-04-03 11:07:16 +000052 for test, err in result.failures:
Simon Glassc78ed662019-10-31 07:42:53 -060053 print(err)
Simon Glassc05694f2013-04-03 11:07:16 +000054
55
Simon Glass04bac6b2014-09-05 19:00:10 -060056options, args = cmdline.ParseArgs()
Simon Glassc05694f2013-04-03 11:07:16 +000057
58# Run our meagre tests
59if options.test:
Simon Glass2bfc6972017-11-12 21:52:14 -070060 RunTests(options.skip_net_tests)
Simon Glassc05694f2013-04-03 11:07:16 +000061
62# Build selected commits for selected boards
63else:
Simon Glassc88c8952014-09-05 19:00:14 -060064 bsettings.Setup(options.config_file)
Simon Glassc2f91072014-08-28 09:43:39 -060065 ret_code = control.DoBuildman(options, args)
66 sys.exit(ret_code)