From patchwork Sat Apr 4 21:28:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2119 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775338259; bh=iWSVr7Hxd2dG/Jzbc3/H9qSB9Pfp2AD2PI4iFk3DAB0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Ju2vt6wMyLMby4TKpN9OO9tfWJOCKNzONMNvYtr9bMuqpb7XbonX7SKUlzOHMCVMj bGhTmj9xF1+n/PRq1S2zIQOux4R4vyr4GFQge5jSQC61RlN7D+bPD6T3utvq1mtE4m +P4HPNeAO2q3YNxgicEKrT4DZTCVMQf+HqzpHClig1UsH37aPArrV6P4yWF3fcp7W4 de6ZfS6QBylH7iA73FjPbKYlHPm8JULsiD7UEkbu85j8X2igdoenthXhTecM1odc6z YH8ljXXtnAVhYBBX1CR0+wnbStbqZ7YyjGeEXVuX0EacfDqqtZDWvDqTMQVs20cNTA Dlnnofu52FDEw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 26F346A37D for ; Sat, 4 Apr 2026 15:30:59 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Wr-kRj6nQqP2 for ; Sat, 4 Apr 2026 15:30:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775338259; bh=iWSVr7Hxd2dG/Jzbc3/H9qSB9Pfp2AD2PI4iFk3DAB0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Ju2vt6wMyLMby4TKpN9OO9tfWJOCKNzONMNvYtr9bMuqpb7XbonX7SKUlzOHMCVMj bGhTmj9xF1+n/PRq1S2zIQOux4R4vyr4GFQge5jSQC61RlN7D+bPD6T3utvq1mtE4m +P4HPNeAO2q3YNxgicEKrT4DZTCVMQf+HqzpHClig1UsH37aPArrV6P4yWF3fcp7W4 de6ZfS6QBylH7iA73FjPbKYlHPm8JULsiD7UEkbu85j8X2igdoenthXhTecM1odc6z YH8ljXXtnAVhYBBX1CR0+wnbStbqZ7YyjGeEXVuX0EacfDqqtZDWvDqTMQVs20cNTA Dlnnofu52FDEw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0B2F16A369 for ; Sat, 4 Apr 2026 15:30:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775338257; bh=DmdLwcj1Eg38u+cl56LIIQ+kO74/4npoK6gnEBElGMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tC+XOY9bcSdeHh9L57gkoAbEFhEpkP4PbybbJy9Z60hs6tUxrGGmLEbgFlFJji7vg m0+d6kCFUxDQtDXRrOkM8E17XBMelu84UxUdYEMQXrBbSCXUA1E4QWhCwDRQJK+vIu de7P7KgWvLzoXXtMaYB3aVn81BBko8aF/gnInUNTDi4toxDQR2LZ/l+Q1L0t3Y8Yeq PqfDxBvirrIsHF7yQd+w5JdJZLz7F/yQ/hiVVE9o9m5r8BdfwFGmzWIGnJOJwEanM2 4oXrnusiyL4/QEBOQ4/X35exLt7ITd9ZXnf8rwPa4pzpuo5gEU4dTQCg1/xZq2Ee5J 5TJwjv+dMav4w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B3CC26A255; Sat, 4 Apr 2026 15:30:57 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id KJyQTp62RQJD; Sat, 4 Apr 2026 15:30:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1775338253; bh=orwgCcbteQhoYHyOvIOj9n+GNS46LSHWGiOdeqhkrAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OK7z1+toUJRkUihHf22HJUlOBW79xGHpvkhxz5C9vLeVL7X4Jn4cKnmqUbv0DZQe6 f5ceyg2RQmdJ3Kdz3tFcCDgpnyw322R+4g7XC+OfWwqedjoXVzB2GigudiIe9AYHDX +9ixmj7AB5Rj7zPOd1QKaS+BpKQ42Y/VEbe9aU82OblQiB8njbN7xWmDNwH6fhUT5Z NB2N/nIlwlyqIs51nUeyDz8C6r2uikVX/48tY1LHeXAHHrvmIncd2m0z7r5YQJWeiL u1HRHr6QH3cvK8wwZbP7SnrHMUoY3VeOPGvNY3BK2LSbdyKnZMkDDFKHZTt5cH4GrP 0OlmMdl75cJvQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 735456869D; Sat, 4 Apr 2026 15:30:53 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 4 Apr 2026 15:28:40 -0600 Message-ID: <20260404213020.372253-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260404213020.372253-1-sjg@u-boot.org> References: <20260404213020.372253-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 632SWT2RS2ZE2Z2NOXEEYGBUSZYA4NLM X-Message-ID-Hash: 632SWT2RS2ZE2Z2NOXEEYGBUSZYA4NLM X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/37] u_boot_pylib: Add test runner entry point List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The u_boot_pylib module has no way to run its tests from the command line. Other tools like patman and buildman have their own entry points that accept a 'test' subcommand. Add a proper __main__.py with argument parsing and a symlink so tests can be run with './tools/u_boot_pylib/u_boot_pylib test'. Signed-off-by: Simon Glass --- tools/u_boot_pylib/__main__.py | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/tools/u_boot_pylib/__main__.py b/tools/u_boot_pylib/__main__.py index d86b9d7dce0..5f802bd8d86 100755 --- a/tools/u_boot_pylib/__main__.py +++ b/tools/u_boot_pylib/__main__.py @@ -4,19 +4,37 @@ # Copyright 2023 Google LLC # +"""u_boot_pylib test runner""" + import os import sys -if __name__ == "__main__": - # Allow 'from u_boot_pylib import xxx to work' - our_path = os.path.dirname(os.path.realpath(__file__)) - sys.path.append(os.path.join(our_path, '..')) +# Allow 'from u_boot_pylib import xxx' to work +our_path = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(our_path, '..')) + +import argparse + +from u_boot_pylib import test_util - # Run tests - from u_boot_pylib import test_util +def run_tests(): + parser = argparse.ArgumentParser(description='u_boot_pylib test runner') + parser.add_argument('cmd', choices=['test'], help='Command to run') + parser.add_argument('testname', nargs='?', default=None, + help='Specific test to run') + parser.add_argument('-v', '--verbose', action='store_true', + help='Verbose output') + args = parser.parse_args() + + to_run = args.testname if args.testname not in [None, 'test'] else None result = test_util.run_test_suites( - 'u_boot_pylib', False, False, False, False, None, None, None, - ['terminal']) + 'u_boot_pylib', False, args.verbose, False, + False, None, to_run, None, + ['u_boot_pylib.terminal']) sys.exit(0 if result.wasSuccessful() else 1) + + +if __name__ == "__main__": + run_tests()