How to use lcov in cross compile environment.?

2.1k views Asked by At

I'm doing unit testing for device drivers for that i need to use gcov and lcov tools to generate reports.I compiled my code in native machine and the .gcno files are generated perfectly.Then i executed my output file in a arm based board and the gcda files also generated correctly.Then i have taken those files to my native and i generated .gcov files.

But when i use lcov to that files it is showing errors like "negative length in /usr/src/geninfo line no 2414".

1.So,For this what i need to do.?. 2.And one more question is I'm using "arm-none-gnueabi-" toolchain(2011.03) for this it has gcov seperately but lcov is not present in the executables.Is it possible to use lcov.?.If yes how to use.?..Thanks in advance.

1

There are 1 answers

0
Parthiv Shah On

Once you are able to generate the .gcda & .gcno files correctly, you need lcov tool to capture the code coverage. Here you should cross compile your lcov tool and add it into the file system.

I am working on similar kind of task, where i am trying to capture the coverage for ARMv7 based system. I have used yocto for the build framework. In yocto, meta-oe layer provides the support of the lcov. you can add it into the conf/local.conf file by adding following line into the configuration file.

CORE_IMAGE_EXTRA_INSTALL += "lcov"

after following all steps of your build, you will have the lcov tool on to the target board in /bin directory. Refer the lcov man page

You can use below command to generate the coverage files.

lcov --capture --directory <path-to-your-generated-files-dir> --gcov-tool /usr/bin/arm-linux-gnueabi-gcov --output-file <file_name>

Above command will generate a file, if your target board does not have enough capability then you can copy the generated file into your build system.

At the build system, you can execute below command to generate the HTML output with the exact coverage details,

genhtml <path_to_generated_file> --output-directory <out_dir>

Refer below links for more details about the GCOV & LCOV integration. 1. How to use GCOV & LCOV

  1. GCOV in linux kernel