blob: 607429df7bcd9fb045e30ce1fa81a6cba318110d [file] [log] [blame]
Jagannadha Sutradharudu Tekia707b3d2013-09-28 23:08:14 +05301#!/usr/bin/env python
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
33def RunTests():
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 Glassd4144e42014-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 Glassfc3fe1c2013-04-03 11:07:16 +000047
Simon Glassfc3fe1c2013-04-03 11:07:16 +000048 print result
49 for test, err in result.errors:
50 print err
51 for test, err in result.failures:
52 print err
53
54
Simon Glassd3d5c122014-09-05 19:00:10 -060055options, args = cmdline.ParseArgs()
Simon Glassfc3fe1c2013-04-03 11:07:16 +000056
57# Run our meagre tests
58if options.test:
59 RunTests()
Simon Glassfc3fe1c2013-04-03 11:07:16 +000060
61# Build selected commits for selected boards
62else:
Simon Glassfd03d632014-09-05 19:00:14 -060063 bsettings.Setup(options.config_file)
Simon Glass2c3deb92014-08-28 09:43:39 -060064 ret_code = control.DoBuildman(options, args)
65 sys.exit(ret_code)