Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/libm Use a global double to stop GCC from optimizi...



details:   https://anonhg.NetBSD.org/src/rev/d9ed290b92c3
branches:  trunk
changeset: 826426:d9ed290b92c3
user:      maya <maya%NetBSD.org@localhost>
date:      Sun Sep 03 13:29:55 2017 +0000

description:
Use a global double to stop GCC from optimizing the test away
Better diagnostic messages
More familiar test for 'even number'

diffstat:

 tests/lib/libm/t_round.c |  14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diffs (39 lines):

diff -r 5794e572bec3 -r d9ed290b92c3 tests/lib/libm/t_round.c
--- a/tests/lib/libm/t_round.c  Sun Sep 03 09:19:51 2017 +0000
+++ b/tests/lib/libm/t_round.c  Sun Sep 03 13:29:55 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_round.c,v 1.7 2017/08/30 22:55:41 maya Exp $ */
+/* $NetBSD: t_round.c,v 1.8 2017/09/03 13:29:55 maya Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -103,8 +103,8 @@
         u = (gimpy_limb_t) d;
 
         for (; i > 0; i--) {
-                printf("i=%d, u: %"PRIu64"\n", i, u);
-                ATF_CHECK(!(u & 1));
+                ATF_CHECK_MSG((u % 2 == 0),
+                   "%"PRIu64" is not an even number! (iteration %d)", u , i);
                 u = u >> 1;
         }
 }
@@ -115,13 +115,15 @@
        atf_tc_set_md_var(tc, "descr","Checking double to uint64_t edge case");
 }
 
+
+double rounding_alpha_simple_even = 9223372036854775808.000000; /* 2^63 */
+
 ATF_TC_BODY(rounding_alpha_simple, tc)
 {
-       double even = 9223372036854775808.000000; /* 2^63 */
-       uint64_t unsigned_even = even;
+       uint64_t unsigned_even = rounding_alpha_simple_even;
 
        ATF_CHECK_MSG(unsigned_even % 2 == 0,
-           "2^63 casted to uint64_t is odd");
+           "2^63 casted to uint64_t is odd (got %"PRIu64")", unsigned_even);
 
 }
 ATF_TP_ADD_TCS(tp)



Home | Main Index | Thread Index | Old Index