You should be able to build and test the application using the dotnet or msbuild build command in the command line mode. RKTracer provides multiple coverage metrics: Function Coverage, Line Coverage, Statement Coverage, and Multi-Condition Code Coverage.
Prefix rktracer to the dotnet build or msbuild command, run your tests, then run rkresults to generate the HTML report.
Dotnet/msbuild Code Coverage example
Before enabling RKTracer for instrumentation, you should clean the project, as the tool instruments at the source code level. The process involves changing:
dotnet build prime.csproj or msbuild prime.sln /t:rebuild
to:
rktracer dotnet build prime.csproj or rktracer -v msbuild prime.sln /t:rebuild
RKTracer instruments C# source files with c:\rktracer/lib/librkliz-x86_64-w64-mingw32.exe and writes instrumented output to the prime.cs file in a preprocessed directory. It stores metadata, instrumentation structure, and source file content in a JSON file, referencing rktracer.config during instrumentation. The tool automatically adds the runtime library to dotnet build.
Run tests on rktracer instrumented application
You can run unit tests or functional tests on the instrumented application. After testing, RKTracer saves coverage data to the rk-coverage.txt file. If testing occurs on a server machine, copy the rk-coverage.txt file from the server to the application working folder on the build machine.
Generate Code Coverage HTML reports
Run the rkresults command in the project root folder where the rktracer folder exists.
rkresults
The rkresults command searches the rk-coverage.txt file and maps it with JSON files generated during instrumentation in the rktracer folder, then generates HTML reports. You can manually open the HTML report using index.html.
Enable coverage for selected files
For selected folders, edit rktracer.config and add:
ignore *.cs instrument */power/* */core/* */keys/* never */firmware_loader/* */lockdown/*
ignore *.csignores all C# source files from instrumentation.instrumentinstruments source files from the given folders.neverignores the selected folders.
For selected functions, edit rktracer.config and set:
ignore *.cs instrument *file-X.cs *file-Y.cs *file-Z.cs function-ignore * function-instrument fun_X() fun_Y() fun_Z()
ignore *.csignores all C# source files.instrument *file-X.cs *file-Y.cs *file-Z.csinstruments only these files.function-ignore *ignores all functions in these files.function-instrument fun_X() fun_Y() fun_Z()does not ignore these specific functions.