Back

Coverity

Coverity is a static analysis tool often used by engineers in the industry to find both trivial and non-trivial bugs in their code. It is not easy to write bug-free code in the first attempt. Engineers know this, so they tend to write unit tests and beyond that, use tools like Coverity to quickly find bugs before releasing the binaries.

Here’s your chance to learn about the tool and find bugs in your code and other’s! So how do you use Coverity?

Download the VM image at the link we provided to you on Piazza. It is an Ubuntu 17.10 VM with Coverity and Docker installed. We suggest using VirtualBox to import and boot the VM image (Be sure not to check the option “Reinitialise MAC addresses…” when using the VM!). We have been able to use it comfortably with 3GB RAM but we would recommend using 4GB of RAM if possible. The machine should autologin but in case it doesn’t, the username and password are both “student”.

Once in the VM, perform the following steps to run the analysis. path_to_code is the path (on the VM) to the code you want to analyze.

$ cd <path_to_code>
$ mkdir analysis_dir
$ make clean
$ cov-build --dir analysis_dir make
$ cov-analyze -all --dir analysis_dir
$ cov-format-errors --dir analysis_dir

The above lines will build a few test units that Coverity will analyze. The summary of Coverity’s analysis can be found in the file analysis_dir/output/summary.txt. The line cov-format-errors... generates an HTML report of the analysis which explains the potential bugs found and their location in the source code; the output can be found at analysis_dir/output/errors/index.html.

For your reference we have downloaded and placed the starter code in the /home/student/Downloads/ directory.

Be careful to run make clean before you run cov-build to ensure that you generate a correct analysis of the source code.

Coverity License Update

Coverity may complain about license errors if the license included with the VM expires. In this case, please download the license updater from the link we provided in Piazza to the Downloads/ folder in the VM.

Execute the following commands:

$ cd /home/student/Downloads
$ chmod +x ./coverity_lic_upd
$ ./coverity_lic_upd

Other Tips