Posts You May Like

PostgreSQL : Test Coverage

Install lcov

Install Dependencies:
yum install perl-devel
yum install perl-Digest-MD5
yum install perl-GD

Download and install lcov
rpm -U lcov-1.13-1.el7.noarch.rpm


Run Test

Configure and make
Use the --enable-coverage configure flag
./configure --enable-coverage
make -j 4

Run make check
cd src/
make check -i

A file with .gcno extension is created for each source file and another with .gcda extension is generated when we run the tests.


Check Coverage

HTML output

make coverage-html

A folder named 'coverage' is generated along with the index.html file and other required data to display the coverage information. The HTML page will show a summary of the coverage for each folder and recursively for each file and then for each line.


Text output

make coverage

A .gcov and .gcov.out file is created for each source file which contains the coverage information.


Reset

make coverage-clean

This resets the execution count by removing all the .gcda files generated.


Output files

<file>.gcov.out

This list out the details for each function in the corresponding source file. An example output for a function is shown below:
Function 'heap_sync' Lines executed:100.00% of 10 Branches executed:100.00% of 4 Taken at least once:75.00% of 4 Calls executed:100.00% of 6

<file>.gcov

This displays the original file entirely along with the line number and the count of the number of times each line was executed during the test run. Lines which were never executed are marked with hashes ‘######’ and '-' indicated that the line is not executable.
-: 9258: /* main heap */ 50: 9259: FlushRelationBuffers(rel); call 0 returned 100%

.
. <more lines>
.

#####: 9283:    Page        page = (Page) pagedata;

        -: 9284:    OffsetNumber off;

        -: 9285:

    #####: 9286:    mask_page_lsn_and_checksum(page);
call    0 never executed

index.html

The home page:
This lists out all the sub directory along with their coverage data.


Per directory info:
On clicking a particular directory, we get the coverage info of each file in the selected directory.


















Select a file:
This gives out the per line hit count of the selected file. The one highlighted in blue are hit and those in red are never executed during the test run.

No comments:

Post a Comment