Source-Changes-HG archive

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

[src/trunk]: src Add dummy test cases for ceil(3) and floor(3). It is expecte...



details:   https://anonhg.NetBSD.org/src/rev/49e5e285934e
branches:  trunk
changeset: 763548:49e5e285934e
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Thu Mar 24 15:43:06 2011 +0000

description:
Add dummy test cases for ceil(3) and floor(3). It is expected that at least
one of these will fail on guest x86_64 NetBSD under Qemu. Thanks to pgoyette@
for checking the broken floor(16.999999...) = 17.

diffstat:

 distrib/sets/lists/tests/mi |   6 +++-
 tests/lib/libm/Makefile     |   4 +-
 tests/lib/libm/t_ceil.c     |  66 +++++++++++++++++++++++++++++++++++++++++++
 tests/lib/libm/t_floor.c    |  68 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 141 insertions(+), 3 deletions(-)

diffs (185 lines):

diff -r e2189b69f9fb -r 49e5e285934e distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Thu Mar 24 15:05:55 2011 +0000
+++ b/distrib/sets/lists/tests/mi       Thu Mar 24 15:43:06 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.275 2011/03/24 13:52:04 jruoho Exp $
+# $NetBSD: mi,v 1.276 2011/03/24 15:43:06 jruoho Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -448,6 +448,8 @@
 ./usr/libdata/debug/usr/tests/lib/libevent                             tests-lib-debug
 ./usr/libdata/debug/usr/tests/lib/libevent/h_event.debug               tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libm                                 tests-lib-debug
+./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_libm.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
@@ -1905,6 +1907,8 @@
 ./usr/tests/lib/libevent/t_event               tests-lib-tests         atf
 ./usr/tests/lib/libm                           tests-lib-tests         atf
 ./usr/tests/lib/libm/Atffile                   tests-lib-tests         atf
+./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_libm                    tests-lib-tests         atf
 ./usr/tests/lib/libobjc                                tests-lib-tests         atf
 ./usr/tests/lib/libobjc/Atffile                        tests-lib-tests         atf
diff -r e2189b69f9fb -r 49e5e285934e tests/lib/libm/Makefile
--- a/tests/lib/libm/Makefile   Thu Mar 24 15:05:55 2011 +0000
+++ b/tests/lib/libm/Makefile   Thu Mar 24 15:43:06 2011 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.1 2010/12/20 23:47:23 pgoyette Exp $
+# $NetBSD: Makefile,v 1.2 2011/03/24 15:43:06 jruoho Exp $
 
 .include <bsd.own.mk>
 
 TESTSDIR=      ${TESTSBASE}/lib/libm
 
-TESTS_C+=      t_libm
+TESTS_C+=      t_ceil t_floor t_libm
 
 LDADD+=-lm
 
diff -r e2189b69f9fb -r 49e5e285934e tests/lib/libm/t_ceil.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libm/t_ceil.c   Thu Mar 24 15:43:06 2011 +0000
@@ -0,0 +1,66 @@
+/* $NetBSD: t_ceil.c,v 1.1 2011/03/24 15:43:06 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_ceil.c,v 1.1 2011/03/24 15:43:06 jruoho Exp $");
+
+#include <math.h>
+#include <limits.h>
+
+#include <atf-c.h>
+
+ATF_TC(ceil);
+ATF_TC_HEAD(ceil, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "A basic test of ceil(3)");
+}
+
+ATF_TC_BODY(ceil, tc)
+{
+       const int n = 10240;
+       double x, y;
+       int i;
+
+       for (i = 0; i < n; i++) {
+
+               x = i + 0.999999999;
+               y = i + 0.000000001;
+
+               ATF_REQUIRE(fabs(ceil(x) - (double)(i + 1)) < 1.0e-40);
+               ATF_REQUIRE(fabs(ceil(x) - (double)(i + 1)) < 1.0e-40);
+       }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+       ATF_TP_ADD_TC(tp, ceil);
+
+       return atf_no_error();
+}
diff -r e2189b69f9fb -r 49e5e285934e tests/lib/libm/t_floor.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libm/t_floor.c  Thu Mar 24 15:43:06 2011 +0000
@@ -0,0 +1,68 @@
+/* $NetBSD: t_floor.c,v 1.1 2011/03/24 15:43:06 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_floor.c,v 1.1 2011/03/24 15:43:06 jruoho Exp $");
+
+#include <math.h>
+#include <limits.h>
+
+#include <stdio.h>
+
+#include <atf-c.h>
+
+ATF_TC(floor);
+ATF_TC_HEAD(floor, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "A basic test of floor(3)");
+}
+
+ATF_TC_BODY(floor, tc)
+{
+       const int n = 10240;
+       double x, y;
+       int i;
+
+       for (i = 0; i < n; i++) {
+
+               x = i + 0.999999999;
+               y = i + 0.000000001;
+
+               ATF_REQUIRE(fabs(floor(x) - (double)i) < 1.0e-40);
+               ATF_REQUIRE(fabs(floor(y) - (double)i) < 1.0e-40);
+       }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+       ATF_TP_ADD_TC(tp, floor);
+
+       return atf_no_error();
+}



Home | Main Index | Thread Index | Old Index