[PATCH] test for fegetround and fesetround

Eshan dhawan eshandhawan51 at gmail.com
Tue Feb 25 14:55:50 UTC 2020


---
 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



More information about the devel mailing list