blob: 6aadf767eca5a82bc38a55012eb525684a6e95f0 [file] [log] [blame]
Simon Glassefeac062019-10-31 07:42:52 -06001#!/usr/bin/env python3
Tom Rini10e47792018-05-06 17:58:06 -04002# SPDX-License-Identifier: GPL-2.0+
Simon Glass26132882012-01-14 15:12:45 +00003#
4# Copyright (c) 2011 The Chromium OS Authors.
5#
Simon Glass26132882012-01-14 15:12:45 +00006
7"""See README for more information"""
8
Simon Glass26132882012-01-14 15:12:45 +00009import os
Simon Glass26132882012-01-14 15:12:45 +000010import sys
Simon Glass26132882012-01-14 15:12:45 +000011
Simon Glassd1b6ecf2023-11-04 10:25:22 -060012# Allow 'from patman import xxx to work'
13# pylint: disable=C0413
14our_path = os.path.dirname(os.path.realpath(__file__))
15sys.path.append(os.path.join(our_path, '..'))
Simon Glassbdaad402020-04-17 18:08:52 -060016
Simon Glass26132882012-01-14 15:12:45 +000017# Our modules
Simon Glass78ee8f82025-04-29 07:22:09 -060018from u_boot_pylib import tout
Simon Glass22ce6412023-11-04 10:25:20 -060019from patman import cmdline
Simon Glass24725af2020-07-05 21:41:49 -060020from patman import control
Simon Glass131444f2023-02-23 18:18:04 -070021from u_boot_pylib import test_util
Simon Glass26132882012-01-14 15:12:45 +000022
Simon Glass26132882012-01-14 15:12:45 +000023
Simon Glassf42ad6a2023-11-04 10:25:21 -060024def run_patman():
25 """Run patamn
Simon Glass2b68b362015-07-30 13:47:41 -060026
Simon Glassf42ad6a2023-11-04 10:25:21 -060027 This is the main program. It collects arguments and runs either the tests or
28 the control module.
29 """
30 args = cmdline.parse_args()
Simon Glass22ce6412023-11-04 10:25:20 -060031
Simon Glassf42ad6a2023-11-04 10:25:21 -060032 if not args.debug:
33 sys.tracebacklimit = 0
Simon Glassdbac7162020-07-05 21:41:59 -060034
Simon Glass78ee8f82025-04-29 07:22:09 -060035 tout.init(tout.INFO if args.verbose else tout.WARNING)
36
37 # Run our reasonably good tests
Simon Glassf42ad6a2023-11-04 10:25:21 -060038 if args.cmd == 'test':
Simon Glassd1b6ecf2023-11-04 10:25:22 -060039 # pylint: disable=C0415
Simon Glassf42ad6a2023-11-04 10:25:21 -060040 from patman import func_test
41 from patman import test_checkpatch
Simon Glass26132882012-01-14 15:12:45 +000042
Simon Glassf42ad6a2023-11-04 10:25:21 -060043 result = test_util.run_test_suites(
Simon Glass17899e42025-04-29 07:22:06 -060044 'patman', False, False, False, False, None, None, None,
Simon Glassf42ad6a2023-11-04 10:25:21 -060045 [test_checkpatch.TestPatch, func_test.TestFunctional,
Simon Glassba1b3b92025-02-09 14:26:00 -070046 'settings'])
Simon Glass26132882012-01-14 15:12:45 +000047
Simon Glassf42ad6a2023-11-04 10:25:21 -060048 sys.exit(0 if result.wasSuccessful() else 1)
Tom Rini5a9ecb22020-07-24 08:42:06 -040049
Simon Glassf42ad6a2023-11-04 10:25:21 -060050 # Process commits, produce patches files, check them, email them
Simon Glass3c0196f2025-04-29 07:21:58 -060051 else:
Simon Glass78ee8f82025-04-29 07:22:09 -060052 exit_code = control.do_patman(args)
53 sys.exit(exit_code)
Simon Glassf42ad6a2023-11-04 10:25:21 -060054
Simon Glass3db916d2020-10-29 21:46:35 -060055
Simon Glassf42ad6a2023-11-04 10:25:21 -060056if __name__ == "__main__":
57 sys.exit(run_patman())