Wednesday 21 December 2011

Checking Coverity builds

I'll write another Coverity related post right after the previous one to not forget..

In Coverity you need to be very careful that what you analyze is really what you wanted to.  First off of course you need to have the correct compiler configured, missing function models defined and correct compilation flags being used for the Coverity build. These are usually a one-off job, but depending on your workflow there might be problems making sure that the new snapshot really is built exactly like the previous one. You have to remember to clean the build etc very carefully.

There are a few things to check out:

  1. Did Coverity compile everything? It says at the end of the process what percentage of units were compiled. This should be 100.
  2. Do you see an unexpectedly high number of fixed and/or new defects? This can reveal issues listed above.
  3. Are there any errors in the build log (build-log.txt in the intermediary directory)? Search for "error #" in the log. This should also show in the percentage.
  4. Are there any warnings in the build log? Search for "warning #" in the log. These can prevent Coverity from analyzing functions.
  5. Are there any asserts? This is a rare Coverity bug and also should show in the percentage as well. Search for "Assertion failed".  There are instructions on how to get past this issue in the build log. It involves setting COVERITY_SUPPRESS_ASSERT.

Coverity and Bitbake

Coverity is a useful tool but boy can it take time to get it to work, especially if your compiler is not supported.

The latest issue, however, was more interesting. Apparently Bitbake shouldn't be a problem, but it was with us. The bitbake script cleans all environment variables except those whitelisted before it runs and as it happens, Coverity requires certain variables to be kept.

This problem can be solved by editing the /lib/bb/ There is a function called preserved_envvars_list() which returns an array of whitelisted environment variables. In order to make Coverity work, you need to add the following variables to that list:

EDIT: I was told of a few more variables in the Coverity Support Forum.