pacemaker/0001-Tests-Fix-running-pcmk__procfs_pid2path_test-on-i686.patch
Klaus Wenninger 059b7a7411 * Wed Oct 26 2022 Klaus Wenninger <kwenning@redhat.com> - 2.1.5-0.1.rc1
- Update for new upstream tarball for release candidate: Pacemaker-2.1.5-rc1,
  for full details, see included ChangeLog file or
  https://github.com/ClusterLabs/pacemaker/releases/tag/Pacemaker-2.1.5-rc1
- add patch to fix 32 bit issue with cmocka
2022-11-08 21:27:51 +01:00

106 lines
3.4 KiB
Diff

From d57379d2a2e0da585b101911abbe7bfbb571ce90 Mon Sep 17 00:00:00 2001
From: Chris Lumens <clumens@redhat.com>
Date: Mon, 7 Nov 2022 15:31:00 -0500
Subject: [PATCH] Tests: Fix running pcmk__procfs_pid2path_test on i686.
The expect_value/check_expected_ptr combo from cmocka fails on i686, but
only if the pointer in question is a statically declared buffer. In
this case, somewhere in the giant pile of casting that occurs in cmocka,
one of the variable or expected value ends up a 32-bit quantity while
the other ends up a 64-bit quantity. The comparison then fails.
Changing these variables into dynamically allocated buffers makes
everything work out fine. This is necessary to get builds working
again.
---
.../tests/procfs/pcmk__procfs_pid2path_test.c | 27 ++++++++++++++--------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/lib/common/tests/procfs/pcmk__procfs_pid2path_test.c b/lib/common/tests/procfs/pcmk__procfs_pid2path_test.c
index 97c7eb4..4b5e240 100644
--- a/lib/common/tests/procfs/pcmk__procfs_pid2path_test.c
+++ b/lib/common/tests/procfs/pcmk__procfs_pid2path_test.c
@@ -20,61 +20,70 @@
static void
no_exe_file(void **state)
{
- char path[PATH_MAX];
+ size_t len = PATH_MAX;
+ char *path = calloc(len, sizeof(char));
// Set readlink() errno and link contents
pcmk__mock_readlink = true;
expect_string(__wrap_readlink, path, "/proc/1000/exe");
expect_value(__wrap_readlink, buf, path);
- expect_value(__wrap_readlink, bufsize, sizeof(path) - 1);
+ expect_value(__wrap_readlink, bufsize, len - 1);
will_return(__wrap_readlink, ENOENT);
will_return(__wrap_readlink, NULL);
- assert_int_equal(pcmk__procfs_pid2path(1000, path, sizeof(path)), ENOENT);
+ assert_int_equal(pcmk__procfs_pid2path(1000, path, len), ENOENT);
pcmk__mock_readlink = false;
+
+ free(path);
}
static void
contents_too_long(void **state)
{
- char path[10];
+ size_t len = 10;
+ char *path = calloc(len, sizeof(char));
// Set readlink() errno and link contents
pcmk__mock_readlink = true;
expect_string(__wrap_readlink, path, "/proc/1000/exe");
expect_value(__wrap_readlink, buf, path);
- expect_value(__wrap_readlink, bufsize, sizeof(path) - 1);
+ expect_value(__wrap_readlink, bufsize, len - 1);
will_return(__wrap_readlink, 0);
will_return(__wrap_readlink, "/more/than/10/characters");
- assert_int_equal(pcmk__procfs_pid2path(1000, path, sizeof(path)),
+ assert_int_equal(pcmk__procfs_pid2path(1000, path, len),
ENAMETOOLONG);
pcmk__mock_readlink = false;
+
+ free(path);
}
static void
contents_ok(void **state)
{
- char path[PATH_MAX];
+ size_t len = PATH_MAX;
+ char *path = calloc(len, sizeof(char));
// Set readlink() errno and link contents
pcmk__mock_readlink = true;
expect_string(__wrap_readlink, path, "/proc/1000/exe");
expect_value(__wrap_readlink, buf, path);
- expect_value(__wrap_readlink, bufsize, sizeof(path) - 1);
+ expect_value(__wrap_readlink, bufsize, len - 1);
will_return(__wrap_readlink, 0);
will_return(__wrap_readlink, "/ok");
- assert_int_equal(pcmk__procfs_pid2path((pid_t) 1000, path, sizeof(path)),
+ assert_int_equal(pcmk__procfs_pid2path((pid_t) 1000, path, len),
pcmk_rc_ok);
assert_string_equal(path, "/ok");
pcmk__mock_readlink = false;
+
+ free(path);
}
PCMK__UNIT_TEST(NULL, NULL,
--
1.8.3.1