Code Coverage for C & C++ Visual Studio IDEs
How to integrate the RKTracer tool with Visual Studio IDE (2005 to 2019)
Open a new command prompt and execute the following command to integrate the RKTracer tool with visual studio IDEs.
rktracer -vs -integrate
On successful integration of the RKTracer tool, you should see the following information in the command prompt.
How to generate code coverage in Visual Studio IDE for C/C++ projects?
To Instrument, test, and generate code coverage in Visual Studio IDEs (2015 to 2019). Make sure you are able to build and run the unit/functional testing of the application. Testing can be on a host or server machine.
Step 1: Enable the RKTracer tool
goto Tools→ RKTracer ON
Step 2: Rebuild the application to the instrument with the RKTracer tool.
Step 3: Test the instrumented application
Testing can be of unit testing or functional testing/integration testing.
Post-testing the RKTracer tool will save coverage data to the rk-coverage.txt file.
Step 4: Generate RKTracer code coverage report.
If your testing the application on the server machine, You need to copy rk-coverage to the application working folder on the host machine and then generate reports
goto Tools→ RKTracer reports
Generate code coverage for selected functions/files/folder
Generate coverage reports for the selected folders
Suppose you need code coverage for source files from three different folders, i.e., core, keys, power, and ignore coverage for folders firmware_loader and lockdown. Edit rktracer.config in the RKTracer installation folder and go to the end of the file add the following information.
instrument */power/* */core/* */keys/*
never */firmware_loader/* */lockdown/*
ignore *.c = Ignores all C source files from instrumentation
Instrument = Instrument source files from given folders
never = ignore selected folder
Generate coverage reports only for selected functions from three different files.
fun_X() in source-file-X
fun_Y() in source-file-Y
fun_Z() in source-file-Z
Suppose you need code coverage for selected functions from three different files. Edit rktracer.config in the RKTracer installation folder and go to the end of the file and set the following variables as shown below.
instrument *source-file-X.c *source-file-Y.c *source-file-Z.c
function-instrument fun_X() fun_Y() fun_Z()
ignore *.c = Ignore all C programming source files
instrument *file-X.c *file-Y.c *file-Z.c = Instrument only these three source files.
function-ignore * = Then ignore all functions in the above three files.
function-instrument fun_X() fun_Y() fun_Z() = Don’t ignore these three functions from these three files from instrumentation.