Subject: Re: bug#29886: tests/rm/rm-readdir-fail is failing with SIGBUS on Gentoo sparc
From: Pádraig Brady <[email-masked]>
To: Thomas Deutschmann <[email-masked]>, Paul Eggert <[email-masked]>, [email-masked], Rolf Eike Beer <[email-masked]>
Date: Sun, 15 Jul 2018 11:02:09 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

On 15/07/18 07:28, Thomas Deutschmann wrote:
> On 2018-07-15 03:21, Pádraig Brady wrote:
>> Does this skip the test for you?

> rm-readdir-fail.sh: set-up failure: failed to build shared library
> ERROR: tests/rm/rm-readdir-fail.sh

Thanks for confirming your __LP64__ setting.
I'm going to go with the attached.

thanks,
Pádraig.
From 63ced8b6482dbc7e1471198e195b83181967b338 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email-masked]>
Date: Sun, 15 Jul 2018 10:50:53 -0700
Subject: [PATCH] tests: avoid false failure on sparc 32 bit

* tests/rm/rm-readdir-fail.sh: Skip the test entirely on 32 bit,
so we avoid conflating the 32bit and 64 bit types, as that
triggers alignment issues (SIGBUS) on Gentoo sparc.
Fixes https://bugs.gnu.org/29886
---
 tests/rm/rm-readdir-fail.sh | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/tests/rm/rm-readdir-fail.sh b/tests/rm/rm-readdir-fail.sh
index 75fa339..6b68c4f 100755
--- a/tests/rm/rm-readdir-fail.sh
+++ b/tests/rm/rm-readdir-fail.sh
@@ -40,6 +40,15 @@ cat > k.c <<\EOF || framework_failure_
 
 struct dirent *readdir (DIR *dirp)
 {
+  static int count = 1;
+
+#ifndef __LP64__
+  if (count == 1)
+    fclose (fopen ("32bit", "w"));
+  errno = ENOSYS;
+  return NULL;
+#endif
+
   static struct dirent *(*real_readdir)(DIR *dirp);
   if (! real_readdir && ! (real_readdir = dlsym (RTLD_NEXT, "readdir")))
     {
@@ -56,7 +65,6 @@ struct dirent *readdir (DIR *dirp)
     }
 
   /* Flag that LD_PRELOAD and above functions work.  */
-  static int count = 1;
   if (count == 1)
     fclose (fopen ("preloaded", "w"));
 
@@ -90,8 +98,10 @@ for READDIR_PARTIAL in '' '1'; do
   rm -f preloaded
   (export LD_PRELOAD=$LD_PRELOAD:./k.so
    returns_ 1 rm -Rf dir 2>>errt) || fail=1
-  if ! test -f preloaded; then
-    cat err
+  if test -f 32bit; then
+    skip_ 'This test only supports 64 bit systems'
+  elif ! test -f preloaded; then
+    cat errt
     skip_ "internal test failure: maybe LD_PRELOAD doesn't work?"
   fi
 done
-- 
2.9.3