From patchwork Sun Jul 31 02:57:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1662228 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ltI30fqM; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LwQtV6rc4z9s09 for ; Sun, 31 Jul 2022 12:58:26 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8F5B8844AF; Sun, 31 Jul 2022 04:57:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ltI30fqM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5539C841F4; Sun, 31 Jul 2022 04:57:36 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9FDCB84221 for ; Sun, 31 Jul 2022 04:57:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-10ea9ef5838so4592341fac.3 for ; Sat, 30 Jul 2022 19:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=OrXjAq9RX6c9f1aihjWFAE+TEbtSw2e4ZKG7+pyc/2I=; b=ltI30fqM2VwTw16DuMk3ThE2qPUcFfaju53xnMuZpKNpVX2qob2h6/PPLlnBCZ/aDG 70OSgz9LY3X9Q3Y3+MVdLyE0hl4ynIM58oilCbI0Sk1r/a3oiQf9kAYVmRYGTt8RhKSD WtsiYgLMRPdXUjpr0M8OztcaDiqlB2/K9BhMs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=OrXjAq9RX6c9f1aihjWFAE+TEbtSw2e4ZKG7+pyc/2I=; b=qsbuitpLgAzY7NimeXe/aavHayq62oVHIORAbX1+2nlWP1x4sySylCN/+e908BfHIv nrxGuLjnDjHxUoY8pdGZ6vMePm1St3k8km58K/0gShtNHWjyUhYLljeg2hHA8i2SJElz u1auXQ629B41q3ENSVxkySzsSnLKdSW+rVhCrmkGuZ+oa04hAdHzZNJl4jDRNYj6qH/9 PQktmPLNmRLAUfFaCBPvBnjI8jJ4+msYtN4DFWp3d+t7VW7JPIdUrdLWmkNX+rSwUh8y e5EH+itce+U1ME8cfmMLcHiKzzmKP3r23k0SM+S1NjRmMf/cvMn/DKqLL+zxYcLt8hOQ Ui/A== X-Gm-Message-State: AJIora/I7kvr8dQl9WVDdL0x8QV9rlUxSvWw9E0jWQDtR61Nz7AIZLPL Y8EneWuCTCkeH2fvpZ9zO52JEdeqnYCCaA== X-Google-Smtp-Source: AGRyM1tjGzcic234m/I0zxCx+AGHOlNiQVbmkZ4MWvcdtXkn7SoALL8mCI1KmMfn6R6PlH6Y5WQ1Cg== X-Received: by 2002:a05:6870:339e:b0:10d:8607:4e76 with SMTP id w30-20020a056870339e00b0010d86074e76mr4871218oae.179.1659236251083; Sat, 30 Jul 2022 19:57:31 -0700 (PDT) Received: from sjg1.lan (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id 185-20020a4a00c2000000b0043610215abasm2061952ooh.16.2022.07.30.19.57.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jul 2022 19:57:30 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Alper Nebi Yasak Subject: [PATCH 5/7] test_fdt: Convert to use argparse Date: Sat, 30 Jul 2022 20:57:09 -0600 Message-Id: <20220731025711.871999-6-sjg@chromium.org> X-Mailer: git-send-email 2.37.1.455.g008518b4e5-goog In-Reply-To: <20220731025711.871999-1-sjg@chromium.org> References: <20220731025711.871999-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Drop the deprecated OptionParser. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/dtoc/test_fdt.py | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index e10fb528e81..c38158edf32 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -4,7 +4,7 @@ # Written by Simon Glass # -from optparse import OptionParser +from argparse import ArgumentParser import glob import os import shutil @@ -778,12 +778,11 @@ def run_test_coverage(build_dir): ['tools/patman/*.py', '*test_fdt.py'], build_dir) -def run_tests(args, processes): +def run_tests(names, processes): """Run all the test we have for the fdt model Args: - args (list or str): List of positional args provided. This can hold a - test name to execute (as in 'test_fdt -t testFdt', for example) + names (list of str): List of test names provided. Only the first is used processes (int): Number of processes to use (None means as many as there are CPUs on the system. This must be set to 1 when running under the python3-coverage tool @@ -791,7 +790,7 @@ def run_tests(args, processes): Returns: int: Return code, 0 on success """ - test_name = args[0] if args else None + test_name = names[0] if names else None result = test_util.run_test_suites( 'test_fdt', False, False, False, processes, test_name, None, [TestFdt, TestNode, TestProp, TestFdtUtil]) @@ -801,23 +800,25 @@ def run_tests(args, processes): def main(): """Main program for this tool""" - parser = OptionParser() - parser.add_option('-B', '--build-dir', type='string', default='b', - help='Directory containing the build output') - parser.add_option('-P', '--processes', type=int, - help='set number of processes to use for running tests') - parser.add_option('-t', '--test', action='store_true', dest='test', - default=False, help='run tests') - parser.add_option('-T', '--test-coverage', action='store_true', - default=False, help='run tests and check for 100% coverage') - (options, args) = parser.parse_args() + parser = ArgumentParser() + parser.add_argument('-B', '--build-dir', type=str, default='b', + help='Directory containing the build output') + parser.add_argument('-P', '--processes', type=int, + help='set number of processes to use for running tests') + parser.add_argument('-t', '--test', action='store_true', dest='test', + default=False, help='run tests') + parser.add_argument('-T', '--test-coverage', action='store_true', + default=False, + help='run tests and check for 100% coverage') + parser.add_argument('name', nargs='*') + args = parser.parse_args() # Run our meagre tests - if options.test: - ret_code = run_tests(args, options.processes) + if args.test: + ret_code = run_tests(args.name, args.processes) return ret_code - if options.test_coverage: - run_test_coverage(options.build_dir) + if args.test_coverage: + run_test_coverage(args.build_dir) return 0 if __name__ == '__main__':