Llvm-cov coverage report can not be parsed

  • SonarQube 9.9 Enterprise, CFamily plugin

I am trying to add the llvm-cov coverage data to the SonarQube analysis but there is an error when the scanner tries to parse the .txt file.

...
ERROR: Error during SonarScanner execution
17:34:53  java.nio.file.InvalidPathException: Trailing char < > at index 241: Com\Config\source\Configuration.cpp                                                        6                 3    50.00%           6                 3    50.00%          15                 7    53.33%           0                 0         
17:34:53  	at java.base/sun.nio.fs.WindowsPathParser.normalize(Unknown Source)
17:34:53  	at java.base/sun.nio.fs.WindowsPathParser.parse(Unknown Source)
17:34:53  	at java.base/sun.nio.fs.WindowsPathParser.parse(Unknown Source)
17:34:53  	at java.base/sun.nio.fs.WindowsPath.parse(Unknown Source)
17:34:53  	at java.base/sun.nio.fs.WindowsFileSystem.getPath(Unknown Source)
17:34:53  	at java.base/java.io.File.toPath(Unknown Source)
17:34:53  	at org.sonar.api.scan.filesystem.PathResolver.relativePath(PathResolver.java:121)
17:34:53  	at org.sonar.api.batch.fs.internal.predicates.AbsolutePathPredicate.get(AbsolutePathPredicate.java:51)
17:34:53  	at org.sonar.api.batch.fs.internal.predicates.AndPredicate.get(AndPredicate.java:87)
17:34:53  	at org.sonar.api.batch.fs.internal.DefaultFileSystem.inputFiles(DefaultFileSystem.java:140)
17:34:53  	at org.sonar.scanner.scan.filesystem.MutableFileSystem.inputFiles(MutableFileSystem.java:45)
17:34:53  	at org.sonar.api.batch.fs.internal.DefaultFileSystem.inputFile(DefaultFileSystem.java:110)
17:34:53  	at org.sonar.scanner.scan.filesystem.MutableFileSystem.inputFile(MutableFileSystem.java:53)
17:34:53  	at com.sonar.cpp.plugin.llvmcov.LLVMCovSensor.lambda$execute$1(LLVMCovSensor.java:63)
17:34:53  	at com.sonar.cpp.plugin.llvmcov.LLVMCovSensor$LineConsumer.consume(LLVMCovSensor.java:182)
17:34:53  	at com.sonar.cpp.plugin.llvmcov.LLVMCovSensor$LineConsumer.accept(LLVMCovSensor.java:125)
17:34:53  	at com.sonar.cpp.plugin.llvmcov.LLVMCovSensor$LineConsumer.accept(LLVMCovSensor.java:94)
17:34:53  	at java.base/java.util.Iterator.forEachRemaining(Unknown Source)
17:34:53  	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
17:34:53  	at java.base/java.util.stream.ReferencePipeline$Head.forEachOrdered(Unknown Source)
17:34:53  	at com.sonar.cpp.plugin.llvmcov.LLVMCovSensor.read(LLVMCovSensor.java:87)
17:34:53  	at com.sonar.cpp.plugin.llvmcov.LLVMCovSensor.execute(LLVMCovSensor.java:61)

I can share the coverage data file per PM.

thx!

Hi,

Can we have at least a few lines leading up to the error, if not the full analysis log?

 
Ann

Hi Peter,

It seems that your coverage report ends at line 218, and I don’t spot anything odd in it off-hand. I’m going to call for more expert eyes.

 
Ann

I assume that the “at index 241” part of the error message refers to the character in the line for the mentioned file. There is a “-” but i assume that this should be valid input.

thx,
Peter

Hi,

:woman_facepalming:

Okay well, the -s in the Cover column did catch my eye, but I was too busy looking for line 241 to pursue that. I expect that’s the problem. Could you try converting them all to “0.00%” and trying again?

 
Ann

Of course i could modify the coverage file but i ran the commands as in the example linux-cmake-llvm-cov-gh-actions-sc/build.yml at main · sonarsource-cfamily-examples/linux-cmake-llvm-cov-gh-actions-sc · GitHub so i would expect that the file is valid. I could not find any specification of the format though.

g,
Peter

Hi Peter,

I understand that you’re using our example. And I’m trying to pinpoint the problem. Could you try again with an edited file so we understand if the problem is how we parse those dashes or if it’s something else?

 
Thx,
Ann

Hi Ann,

i tried it out with 0.00% instead of -: there is no error but also no coverage information in SQ (0.0% overall).
Maybe there is something else wrong with the file/format?

[2023-03-28T08:42:56.076Z] INFO: Sensor llvm-cov [cpp]
[2023-03-28T08:42:56.076Z] INFO: Parsing D:\slave\workspace\ture_migration-2\build\reports\coverage\index_sonarqube.txt
[2023-03-28T08:42:56.076Z] INFO: Sensor llvm-cov [cpp] (done) | time=10ms

g,
Peter

Puzzle solved, my fault, sorry for the noise:
Instead of using the stdout of llvm-cov show like in the example, i used --format=text to produce the file. In Can't get llvm-cov reports to show up in SonarQube project - #3 by amshelley86 i found a snippet of such a correctly formatted coverage file.
I could not find any documentation regarding the format, neither in the LLVM nor in the SonarQube docs …

thx,
Peter

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.