How Can We Help?
< All Topics
Print

Generate Code Coverage for External Kernel module/ kernel file system

Generate Code Coverage for External Kernel module/ kernel file system

How to generate Code Coverage for Standalone Driver Module (knetstat) and Testing in Kernel

How to generate Code Coverage for Standalone Driver Module (knetstat) and Testing in Kernel

 

Step 1: You need to patch the Linux kernel with the RKTracer patch. 

       patch -p1 < /home/rkvalidate/share/rktracer/01-rktracer.patch

Step 2: Build the knetstat Driver module with the command.

       make CC=”rktracer -r aarch64-linux-gnu-gcc” ARCH=arm64 LD=aarch64-linux-gnu-ld 

Step 3: Start kernel device or qemu 64-bit arm architecture emulator.

Step 4: Copy RKTracer instrumented knetnet.ko kernel object file to the kernel which is up and running 

      scp rkvalidate@192.168.15.129:*.ko

Step 5: Load and test knetnet.ko kernel object file to the kernel with command “insmod knetstat.ko” 

Step 6: Save code coverage data to the RK_MEM.raw file. 

     cat /proc/RK_MEM.raw > RK_MEM.raw

Step 7: Copy “RK_MEM.raw” to the host build system to knetstats kernel module folder.

Step 8: Generate reports using command rkresults. 

Generate code coverage for kernel file system

How to generate code coverage for a kernel file system using the RKTRacer tool

 

Step 1: You need to patch the Linux kernel with the RKTracer patch. 

    patch -p1 < /home/rkvalidate/share/rktracer/01-rktracer.patch

 

Step 2: Since we have added the patch, you should be able to see “Enable RKTRacer RK_MEM[]” make sure it’s enabled and then add “CC:=rktracer -r ${CC}” fs makefile of the file system which needs to be instrumented

 

Step 3: Test file system in kernel mode by running/execute test “./runltp -s fs” to run the test suite.

 

Step 4: Now load the rkmem.ko, this is the interface to copy the coverage data which is already in memory ” insmod /lib/modules/4.19.16/kernel/drivers/char/rkmem.ko”

 

Step 5: Save code coverage data.

cat /proc/RK_MEM.raw > RK_MEM.raw

 

Step 6: Copy “RK_MEM.raw” to the host build system and generate reports using command rkresults. 

Previous Generate Code Coverage for NDK Projects
Next Generate Code Coverage for Windows Device Drivers
Table of Contents