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

Carlos O'Donell carlos@redhat.com
Tue Jul 21 12:12:47 GMT 2026


On 7/16/26 10:01 AM, Yury Khrustalev wrote:
> ---
> 
> Base commit: af51ed63d0

This was discussed on the Monday patch queue review in the context of the glibc 2.44 release.

Andreas and I discussed that this is a test-only change and Andreas approved downthread.

This patch is OK if you add the WIFEXITED check.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> 
> Test change only. Passes regression on aarch64-linux-gnu,
> x86_64-linux-gnu, i686-linux-gnu and build-tested for
> several targets with build-many-glibcs.py.
> 
> Andreas, I suppose we could merge this test fix now? It's OK if not.
> 
> ---
>   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..5820de42ad 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>

OK. Required.

>   
>   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");

OK. This converts a compile time test for an optional feature into a runtime test for an optional feature.

We previously had:

  * Mark test UNSUPPORTED if feature is optional

Now we have:

  * Mark test UNSUPPORTED if feature is optional and at runtime we detect it is mising.

This is a better outcome and allows the test to run on more aarch64 systems.

> +
>         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 (WEXITSTATUS (status) == EXIT_UNSUPPORTED)

Nit: POSIX requires "WIFEXITED (status) && WEXITSTATUS (status) == EXIT_UNSUPPORTED"

Caught by LLM.

Yes, there are fixes we should do in the tree for this.

> +        FAIL_UNSUPPORTED ("feenableexcept (FE_INVALID) not supported");

OK.

> +
>         TEST_VERIFY (WIFSIGNALED (status));
>         TEST_COMPARE (WTERMSIG (status), SIGFPE);
>       }


-- 
Cheers,
Carlos.



More information about the Libc-alpha mailing list