commit:     bcd40797c9334adc5e7475dff86714c351b7bbfa
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Feb  5 21:09:46 2021 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Feb  5 21:09:52 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bcd40797

net-mail/dovecot: fix test failures on 32-bit systems

Closes: https://bugs.gentoo.org/764713
Package-Manager: Portage-3.0.14, Repoman-3.0.2
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net-mail/dovecot/dovecot-2.3.13-r100.ebuild        |  4 +-
 .../files/dovecot-2.3.13-32-bit-tests-1.patch      | 52 ++++++++++++++++++++++
 .../files/dovecot-2.3.13-32-bit-tests-2.patch      | 27 +++++++++++
 3 files changed, 82 insertions(+), 1 deletion(-)

diff --git a/net-mail/dovecot/dovecot-2.3.13-r100.ebuild 
b/net-mail/dovecot/dovecot-2.3.13-r100.ebuild
index ff93adddf94..15bc481ff78 100644
--- a/net-mail/dovecot/dovecot-2.3.13-r100.ebuild
+++ b/net-mail/dovecot/dovecot-2.3.13-r100.ebuild
@@ -78,7 +78,9 @@ PATCHES=(
        "${FILESDIR}/${PN}"-autoconf-lua-version.patch
        "${FILESDIR}/${PN}"-unwind-generic.patch
        "${FILESDIR}/${PN}"-socket-name-too-long.patch
-       )
+       "${FILESDIR}/${P}"-32-bit-tests-1.patch
+       "${FILESDIR}/${P}"-32-bit-tests-2.patch
+)
 
 pkg_setup() {
        use lua && lua-single_pkg_setup

diff --git a/net-mail/dovecot/files/dovecot-2.3.13-32-bit-tests-1.patch 
b/net-mail/dovecot/files/dovecot-2.3.13-32-bit-tests-1.patch
new file mode 100644
index 00000000000..204424c5ebb
--- /dev/null
+++ b/net-mail/dovecot/files/dovecot-2.3.13-32-bit-tests-1.patch
@@ -0,0 +1,52 @@
+https://bugs.gentoo.org/764713
+https://github.com/dovecot/core/commit/2cc1feca9087651902a5ea3cda021c8a0b3217ce.patch
+
+From 2cc1feca9087651902a5ea3cda021c8a0b3217ce Mon Sep 17 00:00:00 2001
+From: Paul Howarth <p...@city-fan.org>
+Date: Mon, 4 Jan 2021 16:31:03 +0000
+Subject: [PATCH] lib: Fix timeval_cmp_margin for 32-bit systems
+
+The test suite compares times with seconds values of -INT_MAX and
+INT_MAX. The result of this comparison does not fit in a value of
+type int and so the test suite fails on 32-bit systems where time_t
+is an int. To fix this, calculations on seconds values are done
+using long long integers.
+
+Broken by 16ab5542
+---
+ src/lib/time-util.c | 12 +++++++-----
+ 1 file changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/src/lib/time-util.c b/src/lib/time-util.c
+index 294bb02310..3f4cd01c9e 100644
+--- a/src/lib/time-util.c
++++ b/src/lib/time-util.c
+@@ -38,21 +38,23 @@ int timeval_cmp(const struct timeval *tv1, const struct 
timeval *tv2)
+ int timeval_cmp_margin(const struct timeval *tv1, const struct timeval *tv2,
+       unsigned int usec_margin)
+ {
+-      long long usecs_diff;
++      long long secs_diff, usecs_diff;
+       int sec_margin, ret;
+ 
+       if (tv1->tv_sec < tv2->tv_sec) {
+               sec_margin = ((int)usec_margin / 1000000) + 1;
+-              if ((tv2->tv_sec - tv1->tv_sec) > sec_margin)
++              secs_diff = (long long)tv2->tv_sec - (long long)tv1->tv_sec;
++              if (secs_diff > sec_margin)
+                       return -1;
+-              usecs_diff = (tv2->tv_sec - tv1->tv_sec) * 1000000LL +
++              usecs_diff = secs_diff * 1000000LL +
+                       (tv2->tv_usec - tv1->tv_usec);
+               ret = -1;
+       } else if (tv1->tv_sec > tv2->tv_sec) {
+               sec_margin = ((int)usec_margin / 1000000) + 1;
+-              if ((tv1->tv_sec - tv2->tv_sec) > sec_margin)
++              secs_diff = (long long)tv1->tv_sec - (long long)tv2->tv_sec;
++              if (secs_diff > sec_margin)
+                       return 1;
+-              usecs_diff = (tv1->tv_sec - tv2->tv_sec) * 1000000LL +
++              usecs_diff = secs_diff * 1000000LL +
+                       (tv1->tv_usec - tv2->tv_usec);
+               ret = 1;
+       } else if (tv1->tv_usec < tv2->tv_usec) {

diff --git a/net-mail/dovecot/files/dovecot-2.3.13-32-bit-tests-2.patch 
b/net-mail/dovecot/files/dovecot-2.3.13-32-bit-tests-2.patch
new file mode 100644
index 00000000000..8956773b43e
--- /dev/null
+++ b/net-mail/dovecot/files/dovecot-2.3.13-32-bit-tests-2.patch
@@ -0,0 +1,27 @@
+https://bugs.gentoo.org/764713
+https://github.com/dovecot/core/commit/01366bd18ea98bf6979328ff8580488920a33f0c
+
+From 01366bd18ea98bf6979328ff8580488920a33f0c Mon Sep 17 00:00:00 2001
+From: Aki Tuomi <aki.tu...@open-xchange.com>
+Date: Thu, 4 Feb 2021 08:44:46 +0200
+Subject: [PATCH] lib: test-time-util - Use correct types for test case
+
+Fixes type mismatch on 32-bit systems.
+---
+ src/lib/test-time-util.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/lib/test-time-util.c b/src/lib/test-time-util.c
+index cfa322048e..139db0ec5d 100644
+--- a/src/lib/test-time-util.c
++++ b/src/lib/test-time-util.c
+@@ -358,7 +358,8 @@ static void test_str_to_timeval(void)
+ {
+       struct {
+               const char *str;
+-              unsigned int tv_sec, tv_usec;
++              time_t tv_sec;
++              suseconds_t tv_usec;
+       } tests[] = {
+               { "0", 0, 0 },
+               { "0.0", 0, 0 },

Reply via email to