DM-Devel Archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] multipath-tools: CI fixes for glibc symbol substitutions
@ 2024-04-12  9:32 Martin Wilck
  2024-04-12  9:32 ` [PATCH 1/2] multipath-tools tests: fix CI failures on arm/v7 with glibc 2.37 Martin Wilck
  2024-04-12  9:32 ` [PATCH 2/2] multipath-tools tests: fix CI failures with clang on Fedora Rawhide Martin Wilck
  0 siblings, 2 replies; 6+ messages in thread
From: Martin Wilck @ 2024-04-12  9:32 UTC (permalink / raw
  To: Christophe Varoqui, Benjamin Marzinski; +Cc: dm-devel

Or cmocka-based CI relies on the ability to wrap functions calls, both
our own code and from and system libraries, with the --Wl,--wrap linker
flags. This works only if the function name in the function call generated
by the compliler is known. glibc has introduced function substitutions
for multiple system calls that break this assumption and thus break our CI.
For example, a C call to open() may be translated into a "call __open64_2"
assembly instruction.

We have first seen this with 7b217f8 ("multipath-tools: Makefile.inc:
set _FILE_OFFSET_BITS=64"), but also happens independently of the
type size macros. The 2nd patch in this series works around a
compiler-dependent substitution.

This has an unfortunate effect on our CI code, which is becoming
increasingly hard to understand, with lots of #if's with workarounds
combinations of library versions, compilers, and compile time settings.

CI failures have lately been caused much more frequently by this sort
of failure than by actual bugs in our own code, which is causing significant
maintenance effort.

I am not sure how to deal with this in the long term. I don't see a general
solution, although it's unlikely that only multipath-tools is affected by
this problem. For now, here are patches that fix the recent CI regressions.

Martin Wilck (2):
  multipath-tools tests: fix CI failures on arm/v7 with glibc 2.37
  multipath-tools tests: fix CI failures with clang on Fedora Rawhide

 tests/directio.c | 22 +++++++++---------
 tests/dmevents.c |  6 ++---
 tests/sysfs.c    | 58 ++++++++++++++++++++++++------------------------
 tests/test-lib.c |  6 ++---
 tests/vpd.c      | 35 +++++++++++++++--------------
 tests/wrap64.h   | 37 +++++++++++++++++++++++++++++-
 6 files changed, 100 insertions(+), 64 deletions(-)

-- 
2.44.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] multipath-tools tests: fix CI failures on arm/v7 with glibc 2.37
  2024-04-12  9:32 [PATCH 0/2] multipath-tools: CI fixes for glibc symbol substitutions Martin Wilck
@ 2024-04-12  9:32 ` Martin Wilck
  2024-04-12 15:33   ` Benjamin Marzinski
  2024-04-12  9:32 ` [PATCH 2/2] multipath-tools tests: fix CI failures with clang on Fedora Rawhide Martin Wilck
  1 sibling, 1 reply; 6+ messages in thread
From: Martin Wilck @ 2024-04-12  9:32 UTC (permalink / raw
  To: Christophe Varoqui, Benjamin Marzinski; +Cc: dm-devel

glibc 2.37 has added several new wrappers around the ioctl and
io_getevents system calls on 32 bit systems, to deal with 64bit
time_t. These aren't resolved with cmocka's wrapping technique.

Fix this with C preprocessor trickery, similar to
7b217f8 ("multipath-tools: Makefile.inc: set _FILE_OFFSET_BITS=64").

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 tests/directio.c | 22 +++++++++++-----------
 tests/vpd.c      | 35 ++++++++++++++++++-----------------
 tests/wrap64.h   | 23 ++++++++++++++++++++++-
 3 files changed, 51 insertions(+), 29 deletions(-)

diff --git a/tests/directio.c b/tests/directio.c
index cbedcc9..a5a5c0e 100644
--- a/tests/directio.c
+++ b/tests/directio.c
@@ -41,9 +41,9 @@ struct timespec full_timeout = { .tv_sec = -1 };
 #define ioctl_request_t int
 #endif
 
-int __real_ioctl(int fd, ioctl_request_t request, void *argp);
+int REAL_IOCTL(int fd, ioctl_request_t request, void *argp);
 
-int __wrap_ioctl(int fd, ioctl_request_t request, void *argp)
+int WRAP_IOCTL(int fd, ioctl_request_t request, void *argp)
 {
 #ifdef DIO_TEST_DEV
 	mock_type(int);
@@ -148,10 +148,10 @@ int __wrap_io_cancel(io_context_t ctx, struct iocb *iocb, struct io_event *evt)
 #endif
 }
 
-int __real_io_getevents(io_context_t ctx, long min_nr, long nr,
+int REAL_IO_GETEVENTS(io_context_t ctx, long min_nr, long nr,
 			struct io_event *events, struct timespec *timeout);
 
-int __wrap_io_getevents(io_context_t ctx, long min_nr, long nr,
+int WRAP_IO_GETEVENTS(io_context_t ctx, long min_nr, long nr,
 			struct io_event *events, struct timespec *timeout)
 {
 	int nr_evs;
@@ -193,7 +193,7 @@ int __wrap_io_getevents(io_context_t ctx, long min_nr, long nr,
 
 static void return_io_getevents_none(void)
 {
-	will_return(__wrap_io_getevents, 0);
+	wrap_will_return(WRAP_IO_GETEVENTS, 0);
 }
 
 static void return_io_getevents_nr(struct timespec *ts, int nr,
@@ -207,15 +207,15 @@ static void return_io_getevents_nr(struct timespec *ts, int nr,
 			mock_events[i + ev_off].res = reqs[i]->blksize;
 	}
 	while (nr > 0) {
-		will_return(__wrap_io_getevents, (nr > 128)? 128 : nr);
-		will_return(__wrap_io_getevents, ts);
-		will_return(__wrap_io_getevents, &mock_events[off + ev_off]);
+		wrap_will_return(WRAP_IO_GETEVENTS, (nr > 128)? 128 : nr);
+		wrap_will_return(WRAP_IO_GETEVENTS, ts);
+		wrap_will_return(WRAP_IO_GETEVENTS, &mock_events[off + ev_off]);
 		ts = NULL;
 		off += 128;
 		nr -= 128;
 	}
 	if (nr == 0)
-		will_return(__wrap_io_getevents, 0);
+		wrap_will_return(WRAP_IO_GETEVENTS, 0);
 	ev_off += i;
 }
 
@@ -251,7 +251,7 @@ static void do_libcheck_init(struct checker *c, int blocksize,
 	struct directio_context * ct;
 
 	c->fd = test_fd;
-	will_return(__wrap_ioctl, blocksize);
+	wrap_will_return(WRAP_IOCTL, blocksize);
 	assert_int_equal(libcheck_init(c), 0);
 	ct = (struct directio_context *)c->context;
 	assert_non_null(ct);
@@ -762,7 +762,7 @@ int main(void)
 {
 	int ret = 0;
 
-	init_test_verbosity(2);
+	init_test_verbosity(5);
 	ret += test_directio();
 	return ret;
 }
diff --git a/tests/vpd.c b/tests/vpd.c
index 1b2d62d..e3212e6 100644
--- a/tests/vpd.c
+++ b/tests/vpd.c
@@ -20,6 +20,7 @@
 #include "vector.h"
 #include "structs.h"
 #include "discovery.h"
+#include "wrap64.h"
 #include "globals.c"
 
 #define VPD_BUFSIZ 4096
@@ -58,7 +59,7 @@ static const char vendor_id[] = "Linux";
 static const char test_id[] =
 	"A123456789AbcDefB123456789AbcDefC123456789AbcDefD123456789AbcDef";
 
-int __wrap_ioctl(int fd, unsigned long request, void *param)
+int WRAP_IOCTL(int fd, unsigned long request, void *param)
 {
 	int len;
 	struct sg_io_hdr *io_hdr;
@@ -428,8 +429,8 @@ static void test_vpd_vnd_ ## len ## _ ## wlen(void **state)             \
 	/* Replace spaces, like code under test */			\
 	exp_subst = subst_spaces(exp_wwid);				\
 	free(exp_wwid);							\
-	will_return(__wrap_ioctl, n);					\
-	will_return(__wrap_ioctl, vt->vpdbuf);				\
+	wrap_will_return(WRAP_IOCTL, n);				\
+	wrap_will_return(WRAP_IOCTL, vt->vpdbuf);			\
 	ret = get_vpd_sgio(10, 0x83, 0, vt->wwid, wlen);		\
 	assert_correct_wwid("test_vpd_vnd_" #len "_" #wlen,		\
 			    exp_len, ret, '1', 0, false,		\
@@ -458,8 +459,8 @@ static void test_vpd_str_ ## typ ## _ ## len ## _ ## wlen(void **state) \
 		exp_len--;						\
 	if (exp_len >= wlen)						\
 		exp_len = wlen - 1;					\
-	will_return(__wrap_ioctl, n);					\
-	will_return(__wrap_ioctl, vt->vpdbuf);				\
+	wrap_will_return(WRAP_IOCTL, n);				\
+	wrap_will_return(WRAP_IOCTL, vt->vpdbuf);			\
 	ret = get_vpd_sgio(10, 0x83, 0, vt->wwid, wlen);		\
 	assert_correct_wwid("test_vpd_str_" #typ "_" #len "_" #wlen,	\
 			    exp_len, ret, byte0[type], 0,		\
@@ -495,8 +496,8 @@ static void test_vpd_naa_ ## naa ## _ ## wlen(void **state)             \
 									\
 	n = create_vpd83(vt->vpdbuf, sizeof(vt->vpdbuf), test_id,	\
 			 3, naa, 0);					\
-	will_return(__wrap_ioctl, n);					\
-	will_return(__wrap_ioctl, vt->vpdbuf);				\
+	wrap_will_return(WRAP_IOCTL, n);				\
+	wrap_will_return(WRAP_IOCTL, vt->vpdbuf);			\
 	ret = get_vpd_sgio(10, 0x83, 0, vt->wwid, wlen);		\
 	assert_correct_wwid("test_vpd_naa_" #naa "_" #wlen,		\
 			    exp_len, ret, '3', '0' + naa, true,		\
@@ -518,8 +519,8 @@ static void test_vpd_naa_##NAA##_badlen_##BAD(void **state)	\
 	n = create_vpd83(vt->vpdbuf, sizeof(vt->vpdbuf), test_id, 3, NAA, 0); \
 									\
 	vt->vpdbuf[7] = BAD;						\
-	will_return(__wrap_ioctl, n);					\
-	will_return(__wrap_ioctl, vt->vpdbuf);				\
+	wrap_will_return(WRAP_IOCTL, n);				\
+	wrap_will_return(WRAP_IOCTL, vt->vpdbuf);			\
 	ret = get_vpd_sgio(10, 0x83, 0, vt->wwid, 40);			\
 	assert_int_equal(-ret, -ERR);					\
 }
@@ -545,11 +546,11 @@ static void test_vpd_eui_ ## len ## _ ## wlen ## _ ## sml(void **state)	\
 		/* overwrite the page size to DEFAULT_SGIO_LEN + 1 */	\
 		put_unaligned_be16(255, vt->vpdbuf + 2);		\
 		/* this causes get_vpd_sgio to do a second ioctl */	\
-		will_return(__wrap_ioctl, n);				\
-		will_return(__wrap_ioctl, vt->vpdbuf);			\
+		wrap_will_return(WRAP_IOCTL, n);			\
+		wrap_will_return(WRAP_IOCTL, vt->vpdbuf);		\
 	}								\
-	will_return(__wrap_ioctl, n);					\
-	will_return(__wrap_ioctl, vt->vpdbuf);				\
+	wrap_will_return(WRAP_IOCTL, n);				\
+	wrap_will_return(WRAP_IOCTL, vt->vpdbuf);			\
 	ret = get_vpd_sgio(10, 0x83, 0, vt->wwid, wlen);		\
 	assert_correct_wwid("test_vpd_eui_" #len "_" #wlen "_" #sml,	\
 			    exp_len, ret, '2', 0, true,			\
@@ -571,8 +572,8 @@ static void test_vpd_eui_badlen_##LEN##_##BAD(void **state)	\
 	n = create_vpd83(vt->vpdbuf, sizeof(vt->vpdbuf), test_id, 2, 0, LEN); \
 									\
 	vt->vpdbuf[7] = BAD;						\
-	will_return(__wrap_ioctl, n);					\
-	will_return(__wrap_ioctl, vt->vpdbuf);				\
+	wrap_will_return(WRAP_IOCTL, n);				\
+	wrap_will_return(WRAP_IOCTL, vt->vpdbuf);			\
 	ret = get_vpd_sgio(10, 0x83, 0, vt->wwid, 40);			\
 	assert_int_equal(ret, ERR);					\
 	if (ERR >= 0)							\
@@ -600,8 +601,8 @@ static void test_vpd80_ ## size ## _ ## len ## _ ## wlen(void **state)  \
 		exp_len = wlen - 1;					\
 	n = create_vpd80(vt->vpdbuf, sizeof(vt->vpdbuf), input,		\
 			 size, len);					\
-	will_return(__wrap_ioctl, n);					\
-	will_return(__wrap_ioctl, vt->vpdbuf);				\
+	wrap_will_return(WRAP_IOCTL, n);				\
+	wrap_will_return(WRAP_IOCTL, vt->vpdbuf);			\
 	ret = get_vpd_sgio(10, 0x80, 0, vt->wwid, wlen);		\
 	assert_correct_wwid("test_vpd80_" #size "_" #len "_" #wlen,	\
 			    exp_len, ret, 0, 0, false,			\
diff --git a/tests/wrap64.h b/tests/wrap64.h
index 8c91d27..6b92751 100644
--- a/tests/wrap64.h
+++ b/tests/wrap64.h
@@ -1,5 +1,7 @@
 #ifndef _WRAP64_H
 #define _WRAP64_H 1
+#include <syscall.h>
+#include <linux/types.h>
 #include "util.h"
 
 /*
@@ -31,7 +33,9 @@
  * fcntl() needs special treatment; fcntl64() has been introduced in 2.28.
  * https://savannah.gnu.org/forum/forum.php?forum_id=9205
  */
-#if defined(__GLIBC__) && __GLIBC_PREREQ(2, 28)
+#if defined(__GLIBC__) && __GLIBC_PREREQ(2, 37) && defined(__arm__) && __ARM_ARCH == 7
+#define WRAP_FCNTL_NAME __fcntl_time64
+#elif defined(__GLIBC__) && __GLIBC_PREREQ(2, 28)
 #define WRAP_FCNTL_NAME WRAP_NAME(fcntl)
 #else
 #define WRAP_FCNTL_NAME fcntl
@@ -39,6 +43,23 @@
 #define WRAP_FCNTL CONCAT2(__wrap_, WRAP_FCNTL_NAME)
 #define REAL_FCNTL CONCAT2(__real_, WRAP_FCNTL_NAME)
 
+/*
+ * glibc 2.37 uses __ioctl_time64 for ioctl
+ */
+#if defined(__GLIBC__) && __GLIBC_PREREQ(2, 37) && defined(__arm__) && __ARM_ARCH == 7
+#define WRAP_IOCTL_NAME __ioctl_time64
+#else
+#define WRAP_IOCTL_NAME ioctl
+#endif
+#define WRAP_IOCTL CONCAT2(__wrap_, WRAP_IOCTL_NAME)
+
+#if defined(__NR_io_pgetevents) && __BITS_PER_LONG == 32 && defined(_TIME_BITS) && _TIME_BITS == 64
+#define WRAP_IO_GETEVENTS_NAME io_getevents_time64
+#else
+#define WRAP_IO_GETEVENTS_NAME io_getevents
+#endif
+#define WRAP_IO_GETEVENTS CONCAT2(__wrap_, WRAP_IO_GETEVENTS_NAME)
+
 /*
  * will_return() is itself a macro that uses CPP "stringizing". We need a
  * macro indirection to make sure the *value* of WRAP_FUNC() is stringized
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] multipath-tools tests: fix CI failures with clang on Fedora Rawhide
  2024-04-12  9:32 [PATCH 0/2] multipath-tools: CI fixes for glibc symbol substitutions Martin Wilck
  2024-04-12  9:32 ` [PATCH 1/2] multipath-tools tests: fix CI failures on arm/v7 with glibc 2.37 Martin Wilck
@ 2024-04-12  9:32 ` Martin Wilck
  2024-04-12 15:42   ` Benjamin Marzinski
  1 sibling, 1 reply; 6+ messages in thread
From: Martin Wilck @ 2024-04-12  9:32 UTC (permalink / raw
  To: Christophe Varoqui, Benjamin Marzinski; +Cc: dm-devel

Fedora's glibc 2.39 includes the following patch:

https://patches.linaro.org/project/libc-alpha/patch/20240208184622.332678-10-adhemerval.zanella@linaro.org/

It causes open("file", O_RDONLY) to resolve to __open64_2(),
whereas it resolves to open64() with gcc, causing CI failures because of
wrong wrapper substitutions.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 tests/dmevents.c |  6 ++---
 tests/sysfs.c    | 58 ++++++++++++++++++++++++------------------------
 tests/test-lib.c |  6 ++---
 tests/wrap64.h   | 14 ++++++++++++
 4 files changed, 49 insertions(+), 35 deletions(-)

diff --git a/tests/dmevents.c b/tests/dmevents.c
index 540bf0d..395b16d 100644
--- a/tests/dmevents.c
+++ b/tests/dmevents.c
@@ -207,7 +207,7 @@ static int teardown(void **state)
 	return 0;
 }
 
-int WRAP_FUNC(open)(const char *pathname, int flags)
+int WRAP_OPEN(const char *pathname, int flags)
 {
 	assert_ptr_equal(pathname, "/dev/mapper/control");
 	assert_int_equal(flags, O_RDWR);
@@ -389,7 +389,7 @@ static void test_init_waiter_bad1(void **state)
 	struct test_data *datap = (struct test_data *)(*state);
 	if (datap == NULL)
 		skip();
-	wrap_will_return(WRAP_FUNC(open), -1);
+	wrap_will_return(WRAP_OPEN, -1);
 	assert_int_equal(init_dmevent_waiter(&datap->vecs), -1);
 	assert_ptr_equal(waiter, NULL);
 }
@@ -400,7 +400,7 @@ static void test_init_waiter_good0(void **state)
 	struct test_data *datap = (struct test_data *)(*state);
 	if (datap == NULL)
 		skip();
-	wrap_will_return(WRAP_FUNC(open), 2);
+	wrap_will_return(WRAP_OPEN, 2);
 	assert_int_equal(init_dmevent_waiter(&datap->vecs), 0);
 	assert_ptr_not_equal(waiter, NULL);
 }
diff --git a/tests/sysfs.c b/tests/sysfs.c
index fc256d8..c623d1b 100644
--- a/tests/sysfs.c
+++ b/tests/sysfs.c
@@ -29,7 +29,7 @@ char *__wrap_udev_device_get_syspath(struct udev_device *ud)
 	return val;
 }
 
-int WRAP_FUNC(open)(const char *pathname, int flags)
+int WRAP_OPEN(const char *pathname, int flags)
 {
 	int ret;
 
@@ -167,10 +167,10 @@ static void test_sagv_open_fail(void **state)
 
 	will_return(__wrap_udev_device_get_syspath, "/foo");
 	expect_condlog(4, "open '/foo/bar'");
-	expect_string(WRAP_FUNC(open), pathname, "/foo/bar");
-	expect_value(WRAP_FUNC(open), flags, O_RDONLY);
+	expect_string(WRAP_OPEN, pathname, "/foo/bar");
+	expect_value(WRAP_OPEN, flags, O_RDONLY);
 	errno = ENOENT;
-	wrap_will_return(WRAP_FUNC(open), -1);
+	wrap_will_return(WRAP_OPEN, -1);
 	expect_condlog(3, "__sysfs_attr_get_value: attribute '/foo/bar' cannot be opened");
 	assert_int_equal(sysfs_attr_get_value((void *)state, "bar",
 					      buf, sizeof(buf)), -ENOENT);
@@ -182,9 +182,9 @@ static void test_sagv_read_fail(void **state)
 
 	will_return(__wrap_udev_device_get_syspath, "/foo");
 	expect_condlog(4, "open '/foo/bar'");
-	expect_string(WRAP_FUNC(open), pathname, "/foo/bar");
-	expect_value(WRAP_FUNC(open), flags, O_RDONLY);
-	wrap_will_return(WRAP_FUNC(open), TEST_FD);
+	expect_string(WRAP_OPEN, pathname, "/foo/bar");
+	expect_value(WRAP_OPEN, flags, O_RDONLY);
+	wrap_will_return(WRAP_OPEN, TEST_FD);
 	expect_value(__wrap_read, fd, TEST_FD);
 	expect_value(__wrap_read, count, sizeof(buf));
 	errno = EISDIR;
@@ -197,9 +197,9 @@ static void test_sagv_read_fail(void **state)
 
 	will_return(__wrap_udev_device_get_syspath, "/foo");
 	expect_condlog(4, "open '/foo/baz'");
-	expect_string(WRAP_FUNC(open), pathname, "/foo/baz");
-	expect_value(WRAP_FUNC(open), flags, O_RDONLY);
-	wrap_will_return(WRAP_FUNC(open), TEST_FD);
+	expect_string(WRAP_OPEN, pathname, "/foo/baz");
+	expect_value(WRAP_OPEN, flags, O_RDONLY);
+	wrap_will_return(WRAP_OPEN, TEST_FD);
 	expect_value(__wrap_read, fd, TEST_FD);
 	expect_value(__wrap_read, count, sizeof(buf));
 	errno = EPERM;
@@ -223,9 +223,9 @@ static void _test_sagv_read(void **state, unsigned int bufsz)
 	memset(buf, '.', sizeof(buf));
 	will_return(__wrap_udev_device_get_syspath, "/foo");
 	expect_condlog(4, "open '/foo/bar'");
-	expect_string(WRAP_FUNC(open), pathname, "/foo/bar");
-	expect_value(WRAP_FUNC(open), flags, O_RDONLY);
-	wrap_will_return(WRAP_FUNC(open), TEST_FD);
+	expect_string(WRAP_OPEN, pathname, "/foo/bar");
+	expect_value(WRAP_OPEN, flags, O_RDONLY);
+	wrap_will_return(WRAP_OPEN, TEST_FD);
 	expect_value(__wrap_read, fd, TEST_FD);
 	expect_value(__wrap_read, count, bufsz);
 	will_return(__wrap_read, sizeof(input) - 1);
@@ -250,9 +250,9 @@ static void _test_sagv_read(void **state, unsigned int bufsz)
 	memset(buf, '.', sizeof(buf));
 	will_return(__wrap_udev_device_get_syspath, "/foo");
 	expect_condlog(4, "open '/foo/baz'");
-	expect_string(WRAP_FUNC(open), pathname, "/foo/baz");
-	expect_value(WRAP_FUNC(open), flags, O_RDONLY);
-	wrap_will_return(WRAP_FUNC(open), TEST_FD);
+	expect_string(WRAP_OPEN, pathname, "/foo/baz");
+	expect_value(WRAP_OPEN, flags, O_RDONLY);
+	wrap_will_return(WRAP_OPEN, TEST_FD);
 	expect_value(__wrap_read, fd, TEST_FD);
 	expect_value(__wrap_read, count, bufsz);
 	will_return(__wrap_read, sizeof(input) - 1);
@@ -301,9 +301,9 @@ static void _test_sagv_read_zeroes(void **state, unsigned int bufsz)
 	memset(buf, '.', sizeof(buf));
 	will_return(__wrap_udev_device_get_syspath, "/foo");
 	expect_condlog(4, "open '/foo/bar'");
-	expect_string(WRAP_FUNC(open), pathname, "/foo/bar");
-	expect_value(WRAP_FUNC(open), flags, O_RDONLY);
-	wrap_will_return(WRAP_FUNC(open), TEST_FD);
+	expect_string(WRAP_OPEN, pathname, "/foo/bar");
+	expect_value(WRAP_OPEN, flags, O_RDONLY);
+	wrap_will_return(WRAP_OPEN, TEST_FD);
 	expect_value(__wrap_read, fd, TEST_FD);
 	expect_value(__wrap_read, count, bufsz);
 	will_return(__wrap_read, sizeof(input) - 1);
@@ -386,10 +386,10 @@ static void test_sasv_open_fail(void **state)
 
 	will_return(__wrap_udev_device_get_syspath, "/foo");
 	expect_condlog(4, "open '/foo/bar'");
-	expect_string(WRAP_FUNC(open), pathname, "/foo/bar");
-	expect_value(WRAP_FUNC(open), flags, O_WRONLY);
+	expect_string(WRAP_OPEN, pathname, "/foo/bar");
+	expect_value(WRAP_OPEN, flags, O_WRONLY);
 	errno = EPERM;
-	wrap_will_return(WRAP_FUNC(open), -1);
+	wrap_will_return(WRAP_OPEN, -1);
 	expect_condlog(3, "sysfs_attr_set_value: attribute '/foo/bar' cannot be opened");
 	assert_int_equal(sysfs_attr_set_value((void *)state, "bar",
 					      buf, sizeof(buf)), -EPERM);
@@ -401,9 +401,9 @@ static void test_sasv_write_fail(void **state)
 
 	will_return(__wrap_udev_device_get_syspath, "/foo");
 	expect_condlog(4, "open '/foo/bar'");
-	expect_string(WRAP_FUNC(open), pathname, "/foo/bar");
-	expect_value(WRAP_FUNC(open), flags, O_WRONLY);
-	wrap_will_return(WRAP_FUNC(open), TEST_FD);
+	expect_string(WRAP_OPEN, pathname, "/foo/bar");
+	expect_value(WRAP_OPEN, flags, O_WRONLY);
+	wrap_will_return(WRAP_OPEN, TEST_FD);
 	expect_value(__wrap_write, fd, TEST_FD);
 	expect_value(__wrap_write, count, sizeof(buf));
 	errno = EISDIR;
@@ -422,9 +422,9 @@ static void _test_sasv_write(void **state, unsigned int n_written)
 	assert_in_range(n_written, 0, sizeof(buf));
 	will_return(__wrap_udev_device_get_syspath, "/foo");
 	expect_condlog(4, "open '/foo/bar'");
-	expect_string(WRAP_FUNC(open), pathname, "/foo/bar");
-	expect_value(WRAP_FUNC(open), flags, O_WRONLY);
-	wrap_will_return(WRAP_FUNC(open), TEST_FD);
+	expect_string(WRAP_OPEN, pathname, "/foo/bar");
+	expect_value(WRAP_OPEN, flags, O_WRONLY);
+	wrap_will_return(WRAP_OPEN, TEST_FD);
 	expect_value(__wrap_write, fd, TEST_FD);
 	expect_value(__wrap_write, count, sizeof(buf));
 	will_return(__wrap_write, n_written);
@@ -489,7 +489,7 @@ int main(void)
 {
 	int ret = 0;
 
-	init_test_verbosity(4);
+	init_test_verbosity(5);
 	ret += test_sysfs();
 	return ret;
 }
diff --git a/tests/test-lib.c b/tests/test-lib.c
index 665d438..cdb2780 100644
--- a/tests/test-lib.c
+++ b/tests/test-lib.c
@@ -40,17 +40,17 @@ const char default_wwid_1[] = "TEST-WWID-1";
  */
 
 
-int REAL_FUNC(open)(const char *path, int flags, int mode);
+int REAL_OPEN(const char *path, int flags, int mode);
 
 static const char _mocked_filename[] = "mocked_path";
 
-int WRAP_FUNC(open)(const char *path, int flags, int mode)
+int WRAP_OPEN(const char *path, int flags, int mode)
 {
 	condlog(4, "%s: %s", __func__, path);
 
 	if (!strcmp(path, _mocked_filename))
 		return 111;
-	return REAL_FUNC(open)(path, flags, mode);
+	return REAL_OPEN(path, flags, mode);
 }
 
 int __wrap_libmp_get_version(int which, unsigned int version[3])
diff --git a/tests/wrap64.h b/tests/wrap64.h
index 6b92751..b1dfa38 100644
--- a/tests/wrap64.h
+++ b/tests/wrap64.h
@@ -29,6 +29,20 @@
 #define WRAP_FUNC(x) CONCAT2(__wrap_, WRAP_NAME(x))
 #define REAL_FUNC(x) CONCAT2(__real_, WRAP_NAME(x))
 
+/*
+ * With clang, glibc 2.39, and _FILE_OFFSET_BITS==64,
+ * open() resolves to __open64_2().
+ */
+#if defined(__GLIBC__) && __GLIBC_PREREQ(2, 39) && \
+	defined(__clang__) && __clang__ == 1 && \
+	defined(__fortify_use_clang) && __fortify_use_clang == 1
+#define WRAP_OPEN_NAME __open64_2
+#else
+#define WRAP_OPEN_NAME WRAP_NAME(open)
+#endif
+#define WRAP_OPEN CONCAT2(__wrap_, WRAP_OPEN_NAME)
+#define REAL_OPEN CONCAT2(__real_, WRAP_OPEN_NAME)
+
 /*
  * fcntl() needs special treatment; fcntl64() has been introduced in 2.28.
  * https://savannah.gnu.org/forum/forum.php?forum_id=9205
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] multipath-tools tests: fix CI failures on arm/v7 with glibc 2.37
  2024-04-12  9:32 ` [PATCH 1/2] multipath-tools tests: fix CI failures on arm/v7 with glibc 2.37 Martin Wilck
@ 2024-04-12 15:33   ` Benjamin Marzinski
  2024-04-12 16:36     ` Martin Wilck
  0 siblings, 1 reply; 6+ messages in thread
From: Benjamin Marzinski @ 2024-04-12 15:33 UTC (permalink / raw
  To: Martin Wilck; +Cc: Christophe Varoqui, dm-devel

On Fri, Apr 12, 2024 at 11:32:57AM +0200, Martin Wilck wrote:
> glibc 2.37 has added several new wrappers around the ioctl and
> io_getevents system calls on 32 bit systems, to deal with 64bit
> time_t. These aren't resolved with cmocka's wrapping technique.
> 
> Fix this with C preprocessor trickery, similar to
> 7b217f8 ("multipath-tools: Makefile.inc: set _FILE_OFFSET_BITS=64").
> 
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
>  tests/directio.c | 22 +++++++++++-----------
>  tests/vpd.c      | 35 ++++++++++++++++++-----------------
>  tests/wrap64.h   | 23 ++++++++++++++++++++++-
>  3 files changed, 51 insertions(+), 29 deletions(-)
> 
> diff --git a/tests/directio.c b/tests/directio.c
> index cbedcc9..a5a5c0e 100644
> --- a/tests/directio.c
> +++ b/tests/directio.c
> @@ -41,9 +41,9 @@ struct timespec full_timeout = { .tv_sec = -1 };
>  #define ioctl_request_t int
>  #endif
>  
> -int __real_ioctl(int fd, ioctl_request_t request, void *argp);
> +int REAL_IOCTL(int fd, ioctl_request_t request, void *argp);
>  
> -int __wrap_ioctl(int fd, ioctl_request_t request, void *argp)
> +int WRAP_IOCTL(int fd, ioctl_request_t request, void *argp)
>  {
>  #ifdef DIO_TEST_DEV
>  	mock_type(int);
> @@ -148,10 +148,10 @@ int __wrap_io_cancel(io_context_t ctx, struct iocb *iocb, struct io_event *evt)
>  #endif
>  }
>  
> -int __real_io_getevents(io_context_t ctx, long min_nr, long nr,
> +int REAL_IO_GETEVENTS(io_context_t ctx, long min_nr, long nr,
>  			struct io_event *events, struct timespec *timeout);

Maybe I'm missing something here, but I don't see where you define
REAL_IO_GETEVENTS. Also, WRAP_IO_GETEVENTS calls __real_io_getevents()
not REAL_IO_GETEVENTS(). The same thing happens with REAL_IOCTL (it's
not defined and __read_ioctl is called in directio.c and test-lib.c).
REAL_FCNTL works how I'd expect.

-Ben

>  
> -int __wrap_io_getevents(io_context_t ctx, long min_nr, long nr,
> +int WRAP_IO_GETEVENTS(io_context_t ctx, long min_nr, long nr,
>  			struct io_event *events, struct timespec *timeout)
>  {
>  	int nr_evs;
> @@ -193,7 +193,7 @@ int __wrap_io_getevents(io_context_t ctx, long min_nr, long nr,
>  
>  static void return_io_getevents_none(void)
>  {
> -	will_return(__wrap_io_getevents, 0);
> +	wrap_will_return(WRAP_IO_GETEVENTS, 0);
>  }
>  
>  static void return_io_getevents_nr(struct timespec *ts, int nr,
> @@ -207,15 +207,15 @@ static void return_io_getevents_nr(struct timespec *ts, int nr,
>  			mock_events[i + ev_off].res = reqs[i]->blksize;
>  	}
>  	while (nr > 0) {
> -		will_return(__wrap_io_getevents, (nr > 128)? 128 : nr);
> -		will_return(__wrap_io_getevents, ts);
> -		will_return(__wrap_io_getevents, &mock_events[off + ev_off]);
> +		wrap_will_return(WRAP_IO_GETEVENTS, (nr > 128)? 128 : nr);
> +		wrap_will_return(WRAP_IO_GETEVENTS, ts);
> +		wrap_will_return(WRAP_IO_GETEVENTS, &mock_events[off + ev_off]);
>  		ts = NULL;
>  		off += 128;
>  		nr -= 128;
>  	}
>  	if (nr == 0)
> -		will_return(__wrap_io_getevents, 0);
> +		wrap_will_return(WRAP_IO_GETEVENTS, 0);
>  	ev_off += i;
>  }
>  
> @@ -251,7 +251,7 @@ static void do_libcheck_init(struct checker *c, int blocksize,
>  	struct directio_context * ct;
>  
>  	c->fd = test_fd;
> -	will_return(__wrap_ioctl, blocksize);
> +	wrap_will_return(WRAP_IOCTL, blocksize);
>  	assert_int_equal(libcheck_init(c), 0);
>  	ct = (struct directio_context *)c->context;
>  	assert_non_null(ct);
> @@ -762,7 +762,7 @@ int main(void)
>  {
>  	int ret = 0;
>  
> -	init_test_verbosity(2);
> +	init_test_verbosity(5);
>  	ret += test_directio();
>  	return ret;
>  }
> diff --git a/tests/vpd.c b/tests/vpd.c
> index 1b2d62d..e3212e6 100644
> --- a/tests/vpd.c
> +++ b/tests/vpd.c
> @@ -20,6 +20,7 @@
>  #include "vector.h"
>  #include "structs.h"
>  #include "discovery.h"
> +#include "wrap64.h"
>  #include "globals.c"
>  
>  #define VPD_BUFSIZ 4096
> @@ -58,7 +59,7 @@ static const char vendor_id[] = "Linux";
>  static const char test_id[] =
>  	"A123456789AbcDefB123456789AbcDefC123456789AbcDefD123456789AbcDef";
>  
> -int __wrap_ioctl(int fd, unsigned long request, void *param)
> +int WRAP_IOCTL(int fd, unsigned long request, void *param)
>  {
>  	int len;
>  	struct sg_io_hdr *io_hdr;
> @@ -428,8 +429,8 @@ static void test_vpd_vnd_ ## len ## _ ## wlen(void **state)             \
>  	/* Replace spaces, like code under test */			\
>  	exp_subst = subst_spaces(exp_wwid);				\
>  	free(exp_wwid);							\
> -	will_return(__wrap_ioctl, n);					\
> -	will_return(__wrap_ioctl, vt->vpdbuf);				\
> +	wrap_will_return(WRAP_IOCTL, n);				\
> +	wrap_will_return(WRAP_IOCTL, vt->vpdbuf);			\
>  	ret = get_vpd_sgio(10, 0x83, 0, vt->wwid, wlen);		\
>  	assert_correct_wwid("test_vpd_vnd_" #len "_" #wlen,		\
>  			    exp_len, ret, '1', 0, false,		\
> @@ -458,8 +459,8 @@ static void test_vpd_str_ ## typ ## _ ## len ## _ ## wlen(void **state) \
>  		exp_len--;						\
>  	if (exp_len >= wlen)						\
>  		exp_len = wlen - 1;					\
> -	will_return(__wrap_ioctl, n);					\
> -	will_return(__wrap_ioctl, vt->vpdbuf);				\
> +	wrap_will_return(WRAP_IOCTL, n);				\
> +	wrap_will_return(WRAP_IOCTL, vt->vpdbuf);			\
>  	ret = get_vpd_sgio(10, 0x83, 0, vt->wwid, wlen);		\
>  	assert_correct_wwid("test_vpd_str_" #typ "_" #len "_" #wlen,	\
>  			    exp_len, ret, byte0[type], 0,		\
> @@ -495,8 +496,8 @@ static void test_vpd_naa_ ## naa ## _ ## wlen(void **state)             \
>  									\
>  	n = create_vpd83(vt->vpdbuf, sizeof(vt->vpdbuf), test_id,	\
>  			 3, naa, 0);					\
> -	will_return(__wrap_ioctl, n);					\
> -	will_return(__wrap_ioctl, vt->vpdbuf);				\
> +	wrap_will_return(WRAP_IOCTL, n);				\
> +	wrap_will_return(WRAP_IOCTL, vt->vpdbuf);			\
>  	ret = get_vpd_sgio(10, 0x83, 0, vt->wwid, wlen);		\
>  	assert_correct_wwid("test_vpd_naa_" #naa "_" #wlen,		\
>  			    exp_len, ret, '3', '0' + naa, true,		\
> @@ -518,8 +519,8 @@ static void test_vpd_naa_##NAA##_badlen_##BAD(void **state)	\
>  	n = create_vpd83(vt->vpdbuf, sizeof(vt->vpdbuf), test_id, 3, NAA, 0); \
>  									\
>  	vt->vpdbuf[7] = BAD;						\
> -	will_return(__wrap_ioctl, n);					\
> -	will_return(__wrap_ioctl, vt->vpdbuf);				\
> +	wrap_will_return(WRAP_IOCTL, n);				\
> +	wrap_will_return(WRAP_IOCTL, vt->vpdbuf);			\
>  	ret = get_vpd_sgio(10, 0x83, 0, vt->wwid, 40);			\
>  	assert_int_equal(-ret, -ERR);					\
>  }
> @@ -545,11 +546,11 @@ static void test_vpd_eui_ ## len ## _ ## wlen ## _ ## sml(void **state)	\
>  		/* overwrite the page size to DEFAULT_SGIO_LEN + 1 */	\
>  		put_unaligned_be16(255, vt->vpdbuf + 2);		\
>  		/* this causes get_vpd_sgio to do a second ioctl */	\
> -		will_return(__wrap_ioctl, n);				\
> -		will_return(__wrap_ioctl, vt->vpdbuf);			\
> +		wrap_will_return(WRAP_IOCTL, n);			\
> +		wrap_will_return(WRAP_IOCTL, vt->vpdbuf);		\
>  	}								\
> -	will_return(__wrap_ioctl, n);					\
> -	will_return(__wrap_ioctl, vt->vpdbuf);				\
> +	wrap_will_return(WRAP_IOCTL, n);				\
> +	wrap_will_return(WRAP_IOCTL, vt->vpdbuf);			\
>  	ret = get_vpd_sgio(10, 0x83, 0, vt->wwid, wlen);		\
>  	assert_correct_wwid("test_vpd_eui_" #len "_" #wlen "_" #sml,	\
>  			    exp_len, ret, '2', 0, true,			\
> @@ -571,8 +572,8 @@ static void test_vpd_eui_badlen_##LEN##_##BAD(void **state)	\
>  	n = create_vpd83(vt->vpdbuf, sizeof(vt->vpdbuf), test_id, 2, 0, LEN); \
>  									\
>  	vt->vpdbuf[7] = BAD;						\
> -	will_return(__wrap_ioctl, n);					\
> -	will_return(__wrap_ioctl, vt->vpdbuf);				\
> +	wrap_will_return(WRAP_IOCTL, n);				\
> +	wrap_will_return(WRAP_IOCTL, vt->vpdbuf);			\
>  	ret = get_vpd_sgio(10, 0x83, 0, vt->wwid, 40);			\
>  	assert_int_equal(ret, ERR);					\
>  	if (ERR >= 0)							\
> @@ -600,8 +601,8 @@ static void test_vpd80_ ## size ## _ ## len ## _ ## wlen(void **state)  \
>  		exp_len = wlen - 1;					\
>  	n = create_vpd80(vt->vpdbuf, sizeof(vt->vpdbuf), input,		\
>  			 size, len);					\
> -	will_return(__wrap_ioctl, n);					\
> -	will_return(__wrap_ioctl, vt->vpdbuf);				\
> +	wrap_will_return(WRAP_IOCTL, n);				\
> +	wrap_will_return(WRAP_IOCTL, vt->vpdbuf);			\
>  	ret = get_vpd_sgio(10, 0x80, 0, vt->wwid, wlen);		\
>  	assert_correct_wwid("test_vpd80_" #size "_" #len "_" #wlen,	\
>  			    exp_len, ret, 0, 0, false,			\
> diff --git a/tests/wrap64.h b/tests/wrap64.h
> index 8c91d27..6b92751 100644
> --- a/tests/wrap64.h
> +++ b/tests/wrap64.h
> @@ -1,5 +1,7 @@
>  #ifndef _WRAP64_H
>  #define _WRAP64_H 1
> +#include <syscall.h>
> +#include <linux/types.h>
>  #include "util.h"
>  
>  /*
> @@ -31,7 +33,9 @@
>   * fcntl() needs special treatment; fcntl64() has been introduced in 2.28.
>   * https://savannah.gnu.org/forum/forum.php?forum_id=9205
>   */
> -#if defined(__GLIBC__) && __GLIBC_PREREQ(2, 28)
> +#if defined(__GLIBC__) && __GLIBC_PREREQ(2, 37) && defined(__arm__) && __ARM_ARCH == 7
> +#define WRAP_FCNTL_NAME __fcntl_time64
> +#elif defined(__GLIBC__) && __GLIBC_PREREQ(2, 28)
>  #define WRAP_FCNTL_NAME WRAP_NAME(fcntl)
>  #else
>  #define WRAP_FCNTL_NAME fcntl
> @@ -39,6 +43,23 @@
>  #define WRAP_FCNTL CONCAT2(__wrap_, WRAP_FCNTL_NAME)
>  #define REAL_FCNTL CONCAT2(__real_, WRAP_FCNTL_NAME)
>  
> +/*
> + * glibc 2.37 uses __ioctl_time64 for ioctl
> + */
> +#if defined(__GLIBC__) && __GLIBC_PREREQ(2, 37) && defined(__arm__) && __ARM_ARCH == 7
> +#define WRAP_IOCTL_NAME __ioctl_time64
> +#else
> +#define WRAP_IOCTL_NAME ioctl
> +#endif
> +#define WRAP_IOCTL CONCAT2(__wrap_, WRAP_IOCTL_NAME)
> +
> +#if defined(__NR_io_pgetevents) && __BITS_PER_LONG == 32 && defined(_TIME_BITS) && _TIME_BITS == 64
> +#define WRAP_IO_GETEVENTS_NAME io_getevents_time64
> +#else
> +#define WRAP_IO_GETEVENTS_NAME io_getevents
> +#endif
> +#define WRAP_IO_GETEVENTS CONCAT2(__wrap_, WRAP_IO_GETEVENTS_NAME)
> +
>  /*
>   * will_return() is itself a macro that uses CPP "stringizing". We need a
>   * macro indirection to make sure the *value* of WRAP_FUNC() is stringized
> -- 
> 2.44.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] multipath-tools tests: fix CI failures with clang on Fedora Rawhide
  2024-04-12  9:32 ` [PATCH 2/2] multipath-tools tests: fix CI failures with clang on Fedora Rawhide Martin Wilck
@ 2024-04-12 15:42   ` Benjamin Marzinski
  0 siblings, 0 replies; 6+ messages in thread
From: Benjamin Marzinski @ 2024-04-12 15:42 UTC (permalink / raw
  To: Martin Wilck; +Cc: Christophe Varoqui, dm-devel

On Fri, Apr 12, 2024 at 11:32:58AM +0200, Martin Wilck wrote:
> Fedora's glibc 2.39 includes the following patch:
> 
> https://patches.linaro.org/project/libc-alpha/patch/20240208184622.332678-10-adhemerval.zanella@linaro.org/
> 
> It causes open("file", O_RDONLY) to resolve to __open64_2(),
> whereas it resolves to open64() with gcc, causing CI failures because of
> wrong wrapper substitutions.
> 
> Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
>  tests/dmevents.c |  6 ++---
>  tests/sysfs.c    | 58 ++++++++++++++++++++++++------------------------
>  tests/test-lib.c |  6 ++---
>  tests/wrap64.h   | 14 ++++++++++++
>  4 files changed, 49 insertions(+), 35 deletions(-)
> 
> diff --git a/tests/dmevents.c b/tests/dmevents.c
> index 540bf0d..395b16d 100644
> --- a/tests/dmevents.c
> +++ b/tests/dmevents.c
> @@ -207,7 +207,7 @@ static int teardown(void **state)
>  	return 0;
>  }
>  
> -int WRAP_FUNC(open)(const char *pathname, int flags)
> +int WRAP_OPEN(const char *pathname, int flags)
>  {
>  	assert_ptr_equal(pathname, "/dev/mapper/control");
>  	assert_int_equal(flags, O_RDWR);
> @@ -389,7 +389,7 @@ static void test_init_waiter_bad1(void **state)
>  	struct test_data *datap = (struct test_data *)(*state);
>  	if (datap == NULL)
>  		skip();
> -	wrap_will_return(WRAP_FUNC(open), -1);
> +	wrap_will_return(WRAP_OPEN, -1);
>  	assert_int_equal(init_dmevent_waiter(&datap->vecs), -1);
>  	assert_ptr_equal(waiter, NULL);
>  }
> @@ -400,7 +400,7 @@ static void test_init_waiter_good0(void **state)
>  	struct test_data *datap = (struct test_data *)(*state);
>  	if (datap == NULL)
>  		skip();
> -	wrap_will_return(WRAP_FUNC(open), 2);
> +	wrap_will_return(WRAP_OPEN, 2);
>  	assert_int_equal(init_dmevent_waiter(&datap->vecs), 0);
>  	assert_ptr_not_equal(waiter, NULL);
>  }
> diff --git a/tests/sysfs.c b/tests/sysfs.c
> index fc256d8..c623d1b 100644
> --- a/tests/sysfs.c
> +++ b/tests/sysfs.c
> @@ -29,7 +29,7 @@ char *__wrap_udev_device_get_syspath(struct udev_device *ud)
>  	return val;
>  }
>  
> -int WRAP_FUNC(open)(const char *pathname, int flags)
> +int WRAP_OPEN(const char *pathname, int flags)
>  {
>  	int ret;
>  
> @@ -167,10 +167,10 @@ static void test_sagv_open_fail(void **state)
>  
>  	will_return(__wrap_udev_device_get_syspath, "/foo");
>  	expect_condlog(4, "open '/foo/bar'");
> -	expect_string(WRAP_FUNC(open), pathname, "/foo/bar");
> -	expect_value(WRAP_FUNC(open), flags, O_RDONLY);
> +	expect_string(WRAP_OPEN, pathname, "/foo/bar");
> +	expect_value(WRAP_OPEN, flags, O_RDONLY);
>  	errno = ENOENT;
> -	wrap_will_return(WRAP_FUNC(open), -1);
> +	wrap_will_return(WRAP_OPEN, -1);
>  	expect_condlog(3, "__sysfs_attr_get_value: attribute '/foo/bar' cannot be opened");
>  	assert_int_equal(sysfs_attr_get_value((void *)state, "bar",
>  					      buf, sizeof(buf)), -ENOENT);
> @@ -182,9 +182,9 @@ static void test_sagv_read_fail(void **state)
>  
>  	will_return(__wrap_udev_device_get_syspath, "/foo");
>  	expect_condlog(4, "open '/foo/bar'");
> -	expect_string(WRAP_FUNC(open), pathname, "/foo/bar");
> -	expect_value(WRAP_FUNC(open), flags, O_RDONLY);
> -	wrap_will_return(WRAP_FUNC(open), TEST_FD);
> +	expect_string(WRAP_OPEN, pathname, "/foo/bar");
> +	expect_value(WRAP_OPEN, flags, O_RDONLY);
> +	wrap_will_return(WRAP_OPEN, TEST_FD);
>  	expect_value(__wrap_read, fd, TEST_FD);
>  	expect_value(__wrap_read, count, sizeof(buf));
>  	errno = EISDIR;
> @@ -197,9 +197,9 @@ static void test_sagv_read_fail(void **state)
>  
>  	will_return(__wrap_udev_device_get_syspath, "/foo");
>  	expect_condlog(4, "open '/foo/baz'");
> -	expect_string(WRAP_FUNC(open), pathname, "/foo/baz");
> -	expect_value(WRAP_FUNC(open), flags, O_RDONLY);
> -	wrap_will_return(WRAP_FUNC(open), TEST_FD);
> +	expect_string(WRAP_OPEN, pathname, "/foo/baz");
> +	expect_value(WRAP_OPEN, flags, O_RDONLY);
> +	wrap_will_return(WRAP_OPEN, TEST_FD);
>  	expect_value(__wrap_read, fd, TEST_FD);
>  	expect_value(__wrap_read, count, sizeof(buf));
>  	errno = EPERM;
> @@ -223,9 +223,9 @@ static void _test_sagv_read(void **state, unsigned int bufsz)
>  	memset(buf, '.', sizeof(buf));
>  	will_return(__wrap_udev_device_get_syspath, "/foo");
>  	expect_condlog(4, "open '/foo/bar'");
> -	expect_string(WRAP_FUNC(open), pathname, "/foo/bar");
> -	expect_value(WRAP_FUNC(open), flags, O_RDONLY);
> -	wrap_will_return(WRAP_FUNC(open), TEST_FD);
> +	expect_string(WRAP_OPEN, pathname, "/foo/bar");
> +	expect_value(WRAP_OPEN, flags, O_RDONLY);
> +	wrap_will_return(WRAP_OPEN, TEST_FD);
>  	expect_value(__wrap_read, fd, TEST_FD);
>  	expect_value(__wrap_read, count, bufsz);
>  	will_return(__wrap_read, sizeof(input) - 1);
> @@ -250,9 +250,9 @@ static void _test_sagv_read(void **state, unsigned int bufsz)
>  	memset(buf, '.', sizeof(buf));
>  	will_return(__wrap_udev_device_get_syspath, "/foo");
>  	expect_condlog(4, "open '/foo/baz'");
> -	expect_string(WRAP_FUNC(open), pathname, "/foo/baz");
> -	expect_value(WRAP_FUNC(open), flags, O_RDONLY);
> -	wrap_will_return(WRAP_FUNC(open), TEST_FD);
> +	expect_string(WRAP_OPEN, pathname, "/foo/baz");
> +	expect_value(WRAP_OPEN, flags, O_RDONLY);
> +	wrap_will_return(WRAP_OPEN, TEST_FD);
>  	expect_value(__wrap_read, fd, TEST_FD);
>  	expect_value(__wrap_read, count, bufsz);
>  	will_return(__wrap_read, sizeof(input) - 1);
> @@ -301,9 +301,9 @@ static void _test_sagv_read_zeroes(void **state, unsigned int bufsz)
>  	memset(buf, '.', sizeof(buf));
>  	will_return(__wrap_udev_device_get_syspath, "/foo");
>  	expect_condlog(4, "open '/foo/bar'");
> -	expect_string(WRAP_FUNC(open), pathname, "/foo/bar");
> -	expect_value(WRAP_FUNC(open), flags, O_RDONLY);
> -	wrap_will_return(WRAP_FUNC(open), TEST_FD);
> +	expect_string(WRAP_OPEN, pathname, "/foo/bar");
> +	expect_value(WRAP_OPEN, flags, O_RDONLY);
> +	wrap_will_return(WRAP_OPEN, TEST_FD);
>  	expect_value(__wrap_read, fd, TEST_FD);
>  	expect_value(__wrap_read, count, bufsz);
>  	will_return(__wrap_read, sizeof(input) - 1);
> @@ -386,10 +386,10 @@ static void test_sasv_open_fail(void **state)
>  
>  	will_return(__wrap_udev_device_get_syspath, "/foo");
>  	expect_condlog(4, "open '/foo/bar'");
> -	expect_string(WRAP_FUNC(open), pathname, "/foo/bar");
> -	expect_value(WRAP_FUNC(open), flags, O_WRONLY);
> +	expect_string(WRAP_OPEN, pathname, "/foo/bar");
> +	expect_value(WRAP_OPEN, flags, O_WRONLY);
>  	errno = EPERM;
> -	wrap_will_return(WRAP_FUNC(open), -1);
> +	wrap_will_return(WRAP_OPEN, -1);
>  	expect_condlog(3, "sysfs_attr_set_value: attribute '/foo/bar' cannot be opened");
>  	assert_int_equal(sysfs_attr_set_value((void *)state, "bar",
>  					      buf, sizeof(buf)), -EPERM);
> @@ -401,9 +401,9 @@ static void test_sasv_write_fail(void **state)
>  
>  	will_return(__wrap_udev_device_get_syspath, "/foo");
>  	expect_condlog(4, "open '/foo/bar'");
> -	expect_string(WRAP_FUNC(open), pathname, "/foo/bar");
> -	expect_value(WRAP_FUNC(open), flags, O_WRONLY);
> -	wrap_will_return(WRAP_FUNC(open), TEST_FD);
> +	expect_string(WRAP_OPEN, pathname, "/foo/bar");
> +	expect_value(WRAP_OPEN, flags, O_WRONLY);
> +	wrap_will_return(WRAP_OPEN, TEST_FD);
>  	expect_value(__wrap_write, fd, TEST_FD);
>  	expect_value(__wrap_write, count, sizeof(buf));
>  	errno = EISDIR;
> @@ -422,9 +422,9 @@ static void _test_sasv_write(void **state, unsigned int n_written)
>  	assert_in_range(n_written, 0, sizeof(buf));
>  	will_return(__wrap_udev_device_get_syspath, "/foo");
>  	expect_condlog(4, "open '/foo/bar'");
> -	expect_string(WRAP_FUNC(open), pathname, "/foo/bar");
> -	expect_value(WRAP_FUNC(open), flags, O_WRONLY);
> -	wrap_will_return(WRAP_FUNC(open), TEST_FD);
> +	expect_string(WRAP_OPEN, pathname, "/foo/bar");
> +	expect_value(WRAP_OPEN, flags, O_WRONLY);
> +	wrap_will_return(WRAP_OPEN, TEST_FD);
>  	expect_value(__wrap_write, fd, TEST_FD);
>  	expect_value(__wrap_write, count, sizeof(buf));
>  	will_return(__wrap_write, n_written);
> @@ -489,7 +489,7 @@ int main(void)
>  {
>  	int ret = 0;
>  
> -	init_test_verbosity(4);
> +	init_test_verbosity(5);
>  	ret += test_sysfs();
>  	return ret;
>  }
> diff --git a/tests/test-lib.c b/tests/test-lib.c
> index 665d438..cdb2780 100644
> --- a/tests/test-lib.c
> +++ b/tests/test-lib.c
> @@ -40,17 +40,17 @@ const char default_wwid_1[] = "TEST-WWID-1";
>   */
>  
>  
> -int REAL_FUNC(open)(const char *path, int flags, int mode);
> +int REAL_OPEN(const char *path, int flags, int mode);
>  
>  static const char _mocked_filename[] = "mocked_path";
>  
> -int WRAP_FUNC(open)(const char *path, int flags, int mode)
> +int WRAP_OPEN(const char *path, int flags, int mode)
>  {
>  	condlog(4, "%s: %s", __func__, path);
>  
>  	if (!strcmp(path, _mocked_filename))
>  		return 111;
> -	return REAL_FUNC(open)(path, flags, mode);
> +	return REAL_OPEN(path, flags, mode);
>  }
>  
>  int __wrap_libmp_get_version(int which, unsigned int version[3])
> diff --git a/tests/wrap64.h b/tests/wrap64.h
> index 6b92751..b1dfa38 100644
> --- a/tests/wrap64.h
> +++ b/tests/wrap64.h
> @@ -29,6 +29,20 @@
>  #define WRAP_FUNC(x) CONCAT2(__wrap_, WRAP_NAME(x))
>  #define REAL_FUNC(x) CONCAT2(__real_, WRAP_NAME(x))
>  
> +/*
> + * With clang, glibc 2.39, and _FILE_OFFSET_BITS==64,
> + * open() resolves to __open64_2().
> + */
> +#if defined(__GLIBC__) && __GLIBC_PREREQ(2, 39) && \
> +	defined(__clang__) && __clang__ == 1 && \
> +	defined(__fortify_use_clang) && __fortify_use_clang == 1
> +#define WRAP_OPEN_NAME __open64_2
> +#else
> +#define WRAP_OPEN_NAME WRAP_NAME(open)
> +#endif
> +#define WRAP_OPEN CONCAT2(__wrap_, WRAP_OPEN_NAME)
> +#define REAL_OPEN CONCAT2(__real_, WRAP_OPEN_NAME)
> +
>  /*
>   * fcntl() needs special treatment; fcntl64() has been introduced in 2.28.
>   * https://savannah.gnu.org/forum/forum.php?forum_id=9205
> -- 
> 2.44.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] multipath-tools tests: fix CI failures on arm/v7 with glibc 2.37
  2024-04-12 15:33   ` Benjamin Marzinski
@ 2024-04-12 16:36     ` Martin Wilck
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Wilck @ 2024-04-12 16:36 UTC (permalink / raw
  To: Benjamin Marzinski; +Cc: Christophe Varoqui, dm-devel

On Fri, 2024-04-12 at 11:33 -0400, Benjamin Marzinski wrote:
> On Fri, Apr 12, 2024 at 11:32:57AM +0200, Martin Wilck wrote:
> >  
> > -int __real_io_getevents(io_context_t ctx, long min_nr, long nr,
> > +int REAL_IO_GETEVENTS(io_context_t ctx, long min_nr, long nr,
> >  			struct io_event *events, struct timespec
> > *timeout);
> 
> Maybe I'm missing something here, but I don't see where you define
> REAL_IO_GETEVENTS. Also, WRAP_IO_GETEVENTS calls
> __real_io_getevents()
> not REAL_IO_GETEVENTS(). The same thing happens with REAL_IOCTL (it's
> not defined and __read_ioctl is called in directio.c and test-lib.c).
> REAL_FCNTL works how I'd expect.

Sigh :-(

Obviously, the CI doesn't run the DIO_TEST_DEV case for arm/v7.
Thanks for spotting this.

Martin


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-12 16:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-12  9:32 [PATCH 0/2] multipath-tools: CI fixes for glibc symbol substitutions Martin Wilck
2024-04-12  9:32 ` [PATCH 1/2] multipath-tools tests: fix CI failures on arm/v7 with glibc 2.37 Martin Wilck
2024-04-12 15:33   ` Benjamin Marzinski
2024-04-12 16:36     ` Martin Wilck
2024-04-12  9:32 ` [PATCH 2/2] multipath-tools tests: fix CI failures with clang on Fedora Rawhide Martin Wilck
2024-04-12 15:42   ` Benjamin Marzinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).