[PATCH v4] tests for fenv.h functions

Gedare Bloom gedare at rtems.org
Thu Mar 5 21:42:30 UTC 2020


Getting there, see below.

On Thu, Mar 5, 2020 at 12:22 PM Eshan dhawan <eshandhawan51 at gmail.com> wrote:
>
> ---
>  testsuites/psxtests/psxfenv01/init.c | 68 +++++++++++++++++++++++++---
>  1 file changed, 62 insertions(+), 6 deletions(-)
>
> diff --git a/testsuites/psxtests/psxfenv01/init.c b/testsuites/psxtests/psxfenv01/init.c
> index cdb0fa596e..595d340983 100644
> --- a/testsuites/psxtests/psxfenv01/init.c
> +++ b/testsuites/psxtests/psxfenv01/init.c
> @@ -46,6 +46,7 @@
>  #include <string.h>
>  #include <rtems/test.h>
>  #include <tmacros.h>
> +#include <float.h>
>
>  const char rtems_test_name[] = "PSXFENV 01";
>
> @@ -69,20 +70,23 @@ rtems_task Init(rtems_task_argument ignored)
>    #ifdef FE_ALL_EXCEPT /* floating-point exceptions */
>      puts( "fesetenv(FE_DFL_ENV)." );
>      r = fesetenv(FE_DFL_ENV);
> -    if (r)
> +    if ( r ) {
>        printf("fesetenv ==> %d\n", r);
> +    }
>      rtems_test_assert( r == 0 );
>
>      /* Test 'feclearexcept()' and 'fetestexcept()' in one go. */
>      puts( "feclearexcept(FE_ALL_EXCEPT)." );
>      r = feclearexcept(FE_ALL_EXCEPT);
> -    if (r)
> +    if ( r ) {
>        printf("feclearexcept ==> 0x%x\n", r);
> +    }
>      rtems_test_assert( r == 0 );
>
>      r = fetestexcept( FE_ALL_EXCEPT );
> -    if (r)
> +    if (r){
whitespace

>        printf("fetestexcept ==> 0x%x\n", r);
> +    }
>      rtems_test_assert( r == 0 );
>
>      /* Test 'FE_DIVBYZERO' */
> @@ -91,9 +95,59 @@ rtems_task Init(rtems_task_argument ignored)
>      b = 1.0;
>      c = b/a;
>      (void) c;
> -
> -    fegetexceptflag(&excepts,FE_ALL_EXCEPT);
> -
> +    /* Test 'fegetexceptflag()' and 'fesetexceptflag()' */
no need for the single quotes here ' ' around the function names.

> +    r = fegetexceptflag( &excepts ,FE_ALL_EXCEPT );
> +    if ( r ) {
> +      printf("fegetexceptflag ==> 0x%x\n", r);
> +    }
> +    rtems_test_assert(r == 0);
> +
> +    r = fesetexceptflag( &excepts ,FE_ALL_EXCEPT );
> +    if ( r ) {
> +      printf("fesetexceptflag ==> 0x%x\n", r);
> +    }
> +    rtems_test_assert(r == 0);
> +
> +
avoid 2 blank lines in a row
> +    /* Test for 'fegetround()' and 'fesetround()'
> +     * They have four main macros to be tested seperated by ifdef
typo: separated

> +     * Since not all architectures support them
> +     * The test case gets and sets the rounding directions */
> +#ifdef FE_TONEAREST
> +    rtems_test_assert( fegetround() == FE_TONEAREST ) ;
> +#endif
> +#ifdef FE_TOWARDZERO
> +  r = fesetround(FE_TOWARDZERO);
> +  if( r ) {
whitespace after if
> +      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){
ws

> +      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 ) {
ws

> +      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
>      r = feraiseexcept(FE_DIVBYZERO);
>      rtems_test_assert( fetestexcept( FE_DIVBYZERO ) );
> @@ -125,3 +179,5 @@ rtems_task Init(rtems_task_argument ignored)
>  #define CONFIGURE_INIT
>  #include <rtems/confdefs.h>
>  /* end of file */
> +
> +
Don't add extra blank lines

> --
> 2.17.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list