blob: 0d08a53cbabd3f9379810389453071c5d5d09147 [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 Glass22ce6412023-11-04 10:25:20 -060018from patman import cmdline
Simon Glass24725af2020-07-05 21:41:49 -060019from patman import control
Simon Glass131444f2023-02-23 18:18:04 -070020from u_boot_pylib import test_util
Simon Glass26132882012-01-14 15:12:45 +000021
Simon Glass26132882012-01-14 15:12:45 +000022
Simon Glassf42ad6a2023-11-04 10:25:21 -060023def run_patman():
24 """Run patamn
Simon Glass2b68b362015-07-30 13:47:41 -060025
Simon Glassf42ad6a2023-11-04 10:25:21 -060026 This is the main program. It collects arguments and runs either the tests or
27 the control module.
28 """
29 args = cmdline.parse_args()
Simon Glass22ce6412023-11-04 10:25:20 -060030
Simon Glassf42ad6a2023-11-04 10:25:21 -060031 if not args.debug:
32 sys.tracebacklimit = 0
Simon Glassdbac7162020-07-05 21:41:59 -060033
Simon Glassf42ad6a2023-11-04 10:25:21 -060034 # Run our meagre tests
35 if args.cmd == 'test':
Simon Glassd1b6ecf2023-11-04 10:25:22 -060036 # pylint: disable=C0415
Simon Glassf42ad6a2023-11-04 10:25:21 -060037 from patman import func_test
38 from patman import test_checkpatch
Simon Glass26132882012-01-14 15:12:45 +000039
Simon Glassf42ad6a2023-11-04 10:25:21 -060040 result = test_util.run_test_suites(
41 'patman', False, False, False, None, None, None,
42 [test_checkpatch.TestPatch, func_test.TestFunctional,
Simon Glassba1b3b92025-02-09 14:26:00 -070043 'settings'])
Simon Glass26132882012-01-14 15:12:45 +000044
Simon Glassf42ad6a2023-11-04 10:25:21 -060045 sys.exit(0 if result.wasSuccessful() else 1)
Tom Rini5a9ecb22020-07-24 08:42:06 -040046
Simon Glassf42ad6a2023-11-04 10:25:21 -060047 # Process commits, produce patches files, check them, email them
Simon Glass3c0196f2025-04-29 07:21:58 -060048 else:
49 control.do_patman(args)
Simon Glassf42ad6a2023-11-04 10:25:21 -060050
Simon Glass3db916d2020-10-29 21:46:35 -060051
Simon Glassf42ad6a2023-11-04 10:25:21 -060052if __name__ == "__main__":
53 sys.exit(run_patman())