Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libm Test and clear exception around scalbn calls.
details: https://anonhg.NetBSD.org/src/rev/4e66e5e45d5d
branches: trunk
changeset: 319561:4e66e5e45d5d
user: maya <maya%NetBSD.org@localhost>
date: Sun Jun 03 08:39:00 2018 +0000
description:
Test and clear exception around scalbn calls.
Second part of PR bin/51834.
ifdef out vax to avoid netbsd-specific macros.
diffstat:
tests/lib/libm/t_scalbn.c | 31 +++++++++++++++++++++----------
1 files changed, 21 insertions(+), 10 deletions(-)
diffs (70 lines):
diff -r 53969b782985 -r 4e66e5e45d5d tests/lib/libm/t_scalbn.c
--- a/tests/lib/libm/t_scalbn.c Sun Jun 03 08:08:36 2018 +0000
+++ b/tests/lib/libm/t_scalbn.c Sun Jun 03 08:39:00 2018 +0000
@@ -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 @@
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 @@
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);
Home |
Main Index |
Thread Index |
Old Index