Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Start systematic testing of libm(3) by first evaluating the ...
details: https://anonhg.NetBSD.org/src/rev/edcad0afb393
branches: trunk
changeset: 769499:edcad0afb393
user: jruoho <jruoho%NetBSD.org@localhost>
date: Mon Sep 12 15:27:40 2011 +0000
description:
Start systematic testing of libm(3) by first evaluating the corner cases
(NaN, +0.0, -0.0, +Inf, -Inf) for the ldexp(3) and scalbn(3) families.
diffstat:
distrib/sets/lists/tests/mi | 6 +-
tests/lib/libm/Makefile | 13 +-
tests/lib/libm/t_ldexp.c | 220 +++++++++++++++++++++++++++++
tests/lib/libm/t_scalbn.c | 326 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 561 insertions(+), 4 deletions(-)
diffs (truncated from 613 to 300 lines):
diff -r c14f3f839eab -r edcad0afb393 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Mon Sep 12 14:44:27 2011 +0000
+++ b/distrib/sets/lists/tests/mi Mon Sep 12 15:27:40 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.382 2011/09/11 10:32:23 jruoho Exp $
+# $NetBSD: mi,v 1.383 2011/09/12 15:27:40 jruoho Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -549,9 +549,11 @@
./usr/libdata/debug/usr/tests/lib/libm/t_ceil.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libm/t_floor.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libm/t_infinity.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libm/t_ldexp.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libm/t_log.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libm/t_libm.debug tests-obsolete obsolete
./usr/libdata/debug/usr/tests/lib/libm/t_round.debug tests-lib-debug debug,atf
+./usr/libdata/debug/usr/tests/lib/libm/t_scalbn.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libm/t_tanh.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libobjc tests-lib-debug
./usr/libdata/debug/usr/tests/lib/libobjc/t_threads.debug tests-lib-debug debug,atf
@@ -2253,9 +2255,11 @@
./usr/tests/lib/libm/t_ceil tests-lib-tests atf
./usr/tests/lib/libm/t_floor tests-lib-tests atf
./usr/tests/lib/libm/t_infinity tests-lib-tests atf
+./usr/tests/lib/libm/t_ldexp tests-lib-tests atf
./usr/tests/lib/libm/t_log tests-lib-tests atf
./usr/tests/lib/libm/t_libm tests-obsolete obsolete
./usr/tests/lib/libm/t_round tests-lib-tests atf
+./usr/tests/lib/libm/t_scalbn tests-lib-tests atf
./usr/tests/lib/libm/t_tanh tests-lib-tests atf
./usr/tests/lib/libobjc tests-lib-tests atf
./usr/tests/lib/libobjc/Atffile tests-lib-tests atf
diff -r c14f3f839eab -r edcad0afb393 tests/lib/libm/Makefile
--- a/tests/lib/libm/Makefile Mon Sep 12 14:44:27 2011 +0000
+++ b/tests/lib/libm/Makefile Mon Sep 12 15:27:40 2011 +0000
@@ -1,12 +1,19 @@
-# $NetBSD: Makefile,v 1.6 2011/04/11 10:51:36 martin Exp $
+# $NetBSD: Makefile,v 1.7 2011/09/12 15:27:40 jruoho Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/lib/libm
-TESTS_C+= t_ceil t_floor t_log t_round t_tanh t_infinity
+TESTS_C+= t_ceil
+TESTS_C+= t_floor
+TESTS_C+= t_infinity
+TESTS_C+= t_ldexp
+TESTS_C+= t_log
+TESTS_C+= t_round
+TESTS_C+= t_scalbn
+TESTS_C+= t_tanh
LDADD+= -lm
-COPTS+= -Wfloat-equal
+#COPTS+= -Wfloat-equal
.include <bsd.test.mk>
diff -r c14f3f839eab -r edcad0afb393 tests/lib/libm/t_ldexp.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libm/t_ldexp.c Mon Sep 12 15:27:40 2011 +0000
@@ -0,0 +1,220 @@
+/* $NetBSD: t_ldexp.c,v 1.1 2011/09/12 15:27:40 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jukka Ruohonen.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_ldexp.c,v 1.1 2011/09/12 15:27:40 jruoho Exp $");
+
+#include <math.h>
+#include <limits.h>
+
+#include <atf-c.h>
+
+static const int exps[] = { 0, 1, -1, 100, -100 };
+
+/*
+ * ldexp(3)
+ */
+ATF_TC(ldexp_nan);
+ATF_TC_HEAD(ldexp_nan, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test NaN with ldexp(3)");
+}
+
+ATF_TC_BODY(ldexp_nan, tc)
+{
+ const double x = 0.0L / 0.0L;
+ double y;
+ size_t i;
+
+ for (i = 0; i < __arraycount(exps); i++) {
+ y = ldexp(x, exps[i]);
+ ATF_CHECK(isnan(y) != 0);
+ }
+}
+
+ATF_TC(ldexp_inf_neg);
+ATF_TC_HEAD(ldexp_inf_neg, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test -Inf with ldexp(3)");
+}
+
+ATF_TC_BODY(ldexp_inf_neg, tc)
+{
+ const double x = -1.0L / 0.0L;
+ size_t i;
+
+ for (i = 0; i < __arraycount(exps); i++)
+ ATF_CHECK(ldexp(x, exps[i]) == x);
+}
+
+ATF_TC(ldexp_inf_pos);
+ATF_TC_HEAD(ldexp_inf_pos, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test +Inf with ldexp(3)");
+}
+
+ATF_TC_BODY(ldexp_inf_pos, tc)
+{
+ const double x = 1.0L / 0.0L;
+ size_t i;
+
+ for (i = 0; i < __arraycount(exps); i++)
+ ATF_CHECK(ldexp(x, exps[i]) == x);
+}
+
+ATF_TC(ldexp_zero_neg);
+ATF_TC_HEAD(ldexp_zero_neg, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test -0.0 with ldexp(3)");
+}
+
+ATF_TC_BODY(ldexp_zero_neg, tc)
+{
+ const double x = -0.0L;
+ size_t i;
+
+ for (i = 0; i < __arraycount(exps); i++)
+ ATF_CHECK(ldexp(x, exps[i]) == x);
+}
+
+ATF_TC(ldexp_zero_pos);
+ATF_TC_HEAD(ldexp_zero_pos, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test +0.0 with ldexp(3)");
+}
+
+ATF_TC_BODY(ldexp_zero_pos, tc)
+{
+ const double x = 0.0L;
+ size_t i;
+
+ for (i = 0; i < __arraycount(exps); i++)
+ ATF_CHECK(ldexp(x, exps[i]) == x);
+}
+
+ATF_TC(ldexpf_nan);
+ATF_TC_HEAD(ldexpf_nan, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test NaN with ldexpf(3)");
+}
+
+ATF_TC_BODY(ldexpf_nan, tc)
+{
+ const float x = 0.0L / 0.0L;
+ float y;
+ size_t i;
+
+ for (i = 0; i < __arraycount(exps); i++) {
+ y = ldexpf(x, exps[i]);
+ ATF_CHECK(isnan(y) != 0);
+ }
+}
+
+/*
+ * ldexpf(3)
+ */
+
+ATF_TC(ldexpf_inf_neg);
+ATF_TC_HEAD(ldexpf_inf_neg, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test -Inf with ldexpf(3)");
+}
+
+ATF_TC_BODY(ldexpf_inf_neg, tc)
+{
+ const float x = -1.0L / 0.0L;
+ size_t i;
+
+ for (i = 0; i < __arraycount(exps); i++)
+ ATF_CHECK(ldexpf(x, exps[i]) == x);
+}
+
+ATF_TC(ldexpf_inf_pos);
+ATF_TC_HEAD(ldexpf_inf_pos, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test +Inf with ldexpf(3)");
+}
+
+ATF_TC_BODY(ldexpf_inf_pos, tc)
+{
+ const float x = 1.0L / 0.0L;
+ size_t i;
+
+ for (i = 0; i < __arraycount(exps); i++)
+ ATF_CHECK(ldexpf(x, exps[i]) == x);
+}
+
+ATF_TC(ldexpf_zero_neg);
+ATF_TC_HEAD(ldexpf_zero_neg, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test -0.0 with ldexpf(3)");
+}
+
+ATF_TC_BODY(ldexpf_zero_neg, tc)
+{
+ const float x = -0.0L;
+ size_t i;
+
+ for (i = 0; i < __arraycount(exps); i++)
+ ATF_CHECK(ldexpf(x, exps[i]) == x);
+}
+
+ATF_TC(ldexpf_zero_pos);
+ATF_TC_HEAD(ldexpf_zero_pos, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test +0.0 with ldexpf(3)");
+}
+
+ATF_TC_BODY(ldexpf_zero_pos, tc)
+{
+ const float x = 0.0L;
+ size_t i;
+
+ for (i = 0; i < __arraycount(exps); i++)
+ ATF_CHECK(ldexpf(x, exps[i]) == x);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, ldexp_nan);
+ ATF_TP_ADD_TC(tp, ldexp_inf_neg);
+ ATF_TP_ADD_TC(tp, ldexp_inf_pos);
+ ATF_TP_ADD_TC(tp, ldexp_zero_neg);
+ ATF_TP_ADD_TC(tp, ldexp_zero_pos);
+
+ ATF_TP_ADD_TC(tp, ldexpf_nan);
+ ATF_TP_ADD_TC(tp, ldexpf_inf_neg);
+ ATF_TP_ADD_TC(tp, ldexpf_inf_pos);
+ ATF_TP_ADD_TC(tp, ldexpf_zero_neg);
+ ATF_TP_ADD_TC(tp, ldexpf_zero_pos);
+
+ return atf_no_error();
+}
diff -r c14f3f839eab -r edcad0afb393 tests/lib/libm/t_scalbn.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libm/t_scalbn.c Mon Sep 12 15:27:40 2011 +0000
@@ -0,0 +1,326 @@
+/* $NetBSD: t_scalbn.c,v 1.1 2011/09/12 15:27:40 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jukka Ruohonen.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
Home |
Main Index |
Thread Index |
Old Index