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 11E88C001DC for ; Thu, 20 Jul 2023 00:04:45 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E953D86928; Thu, 20 Jul 2023 01:53:10 +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="NMopodac"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CC39B8606E; Thu, 20 Jul 2023 01:51:09 +0200 (CEST) Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) (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 87F18867F7 for ; Thu, 20 Jul 2023 01:51:02 +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-xd2d.google.com with SMTP id ca18e2360f4ac-7835971026fso8384139f.3 for ; Wed, 19 Jul 2023 16:51:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689810661; x=1690415461; 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=tA86L8gEn+aidARXl6etM8yf96kZHbqPn9GliJPemc4=; b=NMopodacY+Wct3FLHTNlpWROePkqQWgiYesaDJpo7FCF2TNAcY1itW6FBQV7807zqu pWz0K+ppANnzIIHOlP+tweOr2ncfoWLyu1u8vFLNU5n5659OUww/ylPK6w7JL7m36QL4 Bh5Zpzxg7JPuX98oyyMDmr80AxEnl1mnDpV/4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689810661; x=1690415461; 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=tA86L8gEn+aidARXl6etM8yf96kZHbqPn9GliJPemc4=; b=Q6RnbnX2kCcEaktiRH6jhvmQs2x1VLGXcLyUm7k9md+F66m+hFr3k3ZV6OdGGOYsve 6K/1k/1GiglTF4cZFn6juATXfgO2mEkiCZFmaKF2d01kLR0OONkXOur7+1uYONsOu9Nh NH1xy09umtFbG+NF8vzdpCnzUrJxQC6W5zYpBx6biMXWLlUdiLXM+5ot7OrRWPTc7JfC rwIzxUO5iaCRmqbcsJLN1pFJxvqoVIcB6OnpajPhcK/oaEFg3u5hLvPwSkDz6UF+cJ0d y9sDjrpzt3f82APeRErnfJMOmHzsj9l/Lg/+VY4Fm2H1TxsmdPX+i0wHOBiE3pigsdZ/ CDSw== X-Gm-Message-State: ABy/qLan9/zMCSnpYqjE4r8aJDo6JoS9pKkRw1lseVoRZrNcnFRLOctN 9Bd+Hmh258DYXS1WNLh4ly9DdlbvukwwvRxepDA= X-Google-Smtp-Source: APBJJlGLloBaqbDedi6JVfGw+csdG67TTD6ShRj/XhVnvsIQb6AGcwMDFkuG2C0Mz4Lx7ASMedNuRw== X-Received: by 2002:a6b:7f48:0:b0:77e:3d2f:d1f4 with SMTP id m8-20020a6b7f48000000b0077e3d2fd1f4mr3791488ioq.15.1689810661086; Wed, 19 Jul 2023 16:51:01 -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 ed16-20020a056638291000b0042bb1779c18sm1551779jab.151.2023.07.19.16.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 16:51:00 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v4 83/83] buildman: Enable test coverage Date: Wed, 19 Jul 2023 17:49:31 -0600 Message-ID: <20230719234953.796101-84-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230719234953.796101-1-sjg@chromium.org> References: <20230719234953.796101-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 --- (no changes since v3) 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.487.g6d72f3e995-goog