blob: 2b714739a20546647333e9e1addeecafdc2bcc70 [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 Glassf0d9c102020-04-17 18:09:02 -06009import doctest
Simon Glassc05694f2013-04-03 11:07:16 +000010import 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 Glassf0d9c102020-04-17 18:09:02 -060018sys.path.insert(1, os.path.join(our_path, '..'))
Simon Glassc05694f2013-04-03 11:07:16 +000019
20# Our modules
Simon Glassf0d9c102020-04-17 18:09:02 -060021from buildman import board
22from buildman import bsettings
23from buildman import builder
24from buildman import cmdline
25from buildman import control
26from buildman import toolchain
Simon Glassa997ea52020-04-17 18:09:04 -060027from patman import patchstream
28from patman import gitutil
29from patman import terminal
Simon Glassc05694f2013-04-03 11:07:16 +000030
Simon Glass2bfc6972017-11-12 21:52:14 -070031def RunTests(skip_net_tests):
Simon Glassed098bb2014-09-05 19:00:13 -060032 import func_test
Simon Glassc05694f2013-04-03 11:07:16 +000033 import test
Simon Glasscc246fb2013-09-23 17:35:17 -060034 import doctest
35
36 result = unittest.TestResult()
Simon Glass42143162020-04-17 18:09:05 -060037 for module in ['buildman.toolchain', 'patman.gitutil']:
Simon Glasscc246fb2013-09-23 17:35:17 -060038 suite = doctest.DocTestSuite(module)
39 suite.run(result)
40
Simon Glassc05694f2013-04-03 11:07:16 +000041 sys.argv = [sys.argv[0]]
Simon Glass2bfc6972017-11-12 21:52:14 -070042 if skip_net_tests:
43 test.use_network = False
Simon Glassed098bb2014-09-05 19:00:13 -060044 for module in (test.TestBuild, func_test.TestFunctional):
45 suite = unittest.TestLoader().loadTestsFromTestCase(module)
46 suite.run(result)
Simon Glassc05694f2013-04-03 11:07:16 +000047
Simon Glassc78ed662019-10-31 07:42:53 -060048 print(result)
Simon Glassc05694f2013-04-03 11:07:16 +000049 for test, err in result.errors:
Simon Glassc78ed662019-10-31 07:42:53 -060050 print(err)
Simon Glassc05694f2013-04-03 11:07:16 +000051 for test, err in result.failures:
Simon Glassc78ed662019-10-31 07:42:53 -060052 print(err)
Simon Glassc05694f2013-04-03 11:07:16 +000053
54
Simon Glass04bac6b2014-09-05 19:00:10 -060055options, args = cmdline.ParseArgs()
Simon Glassc05694f2013-04-03 11:07:16 +000056
57# Run our meagre tests
58if options.test:
Simon Glass2bfc6972017-11-12 21:52:14 -070059 RunTests(options.skip_net_tests)
Simon Glassc05694f2013-04-03 11:07:16 +000060
61# Build selected commits for selected boards
62else:
Simon Glassc88c8952014-09-05 19:00:14 -060063 bsettings.Setup(options.config_file)
Simon Glassc2f91072014-08-28 09:43:39 -060064 ret_code = control.DoBuildman(options, args)
65 sys.exit(ret_code)