From ae0c0c4c89f60fd379133f46b10c37686eef0c6c Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 22 Aug 2024 17:04:21 +0100 Subject: [PATCH] testsuite/path: match the full rootpath Our expectation is that the (full) rootpath is present, otherwise we prepend it ourselves. Drop the ABS_TOP_BUILDDIR instance. Signed-off-by: Emil Velikov Reviewed-by: Lucas De Marchi Link: https://github.com/kmod-project/kmod/pull/86 Signed-off-by: Lucas De Marchi --- Makefile.am | 2 -- shared/util.h | 1 + testsuite/path.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 370332f..0135698 100644 --- a/Makefile.am +++ b/Makefile.am @@ -232,8 +232,6 @@ EXTRA_DIST += \ 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) diff --git a/shared/util.h b/shared/util.h index f479b94..2671ac9 100644 --- a/shared/util.h +++ b/shared/util.h @@ -16,6 +16,7 @@ /* ************************************************************************ */ #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); void *memdup(const void *p, size_t n) __attribute__((nonnull(1))); diff --git a/testsuite/path.c b/testsuite/path.c index 7c5fa6c..2a2670f 100644 --- a/testsuite/path.c +++ b/testsuite/path.c @@ -33,7 +33,7 @@ static size_t rootpathlen; static inline bool need_trap(const char *path) { return path != NULL && path[0] == '/' - && !strstartswith(path, ABS_TOP_BUILDDIR); + && !strnstartswith(path, rootpath, rootpathlen); } static const char *trap_path(const char *path, char buf[PATH_MAX * 2])