Hi C.C.
Two changes that I recommend for you. Hope it’s helpful for you.
Below is my test command
1. Change DEBUG to NOOPT
From build -a X64 -b
DEBUG -t GCC -D DISABLE_NEW_DEPRECATED_INTERFACES -p MdePkg/Test/GoogleTest/Library/CustomLibs/HostTestPkg.dsc"
To build -a X64 -b
NOOPT -t GCC -D DISABLE_NEW_DEPRECATED_INTERFACES -p MdePkg/Test/GoogleTest/Library/CustomLibs/HostTestPkg.dsc"
Reason: UnitTest only support NOOPT on Host Application.
2. Change BuildOptions from GCC5 to GCC
Reason: TOOLCHAIN “GCC5” is obsolete, it’s issue for Edk2 side.
Thanks,
Gua
From: Kinney, Michael D <michael.d.kinney@intel.com>
Sent: Wednesday, September 20, 2023 2:10 AM
To: CrossedCarpet <crossedcarpet@hotmail.com>; devel@edk2.groups.io; Guo, Gua <gua.guo@intel.com>
Cc: Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] gTest code coverage
Gua may be able to help.
What error do you get trying to use stuart commands?
Mike
From: CrossedCarpet <crossedcarpet@hotmail.com>
Sent: Tuesday, September 19, 2023 9:45 AM
To: Kinney, Michael D <michael.d.kinney@intel.com>;
devel@edk2.groups.io
Subject: Re: [edk2-devel] gTest code coverage
Thank you for your reply!
Unfortunately, I was aware of that documentation, I quoted it in my original email when asking for help in its interpretation.
I have been using the build system instead of the stuart abstraction. If I try using it in my current setup I get a bug saying my HostTestPkg is unsupported.
Anyhow, I'd love to figure out why isn't the build system generating these gcno and gcda files anymore.
When building my LibraryClasses this is the command that gets run:
"gcc" -o /edk2/edk2/Build/CustomLibs/DEBUG_GCC/X64/GoogleTestStringUtilsLib -m64 -no-pie -Wl,--start-group,@/edk2/edk2/Build/CustomLibs/DEBUG_GCC/X64/MdePkg/Test/GoogleTest/Library/CustomLibs/StringUtils/StringUtils/OUTPUT/static_library_files.lst,--end-group
-lgcov -lpthread -lstdc++ -lm
I have been able to modify it in my own HostTestPkg.dsc with:
[BuildOptions.common.EDKII.HOST_APPLICATION]
GCC:*_GCC5_*_CC_FLAGS = --coverage -fprofile-arcs -ftest-coverage
# or
GCC:*_*_X64_DLINK_FLAGS == -o $(BIN_DIR)/$(MODULE_NAME_GUID) -fprofile-arcs -ftest-coverage -m64 -no-pie
But to no avail, I've only been able to generate weird intermediate files like: GoogleTestStringUtilsLib.ltrans0.ltrans.gcno
This is how I invoke the build command:
build -a X64 -b DEBUG -t GCC -D DISABLE_NEW_DEPRECATED_INTERFACES -p MdePkg/Test/GoogleTest/Library/CustomLibs/HostTestPkg.dsc"
Help is greatly appreciated. I believe I'm overthinking it and the solution is more straightforward than this.
C.C.