From: "Guo, Gua" <gua.guo@intel.com>
To: devel@edk2.groups.io
Cc: Gua Guo <gua.guo@intel.com>,
Sean Brogan <sean.brogan@microsoft.com>,
Bret Barkelew <Bret.Barkelew@microsoft.com>,
Michael D Kinney <michael.d.kinney@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>
Subject: [PATCH v7 3/3] .azurepipelines: Install code coverage tool
Date: Mon, 2 Jan 2023 19:18:02 +0800 [thread overview]
Message-ID: <5318d30db2bb837ebd3718f29f00893e064f1104.1672657976.git.gua.guo@intel.com> (raw)
In-Reply-To: <cover.1672657976.git.gua.guo@intel.com>
From: Gua Guo <gua.guo@intel.com>
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 <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Gua Guo <gua.guo@intel.com>
---
.azurepipelines/Ubuntu-GCC5.yml | 5 ++-
.azurepipelines/Windows-VS2019.yml | 5 +++
.../templates/pr-gate-build-job.yml | 36 +++++++++++++++++++
.azurepipelines/templates/pr-gate-steps.yml | 4 +++
pip-requirements.txt | 2 ++
5 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/.azurepipelines/Ubuntu-GCC5.yml b/.azurepipelines/Ubuntu-GCC5.yml
index 1acd8d2a46..f83951eeaf 100644
--- a/.azurepipelines/Ubuntu-GCC5.yml
+++ b/.azurepipelines/Ubuntu-GCC5.yml
@@ -19,4 +19,7 @@ jobs:
tool_chain_tag: 'GCC5'
vm_image: 'ubuntu-latest'
arch_list: "IA32,X64,ARM,AARCH64,RISCV64,LOONGARCH64"
-
+ 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-VS2019.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.prependpath]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/.azurepipelines/templates/pr-gate-build-job.yml
index 7f88b41dc8..f148ec23e2 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: []
# Build step
jobs:
@@ -77,3 +78,38 @@ jobs:
build_pkgs: $(Build.Pkgs)
build_targets: $(Build.Targets)
build_archs: ${{ parameters.arch_list }}
+ extra_install_step: ${{ parameters.extra_install_step }}
+
+- job: Build_${{ parameters.tool_chain_tag }}_TARGET_CODE_COVERAGE
+ dependsOn: Build_${{ parameters.tool_chain_tag }}
+ workspace:
+ clean: all
+
+ pool:
+ vmImage: 'windows-2019'
+
+ steps:
+ - checkout: self
+ clean: true
+ fetchDepth: 1
+ submodules: true
+
+ - task: DownloadPipelineArtifact@2
+ displayName: 'Download Build Artifacts'
+ inputs:
+ buildType: 'current'
+ targetPath: '$(Build.ArtifactStagingDirectory)'
+
+ - task: CmdLine@2
+ displayName: Create code coverage report
+ inputs:
+ script: |
+ dotnet tool install -g dotnet-reportgenerator-globaltool
+ reportgenerator -reports:$(Build.ArtifactStagingDirectory)/**/coverage.xml -targetdir:$(Build.ArtifactStagingDirectory)/Coverage -reporttypes:Cobertura -filefilters:-*Build*;-*UnitTest*;-*Mock*;*usr/*
+
+ - task: PublishCodeCoverageResults@1
+ displayName: 'Publish code coverage'
+ inputs:
+ codeCoverageTool: Cobertura
+ summaryFileLocation: '$(Build.ArtifactStagingDirectory)/Coverage/Cobertura.xml'
+
diff --git a/.azurepipelines/templates/pr-gate-steps.yml b/.azurepipelines/templates/pr-gate-steps.yml
index cb431e53fc..080f60aea6 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: []
steps:
- checkout: self
@@ -37,6 +38,8 @@ steps:
displayName: fetch target branch
condition: eq(variables['Build.Reason'], 'PullRequest')
+- ${{ 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,7 @@ steps:
TestSuites.xml
**/BUILD_TOOLS_REPORT.html
**/OVERRIDELOG.TXT
+ coverage.xml
flattenFolders: true
condition: succeededOrFailed()
diff --git a/pip-requirements.txt b/pip-requirements.txt
index be8c7a1c37..4ffcadddd8 100644
--- a/pip-requirements.txt
+++ b/pip-requirements.txt
@@ -16,3 +16,5 @@ edk2-pytool-library==0.12.1
edk2-pytool-extensions~=0.20.0
edk2-basetools==0.1.39
antlr4-python3-runtime==4.7.1
+lcov-cobertura==2.0.2
+
--
2.31.1.windows.1
prev parent reply other threads:[~2023-01-02 11:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-02 11:17 [PATCH v7 0/3] Add code coverage support for GCC/MSVC Guo, Gua
2023-01-02 11:18 ` [PATCH v7 1/3] UnitTestFrameworkPkg: Add code coverage support for GCC Guo, Gua
2023-01-02 11:18 ` [PATCH v7 2/3] BaseTools/Plugin: Add coverage support for Unit Test Guo, Gua
2023-01-02 11:18 ` Guo, Gua [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5318d30db2bb837ebd3718f29f00893e064f1104.1672657976.git.gua.guo@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox