Subject: [bug#71993] [PATCH core-updates 0/2] Don't use libfaketime for key package tests on 32bit systems

From: Ludovic Courtès <[email-masked]>
Date: Mon, 08 Jul 2024 14:26:43 +0200

Hello!

Christopher Baines <[email-masked]> skribis:

>   gnu: nss: Don't use libfaketime on 32bit systems.
>   gnu: python-pyopenssl: Don't use libfaketime on 32bit systems.

Here’s an alternate solution: getting closer to fixing libfaketime.
After this patch, there are still issues with the
‘pthread_cond_timedwait’ tests that would probably need investigation or
just plain skipping.

diff --git a/gnu/packages/check.scm b/gnu/packages/check.scm
index bc341943f02..8714086be89 100644
--- a/gnu/packages/check.scm
+++ b/gnu/packages/check.scm
@@ -3477,6 +3477,24 @@ (define-public libfaketime
               (substitute* "src/faketime.c"
                 (("\"date\"")
                  (format #f "~s" (search-input-file inputs "bin/date"))))))
+
+          #$@(if (target-64bit?)
+                 #~()
+                 #~((add-after 'unpack 'switch-libc-call
+                      (lambda _
+                        (substitute* "src/libfaketime.c"
+                          (("#define _GNU_SOURCE")
+                           ;; Make sure to use the 64-bit 'struct timespec' in
+                           ;; replacement functions.
+                           (string-append "#define _GNU_SOURCE\n"
+                                          "#define _FILE_OFFSET_BITS 64\n"
+                                          "#define _TIME_BITS 64\n"))
+                          (("\"__clock_gettime\"")
+                           ;; Replace '__clock_gettime64' rather than
+                           ;; '__clock_gettime64' since this is what
+                           ;; newly-built applications use.
+                           "\"__clock_gettime64\""))))))
+
           (replace 'configure
             (lambda* (#:key outputs #:allow-other-keys)
               (setenv "CC" #$(cc-for-target))
@@ -3495,8 +3513,14 @@ (define-public libfaketime
           (add-before 'check 'pre-check
             (lambda _
               (substitute* "test/functests/test_exclude_mono.sh"
-                (("/bin/bash") (which "bash"))))))))
-    (native-inputs (list perl))         ;for tests
+                (("/bin/bash") (which "bash")))
+              #$@(if (target-64bit?)
+                     #~()
+                     ;; This test uses Perl to call 'clock_gettime' and fails
+                     ;; for unclear reasons on i686-linux.
+                     #~((delete-file
+                         "test/functests/test_exclude_mono.sh"))))))))
+    (native-inputs (list perl))                   ;for tests
     (inputs (list coreutils-minimal))
     (synopsis "Fake the system time for single applications")
     (description

Another option: use ‘datefudge’ rather than ‘libfaketime’ for those
packages.

Ludo’.