[PATCH] test for fegetround and fesetround

Eshan Dhawan eshandhawan51 at gmail.com
Tue Feb 25 17:45:25 UTC 2020


added tests for fegetround and fesetround in psxtests / psxfenv01

fegetround fails to send the rounding direction due to soft float and
returns to_nearest or zero  in the cases
fesetround sends zero if the rounding direction is set and sends anything
else if the function fails to set the rounding direction

can you check the patch for correctness

- Eshan

On Tue, Feb 25, 2020 at 8:26 PM Eshan dhawan <eshandhawan51 at gmail.com>
wrote:

> ---
>  testsuites/psxtests/psxfenv01/init.c | 42 +++++++++++++++++++++++++++-
>  1 file changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/testsuites/psxtests/psxfenv01/init.c
> b/testsuites/psxtests/psxfenv01/init.c
> index 05f3cdc880..4339139c58 100644
> --- a/testsuites/psxtests/psxfenv01/init.c
> +++ b/testsuites/psxtests/psxfenv01/init.c
> @@ -106,7 +106,47 @@ rtems_task Init(rtems_task_argument ignored)
>        printf("fesetexceptflag ==> 0x%x\n", r);
>      rtems_test_assert(r == 0);
>
> -
> +
> +    /*test for fegetround() and fesetround()*/
> +    /*they have four main macros to be tested seperated by ifdef*/
> +    /* since all the architectures dont support them */
> +    /*the test cases gets and sets the rounding directions */
> +#ifdef FE_TONEAREST
> +
> +    r=fegetround();
> +    if(r)
> +       printf("fegetround ==> 0x%x\n", r);
> +    rtems_test_assert(r == FE_TONEAREST) ;
> +#endif
> +#ifdef FE_TOWARDZERO
> +
> +  r=fesetround(FE_TOWARDZERO);
> +  if(r)
> +       printf("fesetround ==> 0x%x\n", r);
> +  rtems_test_assert(r == 0) ;
> +  rtems_test_assert(fegetround() == FE_TOWARDZERO) ;
> +#endif
> +#ifdef FE_DOWNWARD
> +
> +  r=fesetround(FE_DOWNWARD);
> +  if(r)
> +       printf("fesetround ==> 0x%x\n", r);
> +  rtems_test_assert(r == 0) ;
> +  rtems_test_assert(fegetround() == FE_DOWNWARD) ;
> +#endif
> +#ifdef FE_UPWARD
> +  r=fesetround(FE_UPWARD);
> +  if(r)
> +       printf("fesetround ==> 0x%x\n", r);
> +  rtems_test_assert(r == 0) ;
> +  rtems_test_assert(fegetround() == FE_UPWARD) ;
> +#endif
> +#ifdef FE_TONEAREST
> +  r=fesetround(FE_TONEAREST);
> +  if(r)
> +       printf("fesetround ==> 0x%x\n", r);
> +  rtems_test_assert(r == 0) ;
> +#endif
>
>
>  #ifdef FE_DIVBYZERO
> --
> 2.17.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20200225/f7878eb8/attachment-0001.html>


More information about the devel mailing list