Commit Graph

15 Commits

Author SHA1 Message Date
David Korth
d6d929aa67 [scripts] lcov.sh: Ignore some more errors.
TODO: Figure out what's causing these errors and fix them.
For now, they're being ignored, since they prevent the coverage report
from being generated.
2025-02-01 11:06:57 -05:00
David Korth
a58b6625b4 fixup! [scripts] lcov.sh: Reduce warnings to 5 per category; enable branch coverage.
remove debug stuff
2025-01-18 12:18:09 -05:00
David Korth
a5c23c5543 [cmake] gcc.cmake: Add -fprofile-update=atomic.
This fixes the 'negative' errors from lcov's geninfo.

Before:
  source files: 600
  lines.......: 23.2% (10654 of 45904 lines)
  functions...: 22.8% (848 of 3721 functions)
  branches....: 15.8% (7572 of 47821 branches)

After:
  source files: 600
  lines.......: 23.2% (10654 of 45904 lines)
  functions...: 22.8% (848 of 3721 functions)
  branches....: 15.8% (7572 of 47821 branches)

Effectively no change in coverage, but it's likely more stable.
I'll note that the error was triggering in ASTC decoding, which
uses OpenMP for parallel processing.
2025-01-18 12:10:32 -05:00
David Korth
f1607d6b83 [scripts] lcov.sh: Reduce warnings to 5 per category; enable branch coverage.
Need to supporess 'mismatch' errors because branch coverage is
generating "mismatched exception tag" errors now.

Also need to supporess 'negative' because some branches are somehow
getting a *negative* token count...

geninfo: ERROR: (negative) Unexpected negative taken count '-103' for branch 6 while capturing from ./extlib/basisu_astc/CMakeFiles/basisu_astc.dir/basisu_astc_decomp.cpp.gcda.
        Perhaps you need to compile with '-fprofile-update=atomic'.
        (use "geninfo --ignore-errors negative ..." to bypass this error)

New coverage rate, now with branches:
  source files: 600
  lines.......: 23.2% (10654 of 45904 lines)
  functions...: 22.8% (848 of 3721 functions)
  branches....: 15.8% (7572 of 47821 branches)
2025-01-18 11:59:13 -05:00
David Korth
7ed038b3e7 [scripts] lcov.sh: Remove set -v that was added for debugging. 2025-01-14 00:52:41 -05:00
David Korth
74be3491f1 [scripts] lcov.sh: Fix issues with lcov-2.x.
lcov-2.x is much more strict than lcov-1.x, and it doesn't like some stuff
with gtest, so we have to ignore various warnings.

[gtk] Class headers: lcov gets confused if G_DECLARE_FINAL_TYPE() is in
a preprocessor conditional. Instead, make conditional typedefs, and use
those typedefs in G_DECLARE_FINAL_TYPE().

lcov: ERROR: (inconsistent) "gtk/MessageWidget.h":19: duplicate function
'RP_IS_MESSAGE_WIDGET' starts on line 19 but previous definition started
on 17 while capturing from
./src/gtk/gtk3/CMakeFiles/rom-properties-gtk3.dir/__/MessageWidget.c.gcno.
        (use "lcov --ignore-errors inconsistent ..." to bypass this error)

lcov.sh: Ignore inconsistent errors because gtest macros confuse lcov:

lcov: ERROR: (inconsistent) mismatched end line for _ZN10LibRomData5Tests37SortFuncsTest_gtk4_ascendingSort_Test8TestBodyEv
at src/gtk/tests/SortFuncsTest_gtk4.cpp:136: 136 -> 163 while capturing
from ./src/gtk/tests/CMakeFiles/SortFuncsTest_gtk4.dir/SortFuncsTest_gtk4.cpp.gcno
        (use "lcov --ignore-errors inconsistent ..." to bypass this error)

Also ignore "corrupt" errors, which seemingly happens randomly.

Ignore "unused" removed file warnings, since SpecializedThumbnailer1.h
might not be present in the output.
2025-01-14 00:48:30 -05:00
David Korth
1c78de6019 [scripts] lcov.sh: Exclude SpecializedThumbnailer1.h in addition to SpecializedThumbnailer1.c. 2023-07-09 18:37:23 -04:00
David Korth
8987fdd97b [scripts] lcov.sh: Fix exclusions; add more generated files.
Missing backslash after glibresources.c broke the remaining exclusions.

Before:
- Lines: 7200/54542 -> 13.2%
- Functions: 518/4076 -> 12.7%

After:
- Lines: 7195/51829 -> 13.9%
- Functions: 517/3631 -> 14.2%
2023-02-11 10:31:06 -05:00
David Korth
2a308eb6cc [scripts] lcov.sh: Ignore some more files.
- glibresources.c
- qrc_*.cpp (Qt resource files)
- GTK+ generated notificationsinterface code.
2021-04-07 02:49:59 -04:00
David Korth
ca722fb187 [scripts] lcov.sh: Exclude gettext.h from the code coverage report.
This is a third-party file from GNU gettext.
2018-01-13 22:59:23 -05:00
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