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