blob: 473117ccff7f4ef427f932c10065444654a2a108 [file] [log] [blame]
Masahiro Yamada94b13bb2018-01-21 18:34:57 +09001#!/usr/bin/env python2
Simon Glassfc3fe1c2013-04-03 11:07:16 +00002#
3# Copyright (c) 2012 The Chromium OS Authors.
4#
Wolfgang Denk1a459662013-07-08 09:37:19 +02005# SPDX-License-Identifier: GPL-2.0+
Simon Glassfc3fe1c2013-04-03 11:07:16 +00006#
7
8"""See README for more information"""
9
10import multiprocessing
Simon Glassfc3fe1c2013-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 Glassa556eee2016-09-18 16:48:34 -060018sys.path.insert(1, os.path.join(our_path, '../patman'))
Simon Glassfc3fe1c2013-04-03 11:07:16 +000019
20# Our modules
21import board
Simon Glassfd03d632014-09-05 19:00:14 -060022import bsettings
Simon Glassfc3fe1c2013-04-03 11:07:16 +000023import builder
24import checkpatch
Simon Glassd3d5c122014-09-05 19:00:10 -060025import cmdline
Simon Glassfc3fe1c2013-04-03 11:07:16 +000026import control
27import doctest
28import gitutil
29import patchstream
30import terminal
31import toolchain
32
Simon Glasscb39a102017-11-12 21:52:14 -070033def RunTests(skip_net_tests):
Simon Glassd4144e42014-09-05 19:00:13 -060034 import func_test
Simon Glassfc3fe1c2013-04-03 11:07:16 +000035 import test
Simon Glass4281ad82013-09-23 17:35:17 -060036 import doctest
37
38 result = unittest.TestResult()
Simon Glassd4144e42014-09-05 19:00:13 -060039 for module in ['toolchain', 'gitutil']:
Simon Glass4281ad82013-09-23 17:35:17 -060040 suite = doctest.DocTestSuite(module)
41 suite.run(result)
42
Simon Glassfc3fe1c2013-04-03 11:07:16 +000043 sys.argv = [sys.argv[0]]
Simon Glasscb39a102017-11-12 21:52:14 -070044 if skip_net_tests:
45 test.use_network = False
Simon Glassd4144e42014-09-05 19:00:13 -060046 for module in (test.TestBuild, func_test.TestFunctional):
47 suite = unittest.TestLoader().loadTestsFromTestCase(module)
48 suite.run(result)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000049
Simon Glassfc3fe1c2013-04-03 11:07:16 +000050 print result
51 for test, err in result.errors:
52 print err
53 for test, err in result.failures:
54 print err
55
56
Simon Glassd3d5c122014-09-05 19:00:10 -060057options, args = cmdline.ParseArgs()
Simon Glassfc3fe1c2013-04-03 11:07:16 +000058
59# Run our meagre tests
60if options.test:
Simon Glasscb39a102017-11-12 21:52:14 -070061 RunTests(options.skip_net_tests)
Simon Glassfc3fe1c2013-04-03 11:07:16 +000062
63# Build selected commits for selected boards
64else:
Simon Glassfd03d632014-09-05 19:00:14 -060065 bsettings.Setup(options.config_file)
Simon Glass2c3deb92014-08-28 09:43:39 -060066 ret_code = control.DoBuildman(options, args)
67 sys.exit(ret_code)