This reverts commit
ae0c0c4c89f60fd379133f46b10c37686eef0c6c.
The commit reasoning was correct, but did not consider the case where
other third-party files are created. Namely: when generating the code
coverage files.
Thus the gcna files were created in $test_rootdir/$abs_top_builddir
which meant they won't get picked when the coverage info/xml/html files
were created and the statistics reported were quite wrong.
Revert the commit and add an inline comment, so we don't feel tempted to
change it in the future.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/229
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
check_LTLIBRARIES = $(TESTSUITE_OVERRIDE_LIBS)
testsuite_uname_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
+testsuite_path_la_CPPFLAGS = $(AM_CPPFLAGS) \
+ -DABS_TOP_BUILDDIR=\"$(abs_top_builddir)\"
testsuite_path_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
testsuite_delete_module_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
/* ************************************************************************ */
#define streq(a, b) (strcmp((a), (b)) == 0)
#define strstartswith(a, b) (strncmp(a, b, strlen(b)) == 0)
-#define strnstartswith(a, b, n) (strncmp(a, b, n) == 0)
char *strchr_replace(char *s, char c, char r);
_nonnull_all_ void *memdup(const void *p, size_t n);
mod,
files('@0@.c'.format(mod)),
include_directories : top_include,
+ c_args : '-DABS_TOP_BUILDDIR="@0@"'.format(meson.project_build_root()),
dependencies : libdl,
link_with : [libshared, libkmod_internal],
gnu_symbol_visibility : 'hidden',
static inline bool need_trap(const char *path)
{
- return path != NULL && path[0] == '/' &&
- !strnstartswith(path, rootpath, rootpathlen);
+ /*
+ * Always consider the ABS_TOP_BUILDDIR as the base root of anything we do.
+ *
+ * Changing this to rootpath is tempting but incorrect, since it won't consider
+ * any third-party files managed through this LD_PRELOAD library, eg coverage.
+ *
+ * In other words: if using rootpath, the coverage gcna files will end up created
+ * in the wrong location eg. $rootpath/$ABS_TOP_BUILDDIR.
+ */
+ return path != NULL && path[0] == '/' && !strstartswith(path, ABS_TOP_BUILDDIR);
}
static const char *trap_path(const char *path, char buf[PATH_MAX * 2])