<div dir="ltr">Tested on leon3. Pushed.<div><br></div><div>Thanks.</div><div><br></div><div>--joel</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 20, 2020 at 1:22 PM Eshan dhawan <<a href="mailto:eshandhawan51@gmail.com">eshandhawan51@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">added tests for fesetexeptflag(), fegetexeptflag(),<br>
fegetround(), fesetround().<br>
<br>
In the test fegetround() does not return any flag<br>
other then FE_TONEAREST in tests.<br>
This is probably due to soft float.<br>
<br>
The test complies successfully and returns assert<br>
at fegetround()<br>
<br>
Other tests run without any errors<br>
tested on RISCV/rv32imac<br>
<br>
The test prints nothing if runs successfully.<br>
<br>
updates #2971<br>
<br>
Signed-off-by: Eshan dhawan <<a href="mailto:eshandhawan51@gmail.com" target="_blank">eshandhawan51@gmail.com</a>><br>
---<br>
testsuites/psxtests/psxfenv01/init.c | 92 ++++++++++++++++-----<br>
testsuites/psxtests/psxfenv01/psxfenv01.doc | 9 +-<br>
testsuites/psxtests/psxfenv01/psxfenv01.scn | 4 -<br>
3 files changed, 78 insertions(+), 27 deletions(-)<br>
<br>
diff --git a/testsuites/psxtests/psxfenv01/init.c b/testsuites/psxtests/psxfenv01/init.c<br>
index cdb0fa596e..766b9de581 100644<br>
--- a/testsuites/psxtests/psxfenv01/init.c<br>
+++ b/testsuites/psxtests/psxfenv01/init.c<br>
@@ -6,6 +6,7 @@<br>
/*<br>
* SPDX-License-Identifier: BSD-2-Clause<br>
*<br>
+ * Copyright (C) 2020 Eshan Dhawan<br>
* Copyright (C) 2019 Vaibhav Gupta<br>
*<br>
* Redistribution and use in source and binary forms, with or without<br>
@@ -46,11 +47,12 @@<br>
#include <string.h><br>
#include <rtems/test.h><br>
#include <tmacros.h><br>
+#include <float.h><br>
<br>
const char rtems_test_name[] = "PSXFENV 01";<br>
<br>
/* forward declarations to avoid warnings */<br>
-rtems_task Init(rtems_task_argument ignored);<br>
+rtems_task Init( rtems_task_argument ignored );<br>
<br>
/* Test Function Begins */<br>
rtems_task Init(rtems_task_argument ignored)<br>
@@ -62,42 +64,92 @@ rtems_task Init(rtems_task_argument ignored)<br>
<br>
/*<br>
* 'FE_ALL_EXCEPT' will be defined only when 'feclearexcept()',<br>
- * 'fegetexceptflag()', 'feraiseexcept()', 'fesetexceptflag()' and<br>
- * 'fetestexcept()' functions are supported by the architecture.<br>
+ * fegetexceptflag() , feraiseexcept(), fesetexceptflag() and<br>
+ * fetestexcept() functions are supported by the architecture.<br>
* Hence their testcases can be wrapped under #ifdef and #endif.<br>
*/<br>
#ifdef FE_ALL_EXCEPT /* floating-point exceptions */<br>
- puts( "fesetenv(FE_DFL_ENV)." );<br>
- r = fesetenv(FE_DFL_ENV);<br>
- if (r)<br>
- printf("fesetenv ==> %d\n", r);<br>
+ r = fesetenv( FE_DFL_ENV );<br>
+ if ( r ) {<br>
+ printf( "fesetenv ==> %d\n", r);<br>
+ }<br>
rtems_test_assert( r == 0 );<br>
<br>
- /* Test 'feclearexcept()' and 'fetestexcept()' in one go. */<br>
- puts( "feclearexcept(FE_ALL_EXCEPT)." );<br>
- r = feclearexcept(FE_ALL_EXCEPT);<br>
- if (r)<br>
- printf("feclearexcept ==> 0x%x\n", r);<br>
+ /* Test feclearexcept() and fetestexcept() in one go. */<br>
+ r = feclearexcept( FE_ALL_EXCEPT );<br>
+ if ( r ) {<br>
+ printf( "feclearexcept ==> 0x%x\n", r );<br>
+ }<br>
rtems_test_assert( r == 0 );<br>
<br>
r = fetestexcept( FE_ALL_EXCEPT );<br>
- if (r)<br>
- printf("fetestexcept ==> 0x%x\n", r);<br>
+ if ( r ) {<br>
+ printf( "fetestexcept ==> 0x%x\n", r );<br>
+ }<br>
rtems_test_assert( r == 0 );<br>
<br>
- /* Test 'FE_DIVBYZERO' */<br>
- puts( "Divide by zero and confirm fetestexcept()" );<br>
+ /* Test 'FE_DIVBYZERO'<br>
+ * Divide by zero and confirm fetestexcept() */<br>
a = 0.0;<br>
b = 1.0;<br>
c = b/a;<br>
(void) c;<br>
+ /* Test fegetexceptflag() and fesetexceptflag() */<br>
+ r = fegetexceptflag( &excepts, FE_ALL_EXCEPT );<br>
+ if ( r ) {<br>
+ printf( "fegetexceptflag ==> 0x%x\n", r );<br>
+ }<br>
+ rtems_test_assert( r == 0 );<br>
<br>
- fegetexceptflag(&excepts,FE_ALL_EXCEPT);<br>
+ r = fesetexceptflag( &excepts, FE_ALL_EXCEPT );<br>
+ if ( r ) {<br>
+ printf( "fesetexceptflag ==> 0x%x\n", r );<br>
+ }<br>
+ rtems_test_assert( r == 0 );<br>
<br>
-#ifdef FE_DIVBYZERO<br>
- r = feraiseexcept(FE_DIVBYZERO);<br>
+ /* Test for fegetround() and fesetround()<br>
+ * They have four main macros to be tested separated by ifdef<br>
+ * Since not all architectures support them<br>
+ * The test case gets and sets the rounding directions */<br>
+ #ifdef FE_TONEAREST /* Rounding direction TONEAREST */<br>
+ rtems_test_assert( fegetround() == FE_TONEAREST );<br>
+ #endif /*rounding direction TONEAREST */<br>
+ #ifdef FE_TOWARDZERO /* rounding direction TOWARDZERO */<br>
+ r = fesetround( FE_TOWARDZERO );<br>
+ if ( r ) {<br>
+ printf( "fesetround ==> 0x%x\n", r );<br>
+ }<br>
+ rtems_test_assert( r == 0 );<br>
+ rtems_test_assert( fegetround() == FE_TOWARDZERO );<br>
+ #endif/*rounding direction TOWARDZERO */<br>
+ #ifdef FE_DOWNWARD /* rounding direction DOWNWARD */<br>
+ r = fesetround( FE_DOWNWARD );<br>
+ if ( r ) {<br>
+ printf( "fesetround ==> 0x%x\n", r );<br>
+ }<br>
+ rtems_test_assert( r == 0 );<br>
+ rtems_test_assert( fegetround() == FE_DOWNWARD );<br>
+ #endif /* rounding direction DOWNWARD */<br>
+ #ifdef FE_UPWARD /* rounding direction UPWARD */<br>
+ r = fesetround( FE_UPWARD );<br>
+ if ( r ) {<br>
+ printf( "fesetround ==> 0x%x\n", r );<br>
+ }<br>
+ rtems_test_assert( r == 0 );<br>
+ rtems_test_assert( fegetround() == FE_UPWARD );<br>
+ #endif /* rounding direction upward */<br>
+ #ifdef FE_TONEAREST /* rounding direction TONEAREST */<br>
+ r = fesetround( FE_TONEAREST );<br>
+ if ( r ) {<br>
+ printf( "fesetround ==> 0x%x\n", r );<br>
+ }<br>
+ rtems_test_assert( r == 0 );<br>
+ #endif /* rounding direction TONEAREST */<br>
+<br>
+ #ifdef FE_DIVBYZERO /* divide by zero exeption */<br>
+ r = feraiseexcept( FE_DIVBYZERO ) ;<br>
rtems_test_assert( fetestexcept( FE_DIVBYZERO ) );<br>
-#endif<br>
+ #endif /* divide by zero exeption */<br>
<br>
/* Test 'FE_INEXACT' */<br>
a = 10.0;<br>
diff --git a/testsuites/psxtests/psxfenv01/psxfenv01.doc b/testsuites/psxtests/psxfenv01/psxfenv01.doc<br>
index 3aa7757496..52d9fd19c7 100644<br>
--- a/testsuites/psxtests/psxfenv01/psxfenv01.doc<br>
+++ b/testsuites/psxtests/psxfenv01/psxfenv01.doc<br>
@@ -1,4 +1,4 @@<br>
-# COPYRIGHT (c) 2019<br>
+# COPYRIGHT (c) 2019<br>
# On-Line Applications Research Corporation (OAR).<br>
#<br>
# SPDX-License-Identifier: BSD-2-Clause<br>
@@ -12,9 +12,12 @@ Directives:<br>
fesetenv<br>
feclearexcept<br>
fetestexcept<br>
- texceptflag<br>
feraiseexcept<br>
-<br>
+ fesetexeptflag<br>
+ fegetexeptflag<br>
+ fegetround<br>
+ fesetround<br>
+<br>
Concepts:<br>
<br>
+ This test exercises the fenv.h methods.<br>
diff --git a/testsuites/psxtests/psxfenv01/psxfenv01.scn b/testsuites/psxtests/psxfenv01/psxfenv01.scn<br>
index 21395e6712..6ea3bc255e 100644<br>
--- a/testsuites/psxtests/psxfenv01/psxfenv01.scn<br>
+++ b/testsuites/psxtests/psxfenv01/psxfenv01.scn<br>
@@ -1,7 +1,3 @@<br>
*** BEGIN OF TEST PSXFENV 01 ***<br>
-fesetenv(FE_DFL_ENV).<br>
-feclearexcept(FE_ALL_EXCEPT).<br>
-Divide by zero and confirm fetestexcept()<br>
-<br>
*** END OF TEST PSXFENV 01 ***<br>
<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div>