| Line | |
|---|
| 1 | Here is how to use gcov to test code coverage in ldb.
|
|---|
| 2 |
|
|---|
| 3 | Step 1: build ldb with gcov enabled
|
|---|
| 4 |
|
|---|
| 5 | make clean all WITH_GCOV=1
|
|---|
| 6 |
|
|---|
| 7 | Step 3: run the test suite
|
|---|
| 8 | make test-tdb
|
|---|
| 9 |
|
|---|
| 10 | Step 4: produce the gcov report
|
|---|
| 11 | make gcov
|
|---|
| 12 |
|
|---|
| 13 | Step 5: read the summary reports
|
|---|
| 14 | less *.report.gcov
|
|---|
| 15 |
|
|---|
| 16 | Step 6: examine the per-file reports
|
|---|
| 17 | less ldb_tdb\#ldb_tdb.c.gcov
|
|---|
| 18 |
|
|---|
| 19 | You can also combine steps 2 to 4 like this:
|
|---|
| 20 |
|
|---|
| 21 | make clean all test-tdb gcov WITH_GCOV=1
|
|---|
| 22 |
|
|---|
| 23 | Note that you should not expect 100% coverage, as some error paths
|
|---|
| 24 | (such as memory allocation failures) are very hard to trigger. There
|
|---|
| 25 | are ways of working around this, but they are quite tricky (they
|
|---|
| 26 | involve allocation wrappers that "fork and fail on malloc").
|
|---|
| 27 |
|
|---|
| 28 | The lines to look for in the per-file reports are the ones starting
|
|---|
| 29 | with "#####". Those are lines that are never executed.
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.