Code Coverage for C & CPP Tizen Studio IDE
How to Integrate RKTracer with Tizen Studio IDE and generate code coverage
How to integrate the RKTracer tool with Tizen Studio IDE?
Step 1: Open a command prompt(Windows) or terminal(Linux) and execute the following command to integrate the RKTracer tool with Tizen Studio IDE.
rktracer -tizen -integrate
Step 2: On successful integration with Tizen Studio IDE. You should be able to see the RKTracer tool option under Run menu–>External tools>
How to instrument application in Tizen Studio IDE and generate code coverage reports?
You should build and test the application at least once in Tizen Studio IDE. Once the RKTracer tool integration is successful, you can see RKTracer options in Tizen Studio IDE under Run menu–>External tools>
Step 1: Enable RKTracer tool and rebuild application
Select project in IDE with the mouse pointer, as shown in the following screenshot. Tizen Studio doesn’t recognize when we try to turn ON/OFF/Report generate using RKTracer options.
Now go to the run menu→ External Tools and select RKTracer ON to turn on the RKTracer tool. Once the RKTracer tool is turned on, you should see the following information in the console output tab.
rktracer options: -v
to change options edit Project → Properties → Resources → ‘Linked Resources’ → ‘Path Variables’ → RK_ARGS
𝗿𝗸𝘁𝗿𝗮𝗰𝗲𝗿 switched 𝗢𝗡 in C:\tizen-studio\ide/Templates/native/ninja/rules.ninja
Step 2: Rebuild the application and test.
Before you test the app on the device, open the project working directory in the command prompt and redirect the sdb dlog output to the rk-coverage.txt file. You should not change the rk-coverage.txt file name. As RKTracer tool only recognizes the rk-coverage.txt file as code coverage data.
sdb dlog > rk-coverage.txt
Now install the app on the device or emulator and test it. Once testing is completed, kill the command that we are running in the command prompt.
i.e sdb dlog > rk-coverage.txt
Step 3:Generate Code Coverage Reports.
To generate the reports go to Tizen Studio IDE and select the project using mouse point as we did earlier before instrumentation and then goto → Run menu→ External Tools and select RKTracer report to generate rktracer code coverage Html reports.
Note: if code coverage reports are not opening automatically in the browser. You should find the reports under.
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() = But instrument or don’t ignore these three functions from these three files.