Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libm A couple of the atan tests are randomly failing.



details:   https://anonhg.NetBSD.org/src/rev/f226d6e2a046
branches:  trunk
changeset: 327358:f226d6e2a046
user:      dsl <dsl%NetBSD.org@localhost>
date:      Wed Mar 05 20:15:41 2014 +0000

description:
A couple of the atan tests are randomly failing.
Print the incorrect value.

diffstat:

 tests/lib/libm/t_atan.c |  200 ++++-------------------------------------------
 1 files changed, 17 insertions(+), 183 deletions(-)

diffs (250 lines):

diff -r 668d2e696e08 -r f226d6e2a046 tests/lib/libm/t_atan.c
--- a/tests/lib/libm/t_atan.c   Wed Mar 05 20:14:46 2014 +0000
+++ b/tests/lib/libm/t_atan.c   Wed Mar 05 20:15:41 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_atan.c,v 1.11 2014/03/03 10:39:08 martin Exp $ */
+/* $NetBSD: t_atan.c,v 1.12 2014/03/05 20:15:41 dsl Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -31,11 +31,14 @@
 
 #include <atf-c.h>
 #include <math.h>
+#include "t_libm.h"
 
 static const struct {
        double x;
        double y;
 } values[] = {
+       { T_LIBM_MINUS_INF, -M_PI / 2 },
+       { T_LIBM_PLUS_INF,   M_PI / 2 },
        { -100, -1.560796660108231, },
        {  -10, -1.471127674303735, },
        {   -1, -M_PI / 4, },
@@ -49,212 +52,43 @@
 /*
  * atan(3)
  */
-ATF_TC(atan_nan);
-ATF_TC_HEAD(atan_nan, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "Test atan(NaN) == NaN");
-}
-
-ATF_TC_BODY(atan_nan, tc)
+ATF_LIBM_TEST(atan_nan, "Test atan/atanf(NaN) == NaN")
 {
-       const double x = 0.0L / 0.0L;
-
-       if (isnan(atan(x)) == 0)
-               atf_tc_fail_nonfatal("atan(NaN) != NaN");
-}
-
-ATF_TC(atan_inf_neg);
-ATF_TC_HEAD(atan_inf_neg, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "Test atan(-Inf) == -pi/2");
-}
-
-ATF_TC_BODY(atan_inf_neg, tc)
-{
-       const double x = -1.0L / 0.0L;
-       const double eps = 1.0e-15;
-
-       if (fabs(atan(x) + M_PI_2) > eps)
-               atf_tc_fail_nonfatal("atan(-Inf) != -pi/2");
+       T_LIBM_CHECK_NAN(0, atan, T_LIBM_NAN);
+       T_LIBM_CHECK_NAN(0, atanf, T_LIBM_NAN);
 }
 
-ATF_TC(atan_inf_pos);
-ATF_TC_HEAD(atan_inf_pos, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "Test atan(+Inf) == pi/2");
-}
-
-ATF_TC_BODY(atan_inf_pos, tc)
+ATF_LIBM_TEST(atan_inrange, "Test atan/atanf(x) for some values")
 {
-       const double x = +1.0L / 0.0L;
-       const double eps = 1.0e-15;
-
-       if (fabs(atan(x) - M_PI_2) > eps)
-               atf_tc_fail_nonfatal("atan(+Inf) != pi/2");
-}
-
-ATF_TC(atan_inrange);
-ATF_TC_HEAD(atan_inrange, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "Test atan(x) for some values");
-}
-
-ATF_TC_BODY(atan_inrange, tc)
-{
-       const double eps = 1.0e-15;
-       size_t i;
+       unsigned int i;
 
        for (i = 0; i < __arraycount(values); i++) {
-               if (fabs(atan(values[i].x) - values[i].y) > eps)
-                       atf_tc_fail_nonfatal("atan(%g) != %g",
-                               values[i].x, values[i].y);
+               T_LIBM_CHECK(i, atan, values[i].x, values[i].y, 1.0e-15);
+               T_LIBM_CHECK(i, atanf, values[i].x, values[i].y, 1.0e-7);
        }
 }
 
-ATF_TC(atan_zero_neg);
-ATF_TC_HEAD(atan_zero_neg, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "Test atan(-0.0) == -0.0");
-}
-
-ATF_TC_BODY(atan_zero_neg, tc)
+ATF_LIBM_TEST(atan_zero_neg, "Test atan/atanf(-0.0) == -0.0")
 {
-       const double x = -0.0L;
-       double y = atan(x);
-
-       if (fabs(y) > 0.0 || signbit(y) == 0)
-               atf_tc_fail_nonfatal("atan(-0.0) != -0.0");
-}
-
-ATF_TC(atan_zero_pos);
-ATF_TC_HEAD(atan_zero_pos, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "Test atan(+0.0) == +0.0");
-}
-
-ATF_TC_BODY(atan_zero_pos, tc)
-{
-       const double x = 0.0L;
-       double y = atan(x);
-
-       if (fabs(y) > 0.0 || signbit(y) != 0)
-               atf_tc_fail_nonfatal("atan(+0.0) != +0.0");
-}
 
-/*
- * atanf(3)
- */
-ATF_TC(atanf_nan);
-ATF_TC_HEAD(atanf_nan, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "Test atanf(NaN) == NaN");
-}
-
-ATF_TC_BODY(atanf_nan, tc)
-{
-       const float x = 0.0L / 0.0L;
-
-       if (isnan(atanf(x)) == 0)
-               atf_tc_fail_nonfatal("atanf(NaN) != NaN");
-}
-
-ATF_TC(atanf_inf_neg);
-ATF_TC_HEAD(atanf_inf_neg, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "Test atanf(-Inf) == -pi/2");
-}
-
-ATF_TC_BODY(atanf_inf_neg, tc)
-{
-       const float x = -1.0L / 0.0L;
-       const float eps = 1.0e-7;
-
-       if (fabsf(atanf(x) + (float)M_PI_2) > eps)
-               atf_tc_fail_nonfatal("atanf(-Inf) != -pi/2");
+       T_LIBM_CHECK_MINUS_ZERO(0, atan, -0.0);
+       T_LIBM_CHECK_MINUS_ZERO(0, atanf, -0.0);
 }
 
-ATF_TC(atanf_inf_pos);
-ATF_TC_HEAD(atanf_inf_pos, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "Test atanf(+Inf) == pi/2");
-}
-
-ATF_TC_BODY(atanf_inf_pos, tc)
+ATF_LIBM_TEST(atan_zero_pos, "Test atan/atanf(+0.0) == +0.0")
 {
-       const float x = +1.0L / 0.0L;
-       const float eps = 1.0e-7;
-
-       if (fabsf(atanf(x) - (float)M_PI_2) > eps)
-               atf_tc_fail_nonfatal("atanf(+Inf) != pi/2");
-}
-
-ATF_TC(atanf_inrange);
-ATF_TC_HEAD(atanf_inrange, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "Test atanf(x) for some values");
-}
-
-ATF_TC_BODY(atanf_inrange, tc)
-{
-       const float eps = 1.0e-7;
-       float x;
-       float y;
-       size_t i;
 
-       for (i = 0; i < __arraycount(values); i++) {
-               x = values[i].x;
-               y = values[i].y;
-               if (fabs(atanf(x) - y) > eps)
-                       atf_tc_fail_nonfatal("atan(%g) != %g", x, y);
-       }
-}
-
-ATF_TC(atanf_zero_neg);
-ATF_TC_HEAD(atanf_zero_neg, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "Test atanf(-0.0) == -0.0");
-}
-
-ATF_TC_BODY(atanf_zero_neg, tc)
-{
-       const float x = -0.0L;
-       float y = atanf(x);
-
-       if (fabsf(y) > 0.0 || signbit(y) == 0)
-               atf_tc_fail_nonfatal("atanf(-0.0) != -0.0");
-}
-
-ATF_TC(atanf_zero_pos);
-ATF_TC_HEAD(atanf_zero_pos, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "Test atanf(+0.0) == +0.0");
-}
-
-ATF_TC_BODY(atanf_zero_pos, tc)
-{
-       const float x = 0.0L;
-       float y = atanf(x);
-
-       if (fabsf(y) > 0.0 || signbit(y) != 0)
-               atf_tc_fail_nonfatal("atanf(+0.0) != +0.0");
+       T_LIBM_CHECK_PLUS_ZERO(0, atan, +0.0);
+       T_LIBM_CHECK_PLUS_ZERO(0, atanf, +0.0);
 }
 
 ATF_TP_ADD_TCS(tp)
 {
 
        ATF_TP_ADD_TC(tp, atan_nan);
-       ATF_TP_ADD_TC(tp, atan_inf_neg);
-       ATF_TP_ADD_TC(tp, atan_inf_pos);
        ATF_TP_ADD_TC(tp, atan_inrange);
        ATF_TP_ADD_TC(tp, atan_zero_neg);
        ATF_TP_ADD_TC(tp, atan_zero_pos);
 
-       ATF_TP_ADD_TC(tp, atanf_nan);
-       ATF_TP_ADD_TC(tp, atanf_inf_neg);
-       ATF_TP_ADD_TC(tp, atanf_inf_pos);
-       ATF_TP_ADD_TC(tp, atanf_inrange);
-       ATF_TP_ADD_TC(tp, atanf_zero_neg);
-       ATF_TP_ADD_TC(tp, atanf_zero_pos);
-
        return atf_no_error();
 }



Home | Main Index | Thread Index | Old Index