blob: f17aa15e7c548bbe9bb34402f072867c76c768fc [file] [log] [blame]
Masahiro Yamadac05e7912018-01-21 18:34:57 +09001#!/usr/bin/env python2
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
9import multiprocessing
Simon Glassc05694f2013-04-03 11:07:16 +000010import os
11import re
12import sys
13import unittest
14
15# Bring in the patman libraries
16our_path = os.path.dirname(os.path.realpath(__file__))
Simon Glass61a67492016-09-18 16:48:34 -060017sys.path.insert(1, os.path.join(our_path, '../patman'))
Simon Glassc05694f2013-04-03 11:07:16 +000018
19# Our modules
20import board
Simon Glassc88c8952014-09-05 19:00:14 -060021import bsettings
Simon Glassc05694f2013-04-03 11:07:16 +000022import builder
23import checkpatch
Simon Glass04bac6b2014-09-05 19:00:10 -060024import cmdline
Simon Glassc05694f2013-04-03 11:07:16 +000025import control
26import doctest
27import gitutil
28import patchstream
29import terminal
30import toolchain
31
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 Glassc05694f2013-04-03 11:07:16 +000049 print result
50 for test, err in result.errors:
51 print err
52 for test, err in result.failures:
53 print err
54
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)