30a8690f9352ce9620f05dc386768ec1bc11fe48
[oweals/u-boot.git] / tools / buildman / buildman.py
1 #!/usr/bin/env python3
2 # SPDX-License-Identifier: GPL-2.0+
3 #
4 # Copyright (c) 2012 The Chromium OS Authors.
5 #
6
7 """See README for more information"""
8
9 from __future__ import print_function
10
11 import multiprocessing
12 import os
13 import re
14 import sys
15 import unittest
16
17 # Bring in the patman libraries
18 our_path = os.path.dirname(os.path.realpath(__file__))
19 sys.path.insert(1, os.path.join(our_path, '../patman'))
20
21 # Our modules
22 import board
23 import bsettings
24 import builder
25 import checkpatch
26 import cmdline
27 import control
28 import doctest
29 import gitutil
30 import patchstream
31 import terminal
32 import toolchain
33
34 def RunTests(skip_net_tests):
35     import func_test
36     import test
37     import doctest
38
39     result = unittest.TestResult()
40     for module in ['toolchain', 'gitutil']:
41         suite = doctest.DocTestSuite(module)
42         suite.run(result)
43
44     sys.argv = [sys.argv[0]]
45     if skip_net_tests:
46         test.use_network = False
47     for module in (test.TestBuild, func_test.TestFunctional):
48         suite = unittest.TestLoader().loadTestsFromTestCase(module)
49         suite.run(result)
50
51     print(result)
52     for test, err in result.errors:
53         print(err)
54     for test, err in result.failures:
55         print(err)
56
57
58 options, args = cmdline.ParseArgs()
59
60 # Run our meagre tests
61 if options.test:
62     RunTests(options.skip_net_tests)
63
64 # Build selected commits for selected boards
65 else:
66     bsettings.Setup(options.config_file)
67     ret_code = control.DoBuildman(options, args)
68     sys.exit(ret_code)