* [PATCH] UnitTestFrameworkPkg: Add code coverage support for GCC @ 2022-09-13 13:24 Guo, Gua 2022-09-13 13:28 ` Guo, Gua 2022-09-13 15:10 ` Michael D Kinney 0 siblings, 2 replies; 6+ messages in thread From: Guo, Gua @ 2022-09-13 13:24 UTC (permalink / raw) To: devel Cc: Gua Guo, Michael D Kinney, Sean Brogan, Bret Barkelew, Michael Kubacki 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/UnitTestFrameworkPkgHost.dsc.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc index 4dd8d4ac67..8623aecb33 100644 --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc @@ -19,7 +19,7 @@ MemoryAllocationLib|UnitTestFrameworkPkg/Library/Posix/MemoryAllocationLibPosix/MemoryAllocationLibPosix.inf [BuildOptions] - GCC:*_*_*_CC_FLAGS = -fno-pie + GCC:*_*_*_CC_FLAGS = -fno-pie -ftest-coverage -fprofile-arcs !ifdef $(UNIT_TESTING_DEBUG) MSFT:*_*_*_CC_FLAGS = -D UNIT_TESTING_DEBUG=1 GCC:*_*_*_CC_FLAGS = -D UNIT_TESTING_DEBUG=1 -- 2.31.1.windows.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] UnitTestFrameworkPkg: Add code coverage support for GCC 2022-09-13 13:24 [PATCH] UnitTestFrameworkPkg: Add code coverage support for GCC Guo, Gua @ 2022-09-13 13:28 ` Guo, Gua 2022-09-13 15:11 ` Michael D Kinney 2022-09-13 15:10 ` Michael D Kinney 1 sibling, 1 reply; 6+ messages in thread From: Guo, Gua @ 2022-09-13 13:28 UTC (permalink / raw) To: devel@edk2.groups.io Cc: Kinney, Michael D, Sean Brogan, Barkelew, Bret, Michael Kubacki Hi All I want to follow below steps to generate code coverage data based the default build. But I notice currently GCC compiler flags won't generate *gcda and *.gcno. So add the CC flags to generate necessary data that require by "lcov" tool. I'm not sure whether have any concern to add the flags by default. Step1. sudo apt-get install lcov Step2. stuart_ci_build -c .pytool/CISettings.py -p MdePkg -t NOOPT -a IA32,X64 TOOL_CHAIN_TAG=GCC5 --verbose Step3. lcov -c --rc lcov_branch_coverage=1 -o UnitTest.info -d Build/MdePkg/HostTest/NOOPT_GCC5/X64/MdePkg/ Step4. genhtml UnitTest.info --branch-coverage -o .Build/UnitTestReport Step5. Open "Build/UnitTestReport/index.html" Thanks, Gua -----Original Message----- From: Guo, Gua <gua.guo@intel.com> Sent: Tuesday, September 13, 2022 9:24 PM To: devel@edk2.groups.io Cc: Guo, Gua <gua.guo@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Sean Brogan <sean.brogan@microsoft.com>; Barkelew, Bret <bret.barkelew@microsoft.com>; Michael Kubacki <mikuback@linux.microsoft.com> Subject: [PATCH] UnitTestFrameworkPkg: Add code coverage support for GCC 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/UnitTestFrameworkPkgHost.dsc.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc index 4dd8d4ac67..8623aecb33 100644 --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc @@ -19,7 +19,7 @@ MemoryAllocationLib|UnitTestFrameworkPkg/Library/Posix/MemoryAllocationLibPosix/MemoryAllocationLibPosix.inf [BuildOptions]- GCC:*_*_*_CC_FLAGS = -fno-pie+ GCC:*_*_*_CC_FLAGS = -fno-pie -ftest-coverage -fprofile-arcs !ifdef $(UNIT_TESTING_DEBUG) MSFT:*_*_*_CC_FLAGS = -D UNIT_TESTING_DEBUG=1 GCC:*_*_*_CC_FLAGS = -D UNIT_TESTING_DEBUG=1-- 2.31.1.windows.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] UnitTestFrameworkPkg: Add code coverage support for GCC 2022-09-13 13:28 ` Guo, Gua @ 2022-09-13 15:11 ` Michael D Kinney 2022-09-13 15:19 ` Guo, Gua 0 siblings, 1 reply; 6+ messages in thread From: Michael D Kinney @ 2022-09-13 15:11 UTC (permalink / raw) To: Guo, Gua, devel@edk2.groups.io, Kinney, Michael D Cc: Sean Brogan, Barkelew, Bret, Michael Kubacki Is there a Visual Studio Code plugin to view the code coverage too? Thanks, Mike > -----Original Message----- > From: Guo, Gua <gua.guo@intel.com> > Sent: Tuesday, September 13, 2022 6:28 AM > To: 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>; Michael Kubacki <mikuback@linux.microsoft.com> > Subject: RE: [PATCH] UnitTestFrameworkPkg: Add code coverage support for GCC > > Hi All > > I want to follow below steps to generate code coverage data based the default build. But I notice currently GCC compiler flags won't > generate *gcda and *.gcno. > So add the CC flags to generate necessary data that require by "lcov" tool. > > I'm not sure whether have any concern to add the flags by default. > > Step1. sudo apt-get install lcov > Step2. stuart_ci_build -c .pytool/CISettings.py -p MdePkg -t NOOPT -a IA32,X64 TOOL_CHAIN_TAG=GCC5 --verbose > Step3. lcov -c --rc lcov_branch_coverage=1 -o UnitTest.info -d Build/MdePkg/HostTest/NOOPT_GCC5/X64/MdePkg/ > Step4. genhtml UnitTest.info --branch-coverage -o .Build/UnitTestReport > Step5. Open "Build/UnitTestReport/index.html" > > Thanks, > Gua > > -----Original Message----- > From: Guo, Gua <gua.guo@intel.com> > Sent: Tuesday, September 13, 2022 9:24 PM > To: devel@edk2.groups.io > Cc: Guo, Gua <gua.guo@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Sean Brogan <sean.brogan@microsoft.com>; Barkelew, > Bret <bret.barkelew@microsoft.com>; Michael Kubacki <mikuback@linux.microsoft.com> > Subject: [PATCH] UnitTestFrameworkPkg: Add code coverage support for GCC > > 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/UnitTestFrameworkPkgHost.dsc.inc | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc > index 4dd8d4ac67..8623aecb33 100644 > --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc > +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc > @@ -19,7 +19,7 @@ > MemoryAllocationLib|UnitTestFrameworkPkg/Library/Posix/MemoryAllocationLibPosix/MemoryAllocationLibPosix.inf [BuildOptions]- > GCC:*_*_*_CC_FLAGS = -fno-pie+ GCC:*_*_*_CC_FLAGS = -fno-pie -ftest-coverage -fprofile-arcs !ifdef $(UNIT_TESTING_DEBUG) > MSFT:*_*_*_CC_FLAGS = -D UNIT_TESTING_DEBUG=1 GCC:*_*_*_CC_FLAGS = -D UNIT_TESTING_DEBUG=1-- > 2.31.1.windows.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] UnitTestFrameworkPkg: Add code coverage support for GCC 2022-09-13 15:11 ` Michael D Kinney @ 2022-09-13 15:19 ` Guo, Gua 0 siblings, 0 replies; 6+ messages in thread From: Guo, Gua @ 2022-09-13 15:19 UTC (permalink / raw) To: Kinney, Michael D, devel@edk2.groups.io Cc: Sean Brogan, Barkelew, Bret, Michael Kubacki [-- Attachment #1.1: Type: text/plain, Size: 4358 bytes --] Yes, we can install gcov viewer on vscode. [cid:image001.png@01D8C7C7.45B07080] [cid:image002.png@01D8C7C7.45B07080] Thanks, Gua -----Original Message----- From: Kinney, Michael D <michael.d.kinney@intel.com> Sent: Tuesday, September 13, 2022 11:12 PM To: Guo, Gua <gua.guo@intel.com>; devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com> Cc: Sean Brogan <sean.brogan@microsoft.com>; Barkelew, Bret <bret.barkelew@microsoft.com>; Michael Kubacki <mikuback@linux.microsoft.com> Subject: RE: [PATCH] UnitTestFrameworkPkg: Add code coverage support for GCC Is there a Visual Studio Code plugin to view the code coverage too? Thanks, Mike > -----Original Message----- > From: Guo, Gua <gua.guo@intel.com<mailto:gua.guo@intel.com>> > Sent: Tuesday, September 13, 2022 6:28 AM > To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> > Cc: Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>; Sean Brogan > <sean.brogan@microsoft.com<mailto:sean.brogan@microsoft.com>>; Barkelew, Bret > <bret.barkelew@microsoft.com<mailto:bret.barkelew@microsoft.com>>; Michael Kubacki > <mikuback@linux.microsoft.com<mailto:mikuback@linux.microsoft.com>> > Subject: RE: [PATCH] UnitTestFrameworkPkg: Add code coverage support > for GCC > > Hi All > > I want to follow below steps to generate code coverage data based the > default build. But I notice currently GCC compiler flags won't generate *gcda and *.gcno. > So add the CC flags to generate necessary data that require by "lcov" tool. > > I'm not sure whether have any concern to add the flags by default. > > Step1. sudo apt-get install lcov > Step2. stuart_ci_build -c .pytool/CISettings.py -p MdePkg -t NOOPT -a > IA32,X64 TOOL_CHAIN_TAG=GCC5 --verbose Step3. lcov -c --rc > lcov_branch_coverage=1 -o UnitTest.info -d > Build/MdePkg/HostTest/NOOPT_GCC5/X64/MdePkg/ > Step4. genhtml UnitTest.info --branch-coverage -o > .Build/UnitTestReport Step5. Open "Build/UnitTestReport/index.html" > > Thanks, > Gua > > -----Original Message----- > From: Guo, Gua <gua.guo@intel.com<mailto:gua.guo@intel.com>> > Sent: Tuesday, September 13, 2022 9:24 PM > To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> > Cc: Guo, Gua <gua.guo@intel.com<mailto:gua.guo@intel.com>>; Kinney, Michael D > <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>; Sean Brogan <sean.brogan@microsoft.com<mailto:sean.brogan@microsoft.com>>; > Barkelew, Bret <bret.barkelew@microsoft.com<mailto:bret.barkelew@microsoft.com>>; Michael Kubacki > <mikuback@linux.microsoft.com<mailto:mikuback@linux.microsoft.com>> > Subject: [PATCH] UnitTestFrameworkPkg: Add code coverage support for > GCC > > From: Gua Guo <gua.guo@intel.com<mailto: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<mailto:michael.d.kinney@intel.com>> > Cc: Sean Brogan <sean.brogan@microsoft.com<mailto:sean.brogan@microsoft.com>> > Cc: Bret Barkelew <Bret.Barkelew@microsoft.com<mailto:Bret.Barkelew@microsoft.com>> > Cc: Michael Kubacki <mikuback@linux.microsoft.com<mailto:mikuback@linux.microsoft.com>> > Signed-off-by: Gua Guo <gua.guo@intel.com<mailto:gua.guo@intel.com>> > --- > UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc > b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc > index 4dd8d4ac67..8623aecb33 100644 > --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc > +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc > @@ -19,7 +19,7 @@ > > MemoryAllocationLib|UnitTestFrameworkPkg/Library/Posix/MemoryAllocationLibPosix/MemoryAllocationLibPosix.inf [BuildOptions]- GCC:*_*_*_CC_FLAGS = -fno-pie+ GCC:*_*_*_CC_FLAGS = -fno-pie -ftest-coverage -fprofile-arcs !ifdef $(UNIT_TESTING_DEBUG) > MSFT:*_*_*_CC_FLAGS = -D UNIT_TESTING_DEBUG=1 GCC:*_*_*_CC_FLAGS = -D UNIT_TESTING_DEBUG=1-- > 2.31.1.windows.1 [-- Attachment #1.2: Type: text/html, Size: 11363 bytes --] [-- Attachment #2: image001.png --] [-- Type: image/png, Size: 110115 bytes --] [-- Attachment #3: image002.png --] [-- Type: image/png, Size: 150539 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] UnitTestFrameworkPkg: Add code coverage support for GCC 2022-09-13 13:24 [PATCH] UnitTestFrameworkPkg: Add code coverage support for GCC Guo, Gua 2022-09-13 13:28 ` Guo, Gua @ 2022-09-13 15:10 ` Michael D Kinney 2022-09-13 15:20 ` Guo, Gua 1 sibling, 1 reply; 6+ messages in thread From: Michael D Kinney @ 2022-09-13 15:10 UTC (permalink / raw) To: Guo, Gua, devel@edk2.groups.io, Kinney, Michael D Cc: Sean Brogan, Barkelew, Bret, Michael Kubacki Hi, This change looks safe because it is scoped to host-based unit tests that include this file in the DSC file that builds host-based tests. Can you also update the UnitTestFrameworkPkg/ReadMe.md to describe how a developer can enable/use the code coverage feature for GCC host-based tests? Mike > -----Original Message----- > From: Guo, Gua <gua.guo@intel.com> > Sent: Tuesday, September 13, 2022 6:24 AM > To: devel@edk2.groups.io > Cc: Guo, Gua <gua.guo@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Sean Brogan <sean.brogan@microsoft.com>; Barkelew, > Bret <bret.barkelew@microsoft.com>; Michael Kubacki <mikuback@linux.microsoft.com> > Subject: [PATCH] UnitTestFrameworkPkg: Add code coverage support for GCC > > 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/UnitTestFrameworkPkgHost.dsc.inc | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc > index 4dd8d4ac67..8623aecb33 100644 > --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc > +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc > @@ -19,7 +19,7 @@ > MemoryAllocationLib|UnitTestFrameworkPkg/Library/Posix/MemoryAllocationLibPosix/MemoryAllocationLibPosix.inf > > > > [BuildOptions] > > - GCC:*_*_*_CC_FLAGS = -fno-pie > > + GCC:*_*_*_CC_FLAGS = -fno-pie -ftest-coverage -fprofile-arcs > > !ifdef $(UNIT_TESTING_DEBUG) > > MSFT:*_*_*_CC_FLAGS = -D UNIT_TESTING_DEBUG=1 > > GCC:*_*_*_CC_FLAGS = -D UNIT_TESTING_DEBUG=1 > > -- > 2.31.1.windows.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] UnitTestFrameworkPkg: Add code coverage support for GCC 2022-09-13 15:10 ` Michael D Kinney @ 2022-09-13 15:20 ` Guo, Gua 0 siblings, 0 replies; 6+ messages in thread From: Guo, Gua @ 2022-09-13 15:20 UTC (permalink / raw) To: Kinney, Michael D, devel@edk2.groups.io Cc: Sean Brogan, Barkelew, Bret, Michael Kubacki Sure, thanks for replying quickly, let me update readme.md file in my next patch. -----Original Message----- From: Kinney, Michael D <michael.d.kinney@intel.com> Sent: Tuesday, September 13, 2022 11:10 PM To: Guo, Gua <gua.guo@intel.com>; devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com> Cc: Sean Brogan <sean.brogan@microsoft.com>; Barkelew, Bret <bret.barkelew@microsoft.com>; Michael Kubacki <mikuback@linux.microsoft.com> Subject: RE: [PATCH] UnitTestFrameworkPkg: Add code coverage support for GCC Hi, This change looks safe because it is scoped to host-based unit tests that include this file in the DSC file that builds host-based tests. Can you also update the UnitTestFrameworkPkg/ReadMe.md to describe how a developer can enable/use the code coverage feature for GCC host-based tests? Mike > -----Original Message----- > From: Guo, Gua <gua.guo@intel.com> > Sent: Tuesday, September 13, 2022 6:24 AM > To: devel@edk2.groups.io > Cc: Guo, Gua <gua.guo@intel.com>; Kinney, Michael D > <michael.d.kinney@intel.com>; Sean Brogan <sean.brogan@microsoft.com>; > Barkelew, Bret <bret.barkelew@microsoft.com>; Michael Kubacki > <mikuback@linux.microsoft.com> > Subject: [PATCH] UnitTestFrameworkPkg: Add code coverage support for > GCC > > 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/UnitTestFrameworkPkgHost.dsc.inc | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc > b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc > index 4dd8d4ac67..8623aecb33 100644 > --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc > +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc > @@ -19,7 +19,7 @@ > > MemoryAllocationLib|UnitTestFrameworkPkg/Library/Posix/MemoryAllocatio > nLibPosix/MemoryAllocationLibPosix.inf > > > > [BuildOptions] > > - GCC:*_*_*_CC_FLAGS = -fno-pie > > + GCC:*_*_*_CC_FLAGS = -fno-pie -ftest-coverage -fprofile-arcs > > !ifdef $(UNIT_TESTING_DEBUG) > > MSFT:*_*_*_CC_FLAGS = -D UNIT_TESTING_DEBUG=1 > > GCC:*_*_*_CC_FLAGS = -D UNIT_TESTING_DEBUG=1 > > -- > 2.31.1.windows.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-09-13 15:21 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-09-13 13:24 [PATCH] UnitTestFrameworkPkg: Add code coverage support for GCC Guo, Gua 2022-09-13 13:28 ` Guo, Gua 2022-09-13 15:11 ` Michael D Kinney 2022-09-13 15:19 ` Guo, Gua 2022-09-13 15:10 ` Michael D Kinney 2022-09-13 15:20 ` Guo, Gua
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox