Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D895C0015E for ; Sun, 16 Jul 2023 00:51:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9628B86789; Sun, 16 Jul 2023 02:41:00 +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="ig5aA/SR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2A5A286287; Sun, 16 Jul 2023 02:38:49 +0200 (CEST) Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (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 0A02D86321 for ; Sun, 16 Jul 2023 02:38:22 +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-io1-xd32.google.com with SMTP id ca18e2360f4ac-785d738d3feso71432939f.0 for ; Sat, 15 Jul 2023 17:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689467900; x=1692059900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0Dxjyp2VgCcl9/wE8wnPKbpUSjtd/7QEU9492If54E4=; b=ig5aA/SRtqw+J3iKdXA/2BqA8GrUeaovZ39b/Krzg+S8wYfJ2f1n9oOnB/jUChQKPU l/YPnv+G6JmF5PLxo8RU7fwZfbjOZiIFhEPftpE51DzUFRSnmw6p7lgahQ7Z2K1F/Ng+ tZ2Ap4lNV1wmNx3nbxv5qlVm0evVgyqcan5P4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689467900; x=1692059900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0Dxjyp2VgCcl9/wE8wnPKbpUSjtd/7QEU9492If54E4=; b=NRWk7QA8pTyFFMbM96YBUoZ99b4mNBdZLiR+0J7vbvh728GpGQAhbmEiSPrbzQuhS9 aWsqX+aMN38E9JS3tAIOMHUaDYm6z1shgY/r9N+cL4bMchuvQExkDZHQXBUQLmLI4HWq 4u68ocN6oaYaenIIlNPQOopBNeuIymdvrC0J0wONwt7ce425oDj6QoIUxSfPV+VZOymo 4SB5TpEiPFbUjqk1qedP0J79MlYZoJLs2wCV6gTZfLcZG/l9pvaCfrRxWdVsb8Kh2bVB Z8JSVNnehlEAAaFWn5n95NlboWUza69WpjFuM/jW4dZnDUbXWknbmSYezn3icZup8gzs JZ5w== X-Gm-Message-State: ABy/qLY0bDyqWIwfxypvduyS04WHRZQ5PInFbVm4g/LCyPpvQsr9D6Ri DqYWzcUataK4vwDtwdOZwJfCrhKGYkOpK7jwW9M= X-Google-Smtp-Source: APBJJlHtiRUaRY9ztKWTQ2IAJBhprb1zFgZlYvNuiTBeSPoQXKuVp/x/s81zZVMrpsG8s6M6fhd2fA== X-Received: by 2002:a05:6602:1225:b0:783:42bc:cc5f with SMTP id z5-20020a056602122500b0078342bccc5fmr4092954iot.8.1689467900668; Sat, 15 Jul 2023 17:38:20 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id t3-20020a05663801e300b0042b52dc77e3sm3510512jaq.158.2023.07.15.17.38.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 17:38:20 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v3 81/81] buildman: Enable test coverage Date: Sat, 15 Jul 2023 18:36:49 -0600 Message-ID: <20230716003718.231903-82-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.455.g037347b96a-goog In-Reply-To: <20230716003718.231903-1-sjg@chromium.org> References: <20230716003718.231903-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.8 at phobos.denx.de X-Virus-Status: Clean Enable measuring test coverage for buildman so we can see the gaps. It is currently at 68%. Signed-off-by: Simon Glass --- Changes in v3: - Fix 'bulidman' typo in three patches Changes in v2: - Drop patch to move -A logic up a little (since it breaks it) tools/buildman/cmdline.py | 2 ++ tools/buildman/main.py | 15 ++++++++++++++- tools/u_boot_pylib/test_util.py | 10 +++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py index 052e223597c8..03211bd5aa5f 100644 --- a/tools/buildman/cmdline.py +++ b/tools/buildman/cmdline.py @@ -142,6 +142,8 @@ def add_after_m(parser): help='Skip tests which need the network') parser.add_argument('-t', '--test', action='store_true', dest='test', default=False, help='run tests') + parser.add_argument('--coverage', action='store_true', + help='Calculated test coverage') parser.add_argument('-T', '--threads', type=int, default=None, help='Number of builder threads to use (0=single-thread)') diff --git a/tools/buildman/main.py b/tools/buildman/main.py index a7f456bc8193..5f42a58ddbb3 100755 --- a/tools/buildman/main.py +++ b/tools/buildman/main.py @@ -48,12 +48,22 @@ def run_tests(skip_net_tests, debug, verbose, args): # Run the entry tests first ,since these need to be the first to import the # 'entry' module. result = test_util.run_test_suites( - 'buildman', debug, verbose, False, None, test_name, [], + 'buildman', debug, verbose, False, args.threads, test_name, [], [test.TestBuild, func_test.TestFunctional, 'buildman.toolchain', 'patman.gitutil']) return (0 if result.wasSuccessful() else 1) +def run_test_coverage(): + """Run the tests and check that we get 100% coverage""" + test_util.run_test_coverage( + 'tools/buildman/buildman', None, + ['tools/patman/*.py', 'tools/u_boot_pylib/*', '*test_fdt.py', + 'tools/buildman/kconfiglib.py', 'tools/buildman/*test*.py', + 'tools/buildman/main.py'], + '/tmp/b', single_thread='-T1') + + def run_buildman(): """Run bulidman @@ -69,6 +79,9 @@ def run_buildman(): if cmdline.HAS_TESTS and args.test: return run_tests(args.skip_net_tests, args.debug, args.verbose, args) + elif cmdline.HAS_TESTS and args.coverage: + run_test_coverage() + elif args.full_help: tools.print_full_help(str(files('buildman').joinpath('README.rst'))) diff --git a/tools/u_boot_pylib/test_util.py b/tools/u_boot_pylib/test_util.py index e7564e10c997..f18d385d9951 100644 --- a/tools/u_boot_pylib/test_util.py +++ b/tools/u_boot_pylib/test_util.py @@ -24,7 +24,7 @@ except: def run_test_coverage(prog, filter_fname, exclude_list, build_dir, required=None, - extra_args=None): + extra_args=None, single_thread='-P1'): """Run tests and check that we get 100% coverage Args: @@ -39,6 +39,9 @@ def run_test_coverage(prog, filter_fname, exclude_list, build_dir, required=None required: List of modules which must be in the coverage report extra_args (str): Extra arguments to pass to the tool before the -t/test arg + single_thread (str): Argument string to make the tests run + single-threaded. This is necessary to get proper coverage results. + The default is '-P0' Raises: ValueError if the code coverage is not 100% @@ -58,8 +61,9 @@ def run_test_coverage(prog, filter_fname, exclude_list, build_dir, required=None if build_dir: prefix = 'PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools ' % build_dir cmd = ('%spython3-coverage run ' - '--omit "%s" %s %s %s -P1' % (prefix, ','.join(glob_list), - prog, extra_args or '', test_cmd)) + '--omit "%s" %s %s %s %s' % (prefix, ','.join(glob_list), + prog, extra_args or '', test_cmd, + single_thread or '-P1')) os.system(cmd) stdout = command.output('python3-coverage', 'report') lines = stdout.splitlines() -- 2.41.0.455.g037347b96a-goog