public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Guo, Gua" <gua.guo@intel.com>
To: Michael Kubacki <mikuback@linux.microsoft.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>,
	Sean Brogan <sean.brogan@microsoft.com>,
	"Barkelew, Bret" <bret.barkelew@microsoft.com>
Subject: Re: [PATCH 1/3] UnitTestFrameworkPkg: Add code coverage support for GCC
Date: Wed, 21 Dec 2022 03:53:15 +0000	[thread overview]
Message-ID: <BL1PR11MB547887C3E48B6E9E1BF78EC3EFEB9@BL1PR11MB5478.namprd11.prod.outlook.com> (raw)
In-Reply-To: <74525b37-5cff-9a95-4ce4-af1955b3aa17@linux.microsoft.com>

You means "```" to "```inf ", it just make markdown file more readability only.

Thanks,
Gua
-----Original Message-----
From: Michael Kubacki <mikuback@linux.microsoft.com> 
Sent: Wednesday, December 21, 2022 11:41 AM
To: Guo, Gua <gua.guo@intel.com>; devel@edk2.groups.io
Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Sean Brogan <sean.brogan@microsoft.com>; Barkelew, Bret <bret.barkelew@microsoft.com>
Subject: Re: [PATCH 1/3] UnitTestFrameworkPkg: Add code coverage support for GCC

I'm not sure if you added some extra new lines in the markdown file to help with readability in the raw markdown or they were accidental, but I think they can be eliminated.

Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>

On 9/29/2022 9:53 PM, gua.guo@intel.com wrote:
> From: Gua Guo <gua.guo@intel.com>
> 
> In order to collect code coverage after running executable file, 
> generate *.gcda and *.gcno file that require by lcov tool to generate 
> code coverage report.
> 
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> Cc: Michael Kubacki <mikuback@linux.microsoft.com>
> Signed-off-by: Gua Guo <gua.guo@intel.com>
> ---
>   UnitTestFrameworkPkg/ReadMe.md                | 37 +++++++++++++++++--
>   .../UnitTestFrameworkPkg.ci.yaml              |  2 +
>   .../UnitTestFrameworkPkgHost.dsc.inc          |  3 +-
>   3 files changed, 38 insertions(+), 4 deletions(-)
> 
> diff --git a/UnitTestFrameworkPkg/ReadMe.md 
> b/UnitTestFrameworkPkg/ReadMe.md index e696412cb3..c00e2411f8 100644
> --- a/UnitTestFrameworkPkg/ReadMe.md
> +++ b/UnitTestFrameworkPkg/ReadMe.md
> @@ -60,7 +60,7 @@ you should be good to go.
>   
> 
>   See this example in 'SampleUnitTestUefiShell.inf'...
> 
>   
> 
> -```
> 
> +```inf
> 
>   [Packages]
> 
>     MdePkg/MdePkg.dec
> 
>   
> 
> @@ -75,7 +75,7 @@ See this example in 'SampleUnitTestUefiShell.inf'...
>   Also, if you want you test to automatically be picked up by the Test 
> Runner plugin, you will need
> 
>   to make sure that the module `BASE_NAME` contains the word `Test`...
> 
>   
> 
> -```
> 
> +```inf
> 
>   [Defines]
> 
>     BASE_NAME      = SampleUnitTestUefiShell
> 
>   ```
> 
> @@ -361,7 +361,7 @@ RUNNING TEST SUITE: Int Safe Conversions Test Suite
>   ```
> 
>   
> 
>   You can also, if you are so inclined, read the output from the exact 
> instance of the test that was run during
> 
> -`stuart_ci_build`. The ouput file can be found on a path that looks like:
> 
> +`stuart_ci_build`. The output file can be found on a path that looks like:
> 
>   
> 
>   
> `Build/<Package>/HostTest/<Arch>/<TestName>.<TestSuiteName>.<Arch>.res
> ult.xml`
> 
>   
> 
> @@ -399,6 +399,37 @@ CMOCKA_XML_FILE=<absolute or relative path to 
> output file>
>   
> 
>   This mode is used by the test running plugin to aggregate the results for CI test status reporting in the web view.
> 
>   
> 
> +### Code Coverage
> 
> +
> 
> +Host based Unit Tests will automatically enable coverage data.
> 
> +
> 
> +For Windows, This is primarily leverage for pipeline builds, but this 
> +can be leveraged locally using the
> 
> +OpenCppCoverage windows tool, and pycobertura is used to covert this 
> +coverage data to a human readable HTML
> 
> +file. These tools must be installed to parse code coverage.
> 
> +
> 
> +- Windows Prerequisite
> 
> +  ```bash
> 
> +  Download and install 
> + https://github.com/OpenCppCoverage/OpenCppCoverage/tags
> 
> +  python -m pip install --upgrade -r ./pip-requirements.txt
> 
> +  stuart_ci_build -c .pytool/CISettings.py  -t NOOPT 
> + TOOL_CHAIN_TAG=VS2019 -p MdeModulePkg
> 
> +  Open Build/coverage.html
> 
> +  ```
> 
> +
> 
> +
> 
> +For Linux, This is primarily leveraged for pipeline builds, but this 
> +can be leveraged locally using the
> 
> +lcov linux tool, and parsed using the lcov_cobertura python tool. 
> +pycobertura is used to
> 
> +covert this coverage data to a human readable HTML file. These tools 
> +must be installed
> 
> +to parse code coverage.
> 
> +
> 
> +- Linux Prerequisite
> 
> +  ```bash
> 
> +  sudo apt-get install -y lcov
> 
> +  python -m pip install --upgrade -r ./pip-requirements.txt
> 
> +  stuart_ci_build -c .pytool/CISettings.py  -t NOOPT 
> + TOOL_CHAIN_TAG=GCC5 -p MdeModulePkg
> 
> +  Open Build/coverage.html
> 
> +  ```
> 
> +
> 
> +
> 
>   ### Important Note
> 
>   
> 
>   This works on both Windows and Linux, but is currently limited to 
> x64 architectures. Working on getting others, but we
> 
> diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.ci.yaml 
> b/UnitTestFrameworkPkg/UnitTestFrameworkPkg.ci.yaml
> index 77d51e1348..f68882e1cf 100644
> --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.ci.yaml
> +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkg.ci.yaml
> @@ -90,6 +90,8 @@
>               "pytools",
> 
>               "NOFAILURE",
> 
>               "cmockery",
> 
> +            "cobertura",
> 
> +            "pycobertura",
> 
>               "DHAVE", # build flag for cmocka in the INF
> 
>               "corthon",      # Contact GitHub account in Readme
> 
>               "mdkinney",     # Contact GitHub account in Readme
> 
> diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc 
> b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc
> index 4dd8d4ac67..ca46b8513a 100644
> --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc
> +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc
> @@ -25,7 +25,8 @@
>     GCC:*_*_*_CC_FLAGS   = -D UNIT_TESTING_DEBUG=1
> 
>     XCODE:*_*_*_CC_FLAGS = -D UNIT_TESTING_DEBUG=1
> 
>   !endif
> 
> -
> 
> +  GCC:*_GCC5_*_CC_FLAGS = --coverage
> 
> +  GCC:*_GCC5_*_DLINK_FLAGS = --coverage
> 
>   [BuildOptions.common.EDKII.HOST_APPLICATION]
> 
>     #
> 
>     # MSFT
> 

  reply	other threads:[~2022-12-21  3:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-30  1:53 [PATCH 0/3] Add code coverage support for GCC Guo, Gua
2022-09-30  1:53 ` [PATCH 1/3] UnitTestFrameworkPkg: " Guo, Gua
2022-12-21  3:41   ` Michael Kubacki
2022-12-21  3:53     ` Guo, Gua [this message]
2022-12-21  3:58       ` Michael Kubacki
2022-12-21  4:02         ` Guo, Gua
2022-09-30  1:53 ` [PATCH 2/3] BaseTools/Plugin: Add coverage support for Unit Test Guo, Gua
2022-12-21  3:42   ` [edk2-devel] " Michael Kubacki
2022-09-30  1:53 ` [PATCH 3/3] .azurepipelines: Install code coverage tool Guo, Gua
2022-12-21  3:42   ` [edk2-devel] " Michael Kubacki
2022-12-21  6:35     ` Guo, Gua

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=BL1PR11MB547887C3E48B6E9E1BF78EC3EFEB9@BL1PR11MB5478.namprd11.prod.outlook.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