C++ Test visual Studio 10.4.1 - Coverage

elchelch Posts: 95

C++ Test visual Studio 10.4.1 - Coverage

Basic Question.
How do I start Coverage task with Parasoft ? Looking for documentation.
Thanks

Best Answers

Answers

  • elchelch Posts: 95

    Hi,

    Where Can I find info on how to do Coverage test on my UT ?
    Or Can I do Coverage on my Integration test using QSPY from QTOOLS.
    Thanks

  • MirekMirek Posts: 93 ✭✭

    Hi @elch,

    Are you using C++test based unit tests? or something else like GoogleTests? or CppUTest?

    If you are working with GoogleTest or other open source UT frameworks it is recommended to use C++test Standard edition, which includes a lightweight coverage tool that can be integrated with MSBuild. Please see "MSbuild integration" section in the manual

  • elchelch Posts: 95

    Hi @Mirek

    Thanks . So you recommend to run coverage in a standart edition in CLi mode. Yes it is google test.
    Is it possible to cover integration test not classic unit testing with this tool.
    For example qtools.

    Thanks

  • MirekMirek Posts: 93 ✭✭

    Hi @elch,

    C++test standard offers a lightweight coverage integration for VisualStudio. You can add a special MSBuild extension (which is done per project) and from this moment you will have an option to build a specific project with coverage. Build with coverage can be done entirely from ide - there is no extra step, once you added coverage extension you can just hit regular build, and once the build is ready you will need to execute the tested application. There will be one step which requires command line invocation - this is for generating a report. Please see the documentation I referred to in my previous post.

  • elchelch Posts: 95

    Hi @Mirek

    Thanks on the detailed response.
    In general ,is there difference between Coverage feature Pro vs. Standard ?

    Thanks

  • elchelch Posts: 95

    Hi @Mirek

    Is it possible to run coverage on EXE file not the tradinall UT project such as google test.
    Thanks

  • MirekMirek Posts: 93 ✭✭

    Hi @elch,

    I'm not 100% sure I understand what do you mean by EXE file, but I general I'm inclined to say yes. If you apply our "lightweight" coverage from C/C++test standard, you should be able to instrument your project in VS in a "transparent" way - that is without any significant modifications to your original project and then run the EXE file as you would normally run your application. In effect, coverage logs should be created. In case of very complex projects with multiple dlls there may be some custom setup steps required - nothing really extensive.

    Thanks,
    Mirek

  • elchelch Posts: 95

    Hi @Mirek

    Yes i want capture coverage when the EXE app is running.
    Can you please elaborate command line invocation for generating report.

    Thanks

  • elchelch Posts: 95

    Hi @Mirek

    One last question:
    Do I have to build the project in coverage mode in order to instrument the EXE when running just the EXE ?

    Thanks

  • elchelch Posts: 95

    Hi @Mirek

    I am trying to collect coverage via make file on windows env.
    I am getting an error about not finding cpptest\instrument.h file.
    any suggestions.

    Thanks

  • MirekMirek Posts: 93 ✭✭

    Hi @elch,

    Can you please provide the command line + exact error message from the console?

  • elchelch Posts: 95

    Hi @Mirek

    I have a GNU c++ project on Windows.
    I am trying to collect code coverage accrdoingto the following CLI example:

    https://docs.parasoft.com/display/CPPTEST1041/Integrating+with+Make-based+Build+Systems

    make CPP="cpptestcc -compiler gcc_3_4 -line-coverage -workspace /home/test/proj/cov -- g++"

    I changed CXX to CPP as it is C++ project.

    I am getting an error about:
    fatal error cpptest/instrumentation.h : No such file or Directory...

    Thanks

  • MirekMirek Posts: 93 ✭✭

    Hi @elch,

    This may be because your make file compilation rule automatically includes the instrumented files into original build.

    Please check inside your project for all directories named ".cpptest" and remove them. Then invoke the build command line one more time, with the workspace location specified somewhere outside of your project directory structure.

    make CPP="cpptestcc -compiler gcc_3_4 -line-coverage -workspace /home/temp/proj -- g++"

  • elchelch Posts: 95

    Hi @Mirek

    Still getting same error:
    I invoke the build command line outside in a different folder.

    Thanks

  • MirekMirek Posts: 93 ✭✭

    Hi @elch,

    Please create a simple option-file with any name, like "opt.psrc" and add one line to it:

    pscom.logger info.pscom.os,TRACE

    Then modify the command line used for instrumentation:

    make CPP="cpptestcc -compiler gcc_3_4 -line-coverage -workspace /home/temp/proj -psrc -- g++"

    This should generate more information on the output, the command line which is causing the trouble should be listed as the last one before the actual error message. Please provide it

  • elchelch Posts: 95

    Hi @Mirek

    This is the error:

    ERROR [src\option\sources\Psrc.cc:82] Utils::OptionReaderError : Can't open file
    ERROR [src\option\sources\CommandLine.cc:146] : Utils::OptionReaderError : Error reading command line option -psrc Cann't open file
    Error during logger initialization ERROR reading command line option -psrc Cann't open file.

    Thanks

  • MirekMirek Posts: 93 ✭✭

    Ok, me previous post was not complete because I've put parameter to -psrc option in ang. brackets which were interpreted as a tag and rendered out. Your command line needs to look like below:

    make CPP="cpptestcc -compiler gcc_3_4 -line-coverage -workspace /home/temp/proj -psrc path_to_opt.psrc -- g++"

    Please note that -psrc option is followed with a path to the options file created in the initial step.

  • elchelch Posts: 95

    Hi @Mirek

    Same error no additional info. fatal error cpptest/instrumentation.h : No such file or Directory...
    Any suggestions ?

    Thanks

  • elchelch Posts: 95

    Hi @Mirek

    The project is built on MiniGW. Is that helpful?

    Thanks

  • MirekMirek Posts: 93 ✭✭

    Hi @elch,

    Compiler should not matter here. If the psrc option was specified correctly you should see "Executing command:" tag in the output somewhere before the error message.
    Below you can see an example from my environment, we are looking for details about the command that generated the error. It will help to find out the reason.

    Executing command:"C:\cygwin\bin\gcc.exe" "-IC:\home\yennefer\mirek\temp\cpptest\runtime\include" -g -I. -o timer.o -c "..cpptest\cpptestcc\d\e\4\ce2b5\0\timer.c"
    Command executed.

  • elchelch Posts: 95

    Hi @Mirek

    Thanks on the follow up.
    The project is built with qtools , Is that matter ?
    https://www.state-machine.com/qtools

    Thanks

Sign In or Register to comment.