Can run opencppcoverage without source code?

Jul 11, 2016 at 2:01 PM
Hi,

OpenCppCoverage is a great tool for windows program code coverage, I have a problem:

I'd like to deploy program and *.pdb on test machine only, and don't copy source code to target machine since it is a security issue. Can I run OpenCppCoverage+program with pdb only, and after exit program, copy something to source code and generate html report like gcov?

Can I archive it?

Thanks
Jul 11, 2016 at 8:38 PM
Have you tried it?

You can output a cobertura xml file, which would be what I would try. Since it works with breakpoints, I see no reason why it shouldn't work, even though I don't know all the details...
Jul 12, 2016 at 1:29 AM
atlaste wrote:
Have you tried it?

You can output a cobertura xml file, which would be what I would try. Since it works with breakpoints, I see no reason why it shouldn't work, even though I don't know all the details...
I already tried this way, but looks it does not work. I think you are working with VS plugin, so can get source code.
Jul 12, 2016 at 8:45 AM
stingyu wrote:
I already tried this way, but looks it does not work.
Works fine here. Just tested it (without source code):

"c:\Program Files\OpenCppCoverage\OpenCppCoverage.exe" --export_type cobertura:cobertura.xml --continue_after_cpp_exception --cover_children -- "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" /Platform:x64 MinimumTest.dll

The HTML outputter obviously loads the files so it can generate the highlighted code. Cobertura files can be read by gcov iirc. At some point you probably still need the source code though; PDB files don't include this.
I think you are working with VS plugin, so can get source code.
Not sure what you mean with this; I built a VS plugin.. it's a different, unrelated story.
Jul 12, 2016 at 10:21 AM
Thank you very much, it can reach my requirement,

C:\tools>opencppcoverage --export_type=cobertura:a1.xml -- mytest.exe

<class name="MyTest" filename="c:\workspace\src\sink.cpp" line-rate="0.067278287461773695">
      <lines>
        <line number="17" hits="1"/>
        <line number="18" hits="1"/>
        <line number="19" hits="1"/>
        <line number="20" hits="1"/>
        <line number="26" hits="1"/>
        <line number="29" hits="0"/>
        <line number="37" hits="0"/>
........

I like it.
Coordinator
Jul 13, 2016 at 8:43 PM
Hello,

As an alternative, you can try the following command:
OpenCppCoverage --sources YourFilter --export_type=binary:test.cov -- YOUR_PROGRAM
It generates a file test.cov that contains the coverage data. Copy this file on the computer where you compile your program (Or another computer with the same source location) and run:
OpenCppCoverage --input_coverage test.cov
It generates the HTML report.

Hope that help,

OpenCppCoverage
Jul 15, 2016 at 8:47 AM
Edited Jul 15, 2016 at 8:50 AM
Thanks,

One more question here,

1.Compile my program on computer A, source code location is c:\workspace\src1
2.Copy program on computer B, and run it with
OpenCppCoverage --export_type=binary:c:\test_data\data.cov -- PROGRAM
3.Copy data.cov on computer C, and check out source code on C, but location is c:\workspace\src2, use following command:
OpenCppCoverage --sources=c:\workspace\src2 --input_coverage data.cov --export_type html:c:\my_report
In html report, it shows source file does not exist.

So, on computer C, source code location must be same as compiling location, and option "--sources" can't resolve this problem, right?
Coordinator
Jul 19, 2016 at 7:46 PM
Edited Jul 19, 2016 at 7:58 PM
Hello,

Yes, source files on computer C should be at the same location as on computer A. "--sources" defines which source files should be included in the coverage not source location.

You can try to use folder shortcut to have the same path (not tested).
Perhaps this link can also help: https://msdn.microsoft.com/en-us/library/ms680641.aspx

Let me know if you find something.


OpenCppCoverage
Jul 25, 2016 at 1:01 AM
Got it, thanks again.
Marked as answer by OpenCppCoverage on 8/19/2016 at 7:29 AM