From nobody Mon Feb 9 06:31:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+94553+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+94553+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1664502964; cv=none; d=zohomail.com; s=zohoarc; b=NCYMHMfmRavSlE0jMfQ3XR2i0SVF2+8pC9O0g9o5VZlWTUHTwfvUDW7JCvPswf0cjd3+zpJVScnFybIOivSTrGx/0GMogzt1BtxJssyS3IgefJFj8ipLQ8YOY50pLDQhnnNUVV9ldeu0D+o0nj2DE8QE70tUiLlqXkZ89dKGFzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664502964; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=acs7kbTXifJ0LmJlHgKcLA2jxFgpd3sLGRk5gSS0/kQ=; b=ALm8m1lDo4VPxag/IjZvB9dbV7OGAjA5bKZCtGEyfFSIOs0oXY78VpC5gnKHJTB+lBDB7vL8YLbMzZSUavEI3yHpHLUYpgf14+ppoQyEtYYPXyBjeSpdYA3AbPJy3p6KfB7Un+3aPh8SdPS33xHGhHA0I1ji18Wv0BORD15BcrI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+94553+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1664502964977386.5316555264084; Thu, 29 Sep 2022 18:56:04 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Rxl3YY1788612xYule0es6yi; Thu, 29 Sep 2022 18:56:04 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.1156.1664502959898933557 for ; Thu, 29 Sep 2022 18:56:04 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="281788321" X-IronPort-AV: E=Sophos;i="5.93,357,1654585200"; d="scan'208";a="281788321" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2022 18:56:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="726671347" X-IronPort-AV: E=Sophos;i="5.93,357,1654585200"; d="scan'208";a="726671347" X-Received: from gguo-desk.gar.corp.intel.com ([10.5.215.23]) by fmsmga002.fm.intel.com with ESMTP; 29 Sep 2022 18:56:02 -0700 From: "Guo, Gua" To: devel@edk2.groups.io Cc: Gua Guo , Sean Brogan , Bret Barkelew , Michael D Kinney , Liming Gao Subject: [edk2-devel] [PATCH v5 3/3] .azurepipelines: Install code coverage tool Date: Fri, 30 Sep 2022 09:55:56 +0800 Message-Id: <4640dcd72927df92d5304411c9a872acd97bf76c.1664502910.git.gua.guo@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,gua.guo@intel.com X-Gm-Message-State: CKxQjXlfYzfqko5H3PBkQX1rx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664502964; bh=TFzh+1eSjHXkfofuLdhpbAGLlktgV8tnYBdQm8oJl2o=; h=Cc:Date:From:Reply-To:Subject:To; b=tlqJX44DOXe31+sCbpPyt2UF75/pdNcbV4wGrt5vVUM15CiBHqmpvx+k84XutTKjyDG zq4R6AcI7d/w4rskwmNhhC/pfC0FQsFf1TM4pubhFgyOnAFizo47QkwQQJtjuishvsLhn iaMP+JT8xJpGl9BZY29b17wAGWRQ2Crz+w4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664502965303100012 Content-Type: text/plain; charset="utf-8" From: Gua Guo For Windows add below tool for code coverage 1. OpenCppCoverage: parsing pdb file to generate coverage data 2. pycobertura: show up html format data for coverage data For Linux add below tool for code coverage 1. lcov: parsing gcda gcno file to generate coverage data 2. lcov-cobertura: convert coverage data to cobertura format 3. pycobertura: show up html format data for coverage data Cc: Sean Brogan Cc: Bret Barkelew Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Gua Guo --- .azurepipelines/Ubuntu-GCC5.yml | 5 ++++- .azurepipelines/Windows-VS2019.yml | 5 +++++ .azurepipelines/templates/pr-gate-build-job.yml | 2 ++ .azurepipelines/templates/pr-gate-steps.yml | 5 +++++ .../HostBasedUnitTestRunner.py | 12 ++++++------ pip-requirements.txt | 3 +++ 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.azurepipelines/Ubuntu-GCC5.yml b/.azurepipelines/Ubuntu-GCC5.= yml index 3760c6efe1..9d53528063 100644 --- a/.azurepipelines/Ubuntu-GCC5.yml +++ b/.azurepipelines/Ubuntu-GCC5.yml @@ -18,4 +18,7 @@ jobs: tool_chain_tag: 'GCC5' vm_image: 'ubuntu-latest' arch_list: "IA32,X64,ARM,AARCH64,RISCV64" - + extra_install_step: + - bash: sudo apt-get install -y lcov + displayName: Install Code Coverage Tools + condition: and(gt(variables.pkg_count, 0), succeeded()) diff --git a/.azurepipelines/Windows-VS2019.yml b/.azurepipelines/Windows-V= S2019.yml index e4bd4b1d22..c07e5bb434 100644 --- a/.azurepipelines/Windows-VS2019.yml +++ b/.azurepipelines/Windows-VS2019.yml @@ -18,3 +18,8 @@ jobs: tool_chain_tag: 'VS2019' vm_image: 'windows-2019' arch_list: "IA32,X64" + extra_install_step: + - powershell: choco install opencppcoverage; Write-Host "##vso[task.pr= ependpath]C:\Program Files\OpenCppCoverage" + displayName: Install Code Coverage Tool + condition: and(gt(variables.pkg_count, 0), succeeded()) + diff --git a/.azurepipelines/templates/pr-gate-build-job.yml b/.azurepipeli= nes/templates/pr-gate-build-job.yml index 0e4ad019bf..0162ea97cb 100644 --- a/.azurepipelines/templates/pr-gate-build-job.yml +++ b/.azurepipelines/templates/pr-gate-build-job.yml @@ -12,6 +12,7 @@ parameters: tool_chain_tag: '' vm_image: '' arch_list: '' + extra_install_step: [] =20 # Build step jobs: @@ -70,3 +71,4 @@ jobs: build_pkgs: $(Build.Pkgs) build_targets: $(Build.Targets) build_archs: ${{ parameters.arch_list }} + extra_install_step: ${{ parameters.extra_install_step }} diff --git a/.azurepipelines/templates/pr-gate-steps.yml b/.azurepipelines/= templates/pr-gate-steps.yml index cb431e53fc..0568941399 100644 --- a/.azurepipelines/templates/pr-gate-steps.yml +++ b/.azurepipelines/templates/pr-gate-steps.yml @@ -12,6 +12,7 @@ parameters: build_pkgs: '' build_targets: '' build_archs: '' + extra_install_step: [] =20 steps: - checkout: self @@ -37,6 +38,8 @@ steps: displayName: fetch target branch condition: eq(variables['Build.Reason'], 'PullRequest') =20 +- ${{ parameters.extra_install_step }} + # trim the package list if this is a PR - task: CmdLine@1 displayName: Check if ${{ parameters.build_pkgs }} need testing @@ -125,6 +128,8 @@ steps: TestSuites.xml **/BUILD_TOOLS_REPORT.html **/OVERRIDELOG.TXT + coverage.xml + coverage.html flattenFolders: true condition: succeededOrFailed() =20 diff --git a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunn= er.py b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py index d92de236dc..c2821cde7d 100644 --- a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py +++ b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py @@ -194,7 +194,7 @@ class HostBasedUnitTestRunner(IUefiBuildPlugin): buildOutputBase =3D thebuilder.env.GetValue("BUILD_OUTPUT_BASE") testList =3D glob.glob(os.path.join(buildOutputBase, "**","*Test*.= exe"), recursive=3DTrue) workspace =3D thebuilder.env.GetValue("WORKSPACE") - + workspace =3D (workspace + os.sep) if workspace[-1] !=3D os.sep el= se workspace # Generate coverage file coverageFile =3D "" for testFile in testList: @@ -204,13 +204,14 @@ class HostBasedUnitTestRunner(IUefiBuildPlugin): logging.error("UnitTest Coverage: Failed to collect covera= ge data.") return 1 =20 + DiskName =3D workspace[:workspace.find (":\\") + 2] # Generate and HTML file if requested.by each package - ret =3D RunCmd("OpenCppCoverage", f"--export_type cobertura:{build= OutputBase}/coverage.xml --working_dir=3D{workspace}/Build {coverageFile}") + ret =3D RunCmd("OpenCppCoverage", f"--export_type cobertura:{build= OutputBase}/coverage.xml --working_dir=3D{workspace}Build {coverageFile}") if(ret !=3D 0): logging.error("UnitTest Coverage: Failed to generate cobertura= format xml in single package.") return 1 =20 - ret =3D RunCmd("pycobertura", f"show --format html --output {build= OutputBase}/cverage.html {buildOutputBase}/coverage.xml --source {workspace= }") + ret =3D RunCmd("pycobertura", f"show --format html --output {build= OutputBase}/coverage.html {buildOutputBase}/coverage.xml --source {DiskName= }") if(ret !=3D 0): logging.error("UnitTest Coverage: Failed to generate HTML in s= ingle package.") return 1 @@ -221,12 +222,11 @@ class HostBasedUnitTestRunner(IUefiBuildPlugin): for testCoverage in testCoverageList: coverageFile +=3D " --input_coverage=3D" + testCoverage =20 - ret =3D RunCmd("OpenCppCoverage", f"--export_type cobertura:{works= pace}/Build/coverage.xml --working_dir=3D{workspace}/Build {coverageFile}") + ret =3D RunCmd("OpenCppCoverage", f"--export_type cobertura:{works= pace}Build/coverage.xml --working_dir=3D{workspace}Build {coverageFile}") if(ret !=3D 0): logging.error("UnitTest Coverage: Failed to generate cobertura= format xml.") return 1 - - ret =3D RunCmd("pycobertura", f"show --format html --output {works= pace}/Build/coverage.html {workspace}/Build/coverage.xml --source {workspac= e}") + ret =3D RunCmd("pycobertura", f"show --format html --output {works= pace}Build/coverage.html {workspace}Build/coverage.xml --source {DiskName}") if(ret !=3D 0): logging.error("UnitTest Coverage: Failed to generate HTML.") return 1 diff --git a/pip-requirements.txt b/pip-requirements.txt index 967da7cb37..18f5afb9c5 100644 --- a/pip-requirements.txt +++ b/pip-requirements.txt @@ -16,3 +16,6 @@ edk2-pytool-library=3D=3D0.11.2 edk2-pytool-extensions~=3D0.16.0 edk2-basetools=3D=3D0.1.29 antlr4-python3-runtime=3D=3D4.7.1 +pycobertura=3D=3D2.1.0 +lcov-cobertura=3D=3D2.0.2 + --=20 2.31.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#94553): https://edk2.groups.io/g/devel/message/94553 Mute This Topic: https://groups.io/mt/94008744/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-