Commit Graph

5 Commits

Author SHA1 Message Date
David Korth
7773ed1e78 [scripts] lcov.sh: Exclude pngcheck.cpp from the code coverage report.
This is mostly third-party code, so we don't need to check it.
2018-01-13 16:14:45 -05:00
David Korth
2668e5f225 [scripts] lcov.sh: Create a baseline coverage data file before running
tests.

This ensures that we get information from all files, not just files that
had functions that were run.

This brings down the total number of covered functions significantly:

	|   Line Coverage    |    Functions     |
--------+--------------------+------------------+
Before: | 43.0% (3308/7699)  | 48.8% (266/545)  |
 After: | 15.2% (3308/21821) | 15.1% (266/1762) |

Excluded generated Qt and D-Bus files from the tests. Also exlcuded
pngcheck, since it's mostly third-party code.

TODO: Create some truncated ROM images to use as test cases and run them
in rpcli, and also compare extracted images.
2018-01-13 03:13:22 -05:00
David Korth
cc4581e429 [scripts] lcov.sh: Correctly exclude extlib/ and tests/ from coverage output.
On some systems, the full path is included in the code coverage data,
so we have to prefix these with '*/'.
2018-01-13 02:45:49 -05:00
David Korth
a394a3321e [scripts] lcov.sh: Exclude the extlib/ directory.
We only want to check coverage of rom-properties code, not external
libraries.
2016-10-18 23:00:52 -04:00
David Korth
b3ad0ef659 Added support for code coverage testing when using gcc or clang.
Set ENABLE_COVERAGE=ON to enable code coverage testing.

After the build is finished, run 'make coverage' to run the unit tests
and generate a code coverage page in the ${CMAKE_BINARY_DIR}/coverage
directory.

Reference: https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake
(commit 59f8ab8dded56b490dec388ac6ad449318de8779)

CMakeLists.txt:
- Moved the CMAKE_BUILD_TYPE check to before INCLUDE(CTest),
  and capitalized the 'D' in "Debug", since CodeCoverage.cmake
  checks for that.

gcc.cmake:
- Set the required CFLAGS. (These aren't checked for explicitly, since
  they're basically present on all gcc since forever.)
- Link all targets to -lgcov.
- Create a 'coverage' target for automatically running tests and
  generating HTML output using lcov/genhtml.

options.cmake:
- Added ENABLE_COVERAGE.

scripts/lcov.sh:
- Shell script used by the 'coverage' target to generate the lcov/genhtml
  output from the gcov profiling data.
2016-10-18 22:55:21 -04:00