ci: collect coverage on _exit() as well
_exit() skips the gcov hooks, so we lose all coverage collected up to that point. Let's work around this by intercepting _exit() with our wrapper that calls __gcov_dump() just before _exit().
This commit is contained in:
parent
b4b8f8c293
commit
b0d003023c
3 changed files with 31 additions and 0 deletions
|
@ -17,6 +17,11 @@ AM_CPPFLAGS += \
|
|||
endif
|
||||
endif
|
||||
|
||||
if WITH_COVERAGE
|
||||
AM_CPPFLAGS += \
|
||||
-include $(top_srcdir)/include/coverage.h
|
||||
endif
|
||||
|
||||
AM_CFLAGS = -fsigned-char $(WARN_CFLAGS)
|
||||
AM_CXXFLAGS = $(AM_CFLAGS)
|
||||
AM_LDFLAGS = $(ASAN_LDFLAGS) $(UBSAN_LDFLAGS) $(FUZZING_ENGINE_LDFLAGS) $(COVERAGE_LDFLAGS)
|
||||
|
|
|
@ -13,6 +13,7 @@ dist_noinst_HEADERS += \
|
|||
include/closestream.h \
|
||||
include/colors.h \
|
||||
include/color-names.h \
|
||||
include/coverage.h \
|
||||
include/cpuset.h \
|
||||
include/crc32.h \
|
||||
include/crc32c.h \
|
||||
|
|
25
include/coverage.h
Normal file
25
include/coverage.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* No copyright is claimed. This code is in the public domain; do with
|
||||
* it what you wish.
|
||||
*/
|
||||
#ifndef UTIL_LINUX_COVERAGE_H
|
||||
#define UTIL_LINUX_COVERAGE_H
|
||||
|
||||
/* When built with --coverage (gcov) we need to explicitly call __gcov_dump()
|
||||
* in places where we use _exit(), since _exit() skips at-exit hooks resulting
|
||||
* in lost coverage.
|
||||
*
|
||||
* To make sure we don't miss any _exit() calls, this header file is included
|
||||
* explicitly on the compiler command line via the -include directive (only
|
||||
* when built with --coverage/-Db_coverage=true)
|
||||
*/
|
||||
void __gcov_dump(void);
|
||||
void _exit(int);
|
||||
|
||||
__attribute__((noreturn)) static inline void _coverage__exit(int status) {
|
||||
__gcov_dump();
|
||||
_exit(status);
|
||||
}
|
||||
#define _exit(x) _coverage__exit(x)
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue