Module Name:    src
Committed By:   maya
Date:           Sun Jun  3 08:39:00 UTC 2018

Modified Files:
        src/tests/lib/libm: t_scalbn.c

Log Message:
Test and clear exception around scalbn calls.
Second part of PR bin/51834.

ifdef out vax to avoid netbsd-specific macros.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libm/t_scalbn.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libm/t_scalbn.c
diff -u src/tests/lib/libm/t_scalbn.c:1.14 src/tests/lib/libm/t_scalbn.c:1.15
--- src/tests/lib/libm/t_scalbn.c:1.14	Fri Jan 13 21:09:12 2017
+++ src/tests/lib/libm/t_scalbn.c	Sun Jun  3 08:39:00 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: t_scalbn.c,v 1.14 2017/01/13 21:09:12 agc Exp $ */
+/* $NetBSD: t_scalbn.c,v 1.15 2018/06/03 08:39:00 maya Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,12 +29,13 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_scalbn.c,v 1.14 2017/01/13 21:09:12 agc Exp $");
+__RCSID("$NetBSD: t_scalbn.c,v 1.15 2018/06/03 08:39:00 maya Exp $");
 
 #include <math.h>
 #include <limits.h>
 #include <float.h>
 #include <errno.h>
+#include <fenv.h>
 
 #include <atf-c.h>
 
@@ -46,16 +47,17 @@ struct testcase {
 	double inval;
 	double result;
 	int error;
+	int except;
 };
 struct testcase test_vals[] = {
-	{ 0,		1.00085,	1.00085,	0 },
-	{ 0,		0.99755,	0.99755,	0 },
-	{ 0,		-1.00085,	-1.00085,	0 },
-	{ 0,		-0.99755,	-0.99755,	0 },
-	{ 1,		1.00085,	2.0* 1.00085,	0 },
-	{ 1,		0.99755,	2.0* 0.99755,	0 },
-	{ 1,		-1.00085,	2.0* -1.00085,	0 },
-	{ 1,		-0.99755,	2.0* -0.99755,	0 },
+	{ 0,		1.00085,	1.00085,	0, 0 },
+	{ 0,		0.99755,	0.99755,	0, 0 },
+	{ 0,		-1.00085,	-1.00085,	0, 0 },
+	{ 0,		-0.99755,	-0.99755,	0, 0 },
+	{ 1,		1.00085,	2.0* 1.00085,	0, 0 },
+	{ 1,		0.99755,	2.0* 0.99755,	0, 0 },
+	{ 1,		-1.00085,	2.0* -1.00085,	0, 0 },
+	{ 1,		-0.99755,	2.0* -0.99755,	0, 0 },
 
 	/*
 	 * We could add more corner test cases here, but we would have to
@@ -82,10 +84,19 @@ ATF_TC_BODY(scalbn_val, tc)
 
 	for (i = 0; i < tcnt; i++) {
 		errno = 0;
+#ifndef __vax__
+		feclearexcept(FE_ALL_EXCEPT);
+#endif
 		rv = scalbn(tests[i].inval, tests[i].exp);
 		ATF_CHECK_EQ_MSG(errno, tests[i].error,
 		    "test %zu: errno %d instead of %d", i, errno,
 		    tests[i].error);
+#ifndef __vax__
+		ATF_CHECK_EQ_MSG(errno, tests[i].error,
+		    "test %zu: fetestexcept %d instead of %d", i,
+		    fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW),
+		    tests[i].except);
+#endif
 		ATF_CHECK_MSG(fabs(rv-tests[i].result)<2.0*DBL_EPSILON,
 		    "test %zu: return value %g instead of %g (difference %g)",
 		    i, rv, tests[i].result, tests[i].result-rv);

Reply via email to