blob: 4e20761ae3afe938576e67ddb44593c9dbfb65c0 [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 Glassc0257982025-04-29 07:22:11 -060018from u_boot_pylib import test_util
Simon Glass78ee8f82025-04-29 07:22:09 -060019from u_boot_pylib import tout
Simon Glass22ce6412023-11-04 10:25:20 -060020from patman import cmdline
Simon Glass24725af2020-07-05 21:41:49 -060021from patman import control
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 Glassed831d12025-04-29 07:22:10 -060043 to_run = args.testname if args.testname not in [None, 'test'] else None
Simon Glassf42ad6a2023-11-04 10:25:21 -060044 result = test_util.run_test_suites(
Simon Glassed831d12025-04-29 07:22:10 -060045 'patman', False, args.verbose, args.no_capture,
46 args.test_preserve_dirs, None, to_run, None,
Simon Glassf42ad6a2023-11-04 10:25:21 -060047 [test_checkpatch.TestPatch, func_test.TestFunctional,
Simon Glassba1b3b92025-02-09 14:26:00 -070048 'settings'])
Simon Glass26132882012-01-14 15:12:45 +000049
Simon Glassf42ad6a2023-11-04 10:25:21 -060050 sys.exit(0 if result.wasSuccessful() else 1)
Tom Rini5a9ecb22020-07-24 08:42:06 -040051
Simon Glassf42ad6a2023-11-04 10:25:21 -060052 # Process commits, produce patches files, check them, email them
Simon Glass3c0196f2025-04-29 07:21:58 -060053 else:
Simon Glass78ee8f82025-04-29 07:22:09 -060054 exit_code = control.do_patman(args)
55 sys.exit(exit_code)
Simon Glassf42ad6a2023-11-04 10:25:21 -060056
Simon Glass3db916d2020-10-29 21:46:35 -060057
Simon Glassf42ad6a2023-11-04 10:25:21 -060058if __name__ == "__main__":
59 sys.exit(run_patman())