[glibc] math: test: Fix unsupported check in test-narrowing-trap

Yury Khrustalev via Glibc-cvs <[email protected]> Tue, 21 Jul 2026 12:56:37 +0000 (GMT)
Newsgroups gmane.comp.lib.glibc.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3f3229739ebf6f91ae3f9681f225f0d1ef734163

commit 3f3229739ebf6f91ae3f9681f225f0d1ef734163
Author: Yury Khrustalev <[email protected]>
Date:   Thu Jul 16 14:09:33 2026 +0100

    math: test: Fix unsupported check in test-narrowing-trap
    
    Reviewed-by: Carlos O'Donell <[email protected]>

Diff:
---
 math/test-narrowing-trap.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/math/test-narrowing-trap.c b/math/test-narrowing-trap.c
index 6d21357913..ad36dfd78b 100644
--- a/math/test-narrowing-trap.c
+++ b/math/test-narrowing-trap.c
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <support/check.h>
 #include <support/xunistd.h>
+#include <support/test-driver.h>
 
 static int
 do_test (void)
@@ -29,14 +30,14 @@ do_test (void)
 #ifdef FE_INVALID
   pid_t pid;
 
-  if (!EXCEPTION_ENABLE_SUPPORTED (FE_INVALID))
-    FAIL_UNSUPPORTED ("feenableexcept (FE_INVALID) not supported");
-
   pid = xfork ();
   if (pid == 0)
     {
       int r = feenableexcept (FE_INVALID);
 
+      if (!EXCEPTION_ENABLE_SUPPORTED (FE_INVALID) && r == -1)
+        FAIL_UNSUPPORTED ("feenableexcept (FE_INVALID) not supported");
+
       TEST_COMPARE (r, 0);
       fdiv (0.0, 0.0);
       _exit (0);
@@ -46,6 +47,9 @@ do_test (void)
       int status;
       xwaitpid (pid, &status, 0);
 
+      if (WIFEXITED (status) && WEXITSTATUS (status) == EXIT_UNSUPPORTED)
+        FAIL_UNSUPPORTED ("feenableexcept (FE_INVALID) not supported");
+
       TEST_VERIFY (WIFSIGNALED (status));
       TEST_COMPARE (WTERMSIG (status), SIGFPE);
     }