blob: 30a8690f9352ce9620f05dc386768ec1bc11fe48 [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 Glassc78ed662019-10-31 07:42:53 -06009from __future__ import print_function
10
Simon Glassc05694f2013-04-03 11:07:16 +000011import multiprocessing
Simon Glassc05694f2013-04-03 11:07:16 +000012import os
13import re
14import sys
15import unittest
16
17# Bring in the patman libraries
18our_path = os.path.dirname(os.path.realpath(__file__))
Simon Glass61a67492016-09-18 16:48:34 -060019sys.path.insert(1, os.path.join(our_path, '../patman'))
Simon Glassc05694f2013-04-03 11:07:16 +000020
21# Our modules
22import board
Simon Glassc88c8952014-09-05 19:00:14 -060023import bsettings
Simon Glassc05694f2013-04-03 11:07:16 +000024import builder
25import checkpatch
Simon Glass04bac6b2014-09-05 19:00:10 -060026import cmdline
Simon Glassc05694f2013-04-03 11:07:16 +000027import control
28import doctest
29import gitutil
30import patchstream
31import terminal
32import toolchain
33
Simon Glass2bfc6972017-11-12 21:52:14 -070034def RunTests(skip_net_tests):
Simon Glassed098bb2014-09-05 19:00:13 -060035 import func_test
Simon Glassc05694f2013-04-03 11:07:16 +000036 import test
Simon Glasscc246fb2013-09-23 17:35:17 -060037 import doctest
38
39 result = unittest.TestResult()
Simon Glassed098bb2014-09-05 19:00:13 -060040 for module in ['toolchain', 'gitutil']:
Simon Glasscc246fb2013-09-23 17:35:17 -060041 suite = doctest.DocTestSuite(module)
42 suite.run(result)
43
Simon Glassc05694f2013-04-03 11:07:16 +000044 sys.argv = [sys.argv[0]]
Simon Glass2bfc6972017-11-12 21:52:14 -070045 if skip_net_tests:
46 test.use_network = False
Simon Glassed098bb2014-09-05 19:00:13 -060047 for module in (test.TestBuild, func_test.TestFunctional):
48 suite = unittest.TestLoader().loadTestsFromTestCase(module)
49 suite.run(result)
Simon Glassc05694f2013-04-03 11:07:16 +000050
Simon Glassc78ed662019-10-31 07:42:53 -060051 print(result)
Simon Glassc05694f2013-04-03 11:07:16 +000052 for test, err in result.errors:
Simon Glassc78ed662019-10-31 07:42:53 -060053 print(err)
Simon Glassc05694f2013-04-03 11:07:16 +000054 for test, err in result.failures:
Simon Glassc78ed662019-10-31 07:42:53 -060055 print(err)
Simon Glassc05694f2013-04-03 11:07:16 +000056
57
Simon Glass04bac6b2014-09-05 19:00:10 -060058options, args = cmdline.ParseArgs()
Simon Glassc05694f2013-04-03 11:07:16 +000059
60# Run our meagre tests
61if options.test:
Simon Glass2bfc6972017-11-12 21:52:14 -070062 RunTests(options.skip_net_tests)
Simon Glassc05694f2013-04-03 11:07:16 +000063
64# Build selected commits for selected boards
65else:
Simon Glassc88c8952014-09-05 19:00:14 -060066 bsettings.Setup(options.config_file)
Simon Glassc2f91072014-08-28 09:43:39 -060067 ret_code = control.DoBuildman(options, args)
68 sys.exit(ret_code)