I'm attempting to generate a coverage report using the lcov.perl
files in my project. I have all the necessary lcov.perl
, geninfo.perl
, genhtml.perl
, and repl.bat
files stored in one folder. In my .bat
scripting, I'm setting the path to the .perl
files in the LCOV_PERL_SCIRPT_DIR
variable like this: C:\USER\a\b\c
.
Here's a snippet of my script:
cmake -G "Unix Makefiles" -D "CMAKE_MAKE_PROGRAM:PATH=!MAKE_BIN!/make.exe" -B debug -DCMAKE_BUILD_TYPE=Debug .
copy linker\*.ld debug
cmake --build debug -j4
cd debug
cppunittest.exe -ojunit
cd debug
mkdir runs
move *.xml runs/
cd ..
cd debug\CMakeFiles\cppunittest.dir
set "filename=gcov"
set "LCOV_PERL_SCIRPT_DIR=!LCOV_PERL_SCIRPT_DIR:/=\%!"
echo "LCOV_PERL_SCIRPT_DIR=!LCOV_PERL_SCIRPT_DIR!"
"!LCOV_PERL_SCIRPT_DIR!/lcov.perl" -b . -d . -c -o "!filename!.info"
echo test1
type "!filename!.info" | call "!LCOV_PERL_SCIRPT_DIR!/repl.bat" ^
"!CUR_BAT_SCRIPT_DIR!/debug/CMakeFiles/cppunittest.dir/" "" L B E > "!filename!.info.tmp"
echo test2
type "!filename!.info.tmp" | call "!LCOV_PERL_SCIRPT_DIR!/repl.bat" "\" "/" >"!filename!.info1.tmp"
echo test2
move /y "!filename!.info1.tmp" "!filename!.info" >nul
echo test3
"!LCOV_PERL_SCIRPT_DIR!/genhtml.perl" "!filename!.info" --output-directory out
cd ../../..
I can see that XML files are generated, but I'm encountering the following error:
"libgcov profiling error
libgcov profiling error: C:\Users\a\b\c\d\test\unit\common_io\adc\debug/CMakeFiles/cppunittest.dir/C_/Users/JhaRagha/projects/mcu_build_script/mcu_firmware/platform-bsp/source/common_io/adc/src/iot_adc.c.gcda: overwriting an existing profile data with a different timestamp
A subdirectory or file runs already exists.
C:\Users\a\b\c\d\test\unit\common_io\adc\debug\cpputest_AdcTestGroup.xml
1 file(s) moved.
"LCOV_PERL_SCIRPT_DIR=C:\Users\a\b\c\d\..\platform-bsp\toolchain\scripts\win_cpputest"
Capturing coverage data from .
C:\Users\a\b\c\d\toolchain\scripts\win_cpputest/geninfo.perl . --output-filename gcov.info --base-directory .Found gcov version: 9.2.0
Scanning . for .gcda files ...
geninfo.perl: Can't cd to ../../../../../../../../../../../.. from ./C_/Users/a/b/c/mcu_firmware/d/test/unit/common_io/build/source: No such file or directory at C:/Strawberry/perl/lib/File/Find.pm line 477.
test1
test2
C:\Users\a\b\c\d\toolchain\scripts\win_cpputest\repl.bat(279, 1) Microsoft JScript runtime error: Syntax error in regular expression
test2
test3
Reading data file gcov.info
genhtml.perl: ERROR: no valid records found in tracefile gcov.info
A subdirectory or file results already exists.
The system cannot find the file specified.
Access is denied.
I also tried to manually change directories using cd ../../../../../../../../../../../..
from from ./C_/Users/JhaRagha/projects/mcu_build_script/mcu_firmware/platform-bsp/test/unit/common_io/build/source
and was able to get back successfully.
I'm unsure how to resolve these errors.
Answers
It looks like you're encountering several issues with your script:
-
Overwriting existing profile data with a different timestamp: This error typically occurs when the .gcda files have been overwritten or modified. It seems like there might be multiple instances of the same .gcda file being generated with different timestamps. Ensure that only one instance of each .gcda file is being generated during the build process.
-
Can't cd to ../../../../../../../../../../../.. from ./C_/Users/a/b/c/mcu_firmware/d/test/unit/common_io/build/source: This error suggests that the script is unable to change directories to the specified path. Make sure that the path specified in the geninfo.perl command is correct and accessible from the current directory.
-
Syntax error in regular expression: This error indicates a syntax error in the repl.bat script. It's possible that the regular expression used in the script is incorrect or malformed. You may need to review the repl.bat script and ensure that the regular expression is valid.
-
ERROR: no valid records found in tracefile gcov.info: This error occurs when genhtml.perl cannot find valid records in the gcov.info file. Make sure that the gcov.info file is being generated correctly by the geninfo.perl command.
To resolve these issues, I would suggest the following steps:
- Double-check the build process to ensure that only one instance of each .gcda file is being generated.
- Verify that the paths specified in the script are correct and accessible.
- Review the repl.bat script for any syntax errors in the regular expression.
- Check the output of the geninfo.perl command to ensure that the gcov.info file is being generated properly.
By addressing these issues, you should be able to generate the coverage report successfully. If you continue to encounter errors, consider debugging the script step by step to identify the specific cause of each issue.