This project is read-only.

Is there any way to find the coverage of my DLL when loaded via COM from .net

Mar 23, 2015 at 5:33 PM
I know, it's a pretty unusual request for a C++ coverage tool. I ran my Google Tests under OpenCppCoverage and they just worked, so then I started on the more unrealistic stuff...

I've got some COM objects in a native DLL, loaded (with an app manifest) from a .net assembly running under nunit-console, and I was wondering if there's any way I can get the coverage of the C++ native DLL.

I have some test cases in Google Test that use methods dllexported from the DLL and I can get their coverage fine, and it would be great if I could get the coverage as the COM methods are called - but that's done from .net.

The debug log doesn't show any of the .net assemblies being loaded, so I guess that OpenCppCoverage doesn't get a notification for them or the DLL being opened via COM.
Mar 24, 2015 at 10:14 AM
Ah, at least part of the problem is that the default mode for nunit-console is to spawn another process, nunit-agent.
I'll look into this some more.
Mar 24, 2015 at 2:08 PM
Using NUnit-lite, which makes the test suite into an exe without any of the new-process-spawning or .net-framework-version-mismatch problems, I was able to get OpenCppCoverage to attach to the C++ DLL being loaded for COM.
I got lots of [debug] Debug event:8, which it seems from miniwinbase.h is the DLL doing an OutputDebugString, and I saw the NUnit-lite summary of the tests having passed, but at the point where the coverage is gathered I got:
"Error: ExecutedAddressManager.cpp:144 Address should be register first"

I tried building OpenCppCoverage from source under VS2013 update 4, but hit a few snags:
Compiler Error C2797 in Wildcards.cpp and StartInfo,cpp
An unresolved external at linking from << in StartInfo
No ctemplate library - at which point I gave up.
Mar 25, 2015 at 12:42 PM
OK, got ctemplate to build. The error in ExecutedAddressManager is coming from CodeCoverageRunner::OnException.
An exception of type 0x80000003 in KernelBase.DebugBreak, (caused by a failing assert in the app that's being covered) causes the coverage to throw the CppCoverageException because it doesn't recognise the address within DebugBreak.

Hopefully if I fix the DbgAssert in the DLL, then OpenCppCoverage will complete
Mar 25, 2015 at 3:26 PM
It works!

TL;DR - Use NUnit-lite and make sure you don't have any failing native ASSERTs in your code under test.
Apr 2, 2015 at 6:58 PM
Thanks for your feedback. It should be fixed in the new release
Now if OpenCppCoverage detects a breakpoint, it will continue and return exit code EXCEPTION_BREAKPOINT (-2147483645) if no other error is detected.

Please let me known if it does not solve your issue.

Sorry for the delay, discussions notification was not activated and Codeplex discussion was disable these last days.

Apr 21, 2015 at 9:52 AM
That fixes it, thanks!
Marked as answer by OpenCppCoverage on 11/15/2015 at 3:35 AM