]> Savannah Git Hosting - gnulib.git/commitdiff
nan, snan tests: Avoid test failures.
authorBruno Haible <bruno@clisp.org>
Thu, 12 Oct 2023 23:04:27 +0000 (01:04 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 12 Oct 2023 23:04:27 +0000 (01:04 +0200)
* tests/test-nan-1.c (main): Special handling of arm CPUs with software
floating-point emulation.
* tests/test-snan-1.c (main): Likewise. Disable tests that are known to
fail.
* tests/test-snan-2.c (main): Skip tests that are known to fail.
* modules/snan-tests (Files): Add m4/math_h.m4.
(configure.ac): Require gl_LONG_DOUBLE_VS_DOUBLE.
* m4/math_h.m4 (gl_LONG_DOUBLE_VS_DOUBLE): Mention also NetBSD/sparc32.

ChangeLog
m4/math_h.m4
modules/snan-tests
tests/test-nan-1.c
tests/test-snan-1.c
tests/test-snan-2.c

index 2a2ed122e1cd24b2336fc20ef04c24a2c9983963..7112234f8f1e7e888af348d085b7905d161732b6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2023-10-12  Bruno Haible  <bruno@clisp.org>
+
+       nan, snan tests: Avoid test failures.
+       * tests/test-nan-1.c (main): Special handling of arm CPUs with software
+       floating-point emulation.
+       * tests/test-snan-1.c (main): Likewise. Disable tests that are known to
+       fail.
+       * tests/test-snan-2.c (main): Skip tests that are known to fail.
+       * modules/snan-tests (Files): Add m4/math_h.m4.
+       (configure.ac): Require gl_LONG_DOUBLE_VS_DOUBLE.
+       * m4/math_h.m4 (gl_LONG_DOUBLE_VS_DOUBLE): Mention also NetBSD/sparc32.
+
 2023-10-12  Bruno Haible  <bruno@clisp.org>
 
        snan: Add tests.
index 008dd6fa3b2fd81e4686a747badce60fd5e6525d..959006472a1f1d9eae0c0aa5aec2bb3a449ab9c7 100644 (file)
@@ -375,7 +375,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
 # Sets variable HAVE_SAME_LONG_DOUBLE_AS_DOUBLE to 0 or 1, and defines
 # HAVE_SAME_LONG_DOUBLE_AS_DOUBLE accordingly.
 # The currently known platforms where this is the case are:
-# Linux/HPPA, Minix 3.1.8, AIX 5, AIX 6 and 7 with xlc, MSVC 9.
+# Linux/HPPA, NetBSD/sparc32, Minix 3.1.8, AIX 5, AIX 6 and 7 with xlc, MSVC 9.
 AC_DEFUN([gl_LONG_DOUBLE_VS_DOUBLE],
 [
   AC_CACHE_CHECK([whether long double and double are the same],
index d3f2b8615e20235ac24a9f47906c8570854fa80a..91210d2ea5ee725962c30685005ea2798671c7ad 100644 (file)
@@ -3,12 +3,14 @@ tests/test-snan-1.c
 tests/test-snan-2.sh
 tests/test-snan-2.c
 tests/macros.h
+m4/math_h.m4
 
 Depends-on:
 fpe-tracking
 fpe-trapping
 
 configure.ac:
+AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
 
 Makefile.am:
 TESTS += test-snan-1 test-snan-2.sh
index 9bce3225c18d38bb61fb0abf874e60bf6eada17a..4ebe013e3c3debda9e220a0eeb9d8b096c77b71b 100644 (file)
 /* Specification.  */
 #include "nan.h"
 
+#include <stdio.h>
+
 #if HAVE_FE_INVALID
 
-# include <fenv.h>
+# if defined __GLIBC__ && defined __arm__ && defined __SOFTFP__
+
+/* The arm software floating-point emulation (used e.g. on armv5) does not set
+   the floating-point exception bits.  */
+
+int
+main ()
+{
+  fputs ("Skipping test: software floating-point emulation\n", stderr);
+  return 77;
+}
+
+# else
+
+#  include <fenv.h>
 
-# include "macros.h"
+#  include "macros.h"
 
 float volatile resultf;
 double volatile resultd;
@@ -64,14 +80,14 @@ main ()
   return 0;
 }
 
+# endif
+
 #else
 
 /* No <fenv.h> available.
    We could use the various alternative approaches from
    libgfortran/config/fpu-*.h, but that's not worth it.  */
 
-#include <stdio.h>
-
 int
 main ()
 {
index de87372f17a179ef3d93ece1496e45ff4af30a68..fc8fc99e312fadbbf9e58f3e325152db4025622c 100644 (file)
 /* Specification.  */
 #include "snan.h"
 
+#include <stdio.h>
+
 #if HAVE_FE_INVALID
 
-# include <fenv.h>
+# if defined __GLIBC__ && defined __arm__ && defined __SOFTFP__
+
+/* The arm software floating-point emulation (used e.g. on armv5) does not set
+   the floating-point exception bits.  */
+
+int
+main ()
+{
+  fputs ("Skipping test: software floating-point emulation\n", stderr);
+  return 77;
+}
+
+# else
+
+#  include <fenv.h>
 
-# include "macros.h"
+#  include "macros.h"
 
 float volatile resultf;
 double volatile resultd;
@@ -45,33 +61,60 @@ main ()
   long double volatile nanl = SNaNl ();
 
   /* Check that the values are really signalling.  */
+  /* These tests do not work on 32-bit x86 processors, although the
+     "Intel 64 and IA-32 Architectures Software Developer's Manual" and
+     "IA-32 Intel Architecture Software Developer's Manual", each in
+     sections
+       4.8.3.4 NaNs
+       4.8.3.5 Operating on SNaNs and QNaNs
+       4.8.3.6 Using SNaNs and QNaNs in Applications
+     claim that it should work.  */
+  #if !(defined __i386 || defined _M_IX86)
+  /* This test does not work on AIX 7.1 with the xlc compiler, even with
+     the compiler options -qfloat=fenv -qfloat=nans -qfloat=spnans.  */
+  #if !(defined _AIX && defined __xlC__)
   {
     feclearexcept (FE_INVALID);
     resultf = nanf + 42.0f;
     ASSERT (fetestexcept (FE_INVALID));
   }
+  #endif
   {
     feclearexcept (FE_INVALID);
     resultd = nand + 42.0;
     ASSERT (fetestexcept (FE_INVALID));
   }
+  #endif
+  /* This test does not work on eglibc 2.13/mips64
+     (bug in libc function __addtf3).
+     This test does not work on FreeBSD/arm64
+     (bug in libc function __addtf3).
+     This test does not work on FreeBSD/sparc64 and NetBSD/sparc64
+     (bug in libc function _Qp_add).
+     This test does not work on MSVC/i386, because of the general IA-32
+     problem (see above) and 'long double' == 'double'.  */
+  #if !((((__GLIBC__ == 2 && __GLIBC_MINOR__ < 19 && defined __mips64) \
+          || ((defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__) && (defined __aarch64__ || defined __sparc__))) \
+         && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE) \
+        || ((defined __i386 || defined _M_IX86) && HAVE_SAME_LONG_DOUBLE_AS_DOUBLE))
   {
     feclearexcept (FE_INVALID);
     resultl = nanl + 42.0L;
     ASSERT (fetestexcept (FE_INVALID));
   }
+  #endif
 
   return 0;
 }
 
+# endif
+
 #else
 
 /* No <fenv.h> available.
    We could use the various alternative approaches from
    libgfortran/config/fpu-*.h, but that's not worth it.  */
 
-#include <stdio.h>
-
 int
 main ()
 {
index e1ee7c89283f67a4060f58ba0d3867df71caad6c..42927d6077849a6152ba21a765b77404651defdd 100644 (file)
@@ -65,14 +65,74 @@ main (int argc, char *argv[])
     switch (argv[1][0])
       {
       case 'f':
+        /* This test does not work on 32-bit x86 processors, although the
+           "Intel 64 and IA-32 Architectures Software Developer's Manual" and
+           "IA-32 Intel Architecture Software Developer's Manual", each in
+           sections
+             4.8.3.4 NaNs
+             4.8.3.5 Operating on SNaNs and QNaNs
+             4.8.3.6 Using SNaNs and QNaNs in Applications
+           claim that it should work.  */
+        #if !(defined __i386 || defined _M_IX86)
+        /* This test does not work on AIX 7.1 with the xlc compiler, even with
+           the compiler options -qfloat=fenv -qfloat=nans -qfloat=spnans.  */
+        #if !(defined _AIX && defined __xlC__)
         resultf = nanf + 42.0f;
+        #else
+        fputs ("Skipping test: known failure on this platform with this compiler\n", stderr);
+        return 77;
+        #endif
+        #else
+        fputs ("Skipping test: known failure on this platform\n", stderr);
+        return 77;
+        #endif
         break;
+
       case 'd':
+        /* This test does not work on 32-bit x86 processors, although the
+           "Intel 64 and IA-32 Architectures Software Developer's Manual" and
+           "IA-32 Intel Architecture Software Developer's Manual", each in
+           sections
+             4.8.3.4 NaNs
+             4.8.3.5 Operating on SNaNs and QNaNs
+             4.8.3.6 Using SNaNs and QNaNs in Applications
+           claim that it should work.  */
+        #if !(defined __i386 || defined _M_IX86)
         resultd = nand + 42.0;
+        #else
+        fputs ("Skipping test: known failure on this platform\n", stderr);
+        return 77;
+        #endif
         break;
+
       case 'l':
+        /* This test does not work on Linux/alpha with glibc 2.7.  But it
+           works with glibc 2.36.  Cause unknown.
+           This test does not work on Linux/loongarch64 with glibc 2.37.
+           Cause unknown.
+           This test does not work on eglibc 2.13/mips64
+           (bug in libc function __addtf3).
+           This test does not work on FreeBSD/arm64
+           (bug in libc function __addtf3).
+           This test does not work on FreeBSD/sparc64 and NetBSD/sparc64
+           (bug in libc function _Qp_add).
+           This test does not work on Cygwin 2.9.0/i386. Cause unknown.
+           This test does not work on MSVC/i386, because of the general IA-32
+           problem (see above) and 'long double' == 'double'.  */
+        #if !((__GLIBC__ == 2 && __GLIBC_MINOR__ < 36 && defined __alpha__) \
+              || (__GLIBC__ >= 2 && defined __loongarch__) \
+              || (((__GLIBC__ == 2 && __GLIBC_MINOR__ < 19 && defined __mips64) \
+                   || ((defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__) && (defined __aarch64__ || defined __sparc__))) \
+                  && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE) \
+              || (defined __CYGWIN__ && defined __i386) \
+              || ((defined __i386 || defined _M_IX86) && HAVE_SAME_LONG_DOUBLE_AS_DOUBLE))
         resultl = nanl + 42.0L;
+        #else
+        fputs ("Skipping test: known failure on this platform\n", stderr);
+        return 77;
+        #endif
         break;
+
       default:
         break;
       }