Module Name: src Committed By: jruoho Date: Mon Sep 19 05:40:39 UTC 2011
Modified Files: src/distrib/sets/lists/tests: mi src/tests/lib/libc/gen: Makefile src/tests/lib/libm: t_ldexp.c Removed Files: src/tests/lib/libc/gen: t_ldexp.c Log Message: Move duplicate ldexp(3) test out from the tests/libc. To generate a diff of this commit: cvs rdiff -u -r1.390 -r1.391 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.29 -r1.30 src/tests/lib/libc/gen/Makefile cvs rdiff -u -r1.5 -r0 src/tests/lib/libc/gen/t_ldexp.c cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libm/t_ldexp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.390 src/distrib/sets/lists/tests/mi:1.391 --- src/distrib/sets/lists/tests/mi:1.390 Mon Sep 19 05:25:50 2011 +++ src/distrib/sets/lists/tests/mi Mon Sep 19 05:40:39 2011 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.390 2011/09/19 05:25:50 jruoho Exp $ +# $NetBSD: mi,v 1.391 2011/09/19 05:40:39 jruoho Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -364,7 +364,7 @@ ./usr/libdata/debug/usr/tests/lib/libc/gen/t_glob.debug tests-lib-debug debug,atf ./usr/libdata/debug/usr/tests/lib/libc/gen/t_glob_star.debug tests-obsolete obsolete ./usr/libdata/debug/usr/tests/lib/libc/gen/t_humanize_number.debug tests-lib-debug debug,atf -./usr/libdata/debug/usr/tests/lib/libc/gen/t_ldexp.debug tests-lib-debug debug,atf +./usr/libdata/debug/usr/tests/lib/libc/gen/t_ldexp.debug tests-obsolete obsolete ./usr/libdata/debug/usr/tests/lib/libc/gen/t_nice.debug tests-lib-debug debug,atf ./usr/libdata/debug/usr/tests/lib/libc/gen/t_pause.debug tests-lib-debug debug,atf ./usr/libdata/debug/usr/tests/lib/libc/gen/t_raise.debug tests-lib-debug debug,atf @@ -1890,7 +1890,7 @@ ./usr/tests/lib/libc/gen/t_glob tests-lib-tests atf ./usr/tests/lib/libc/gen/t_glob_star tests-obsolete obsolete ./usr/tests/lib/libc/gen/t_humanize_number tests-lib-tests atf -./usr/tests/lib/libc/gen/t_ldexp tests-lib-tests atf +./usr/tests/lib/libc/gen/t_ldexp tests-obsolete obsolete ./usr/tests/lib/libc/gen/t_nice tests-lib-tests atf ./usr/tests/lib/libc/gen/t_pause tests-lib-tests atf ./usr/tests/lib/libc/gen/t_raise tests-lib-tests atf Index: src/tests/lib/libc/gen/Makefile diff -u src/tests/lib/libc/gen/Makefile:1.29 src/tests/lib/libc/gen/Makefile:1.30 --- src/tests/lib/libc/gen/Makefile:1.29 Mon Sep 19 05:25:50 2011 +++ src/tests/lib/libc/gen/Makefile Mon Sep 19 05:40:38 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.29 2011/09/19 05:25:50 jruoho Exp $ +# $NetBSD: Makefile,v 1.30 2011/09/19 05:40:38 jruoho Exp $ .include <bsd.own.mk> @@ -18,7 +18,6 @@ TESTS_C+= t_glob TESTS_C+= t_humanize_number TESTS_C+= t_isnan -TESTS_C+= t_ldexp TESTS_C+= t_nice TESTS_C+= t_pause TESTS_C+= t_raise @@ -31,7 +30,6 @@ TESTS_C+= t_vis LDADD.t_fpclassify+= -lm -LDADD.t_ldexp+= -lm LDADD.t_nice+= -lpthread LDADD.t_syslog+= -lpthread Index: src/tests/lib/libm/t_ldexp.c diff -u src/tests/lib/libm/t_ldexp.c:1.9 src/tests/lib/libm/t_ldexp.c:1.10 --- src/tests/lib/libm/t_ldexp.c:1.9 Sat Sep 17 06:21:19 2011 +++ src/tests/lib/libm/t_ldexp.c Mon Sep 19 05:40:38 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ldexp.c,v 1.9 2011/09/17 06:21:19 jruoho Exp $ */ +/* $NetBSD: t_ldexp.c,v 1.10 2011/09/19 05:40:38 jruoho Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,15 +29,159 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_ldexp.c,v 1.9 2011/09/17 06:21:19 jruoho Exp $"); +__RCSID("$NetBSD: t_ldexp.c,v 1.10 2011/09/19 05:40:38 jruoho Exp $"); + +#include <atf-c.h> +#include <atf-c/config.h> #include <math.h> #include <limits.h> +#include <stdio.h> +#include <string.h> -#include <atf-c.h> +#define SKIP 9999 +#define FORMAT "%23.23lg" static const int exps[] = { 0, 1, -1, 100, -100 }; +struct ldexp_test { + double x; + int exp1; + int exp2; + const char *result; +}; + +struct ldexp_test ldexp_basic[] = { + { 1.0, 5, SKIP, " 32" }, + { 1.0, 1022, SKIP, "4.4942328371557897693233e+307" }, + { 1.0, 1023, -1, "4.4942328371557897693233e+307" }, + { 1.0, 1023, SKIP, "8.9884656743115795386465e+307" }, + { 1.0, 1022, 1, "8.9884656743115795386465e+307" }, + { 1.0, -1022, 2045, "8.9884656743115795386465e+307" }, + { 1.0, -5, SKIP, " 0.03125" }, + { 1.0, -1021, SKIP, "4.4501477170144027661805e-308" }, + { 1.0, -1022, 1, "4.4501477170144027661805e-308" }, + { 1.0, -1022, SKIP, "2.2250738585072013830902e-308" }, + { 1.0, -1021, -1, "2.2250738585072013830902e-308" }, + { 1.0, 1023, -2045, "2.2250738585072013830902e-308" }, + { 1.0, 1023, -1023, " 1" }, + { 1.0, -1022, 1022, " 1" }, + { 0, 0, 0, NULL } +}; + +struct ldexp_test ldexp_zero[] = { + { 0.0, -1, SKIP, " 0" }, + { 0.0, 0, SKIP, " 0" }, + { 0.0, 1, SKIP, " 0" }, + { 0.0, 1024, SKIP, " 0" }, + { 0.0, 1025, SKIP, " 0" }, + { 0.0, -1023, SKIP, " 0" }, + { 0.0, -1024, SKIP, " 0" }, + { 0, 0, 0, NULL } +}; + +struct ldexp_test ldexp_infinity[] = { + { 1.0, 1024, -1, " inf" }, + { 1.0, 1024, 0, " inf" }, + { 1.0, 1024, 1, " inf" }, + { -1.0, 1024, -1, " -inf" }, + { -1.0, 1024, 0, " -inf" }, + { -1.0, 1024, 1, " -inf" }, + { 0, 0, 0, NULL } +}; + +struct ldexp_test ldexp_overflow[] = { + { 1.0, 1024, SKIP, " inf" }, + { 1.0, 1023, 1, " inf" }, + { 1.0, -1022, 2046, " inf" }, + { 1.0, 1025, SKIP, " inf" }, + { -1.0, 1024, SKIP, " -inf" }, + { -1.0, 1023, 1, " -inf" }, + { -1.0, -1022, 2046, " -inf" }, + { -1.0, 1025, SKIP, " -inf" }, + { 0, 0, 0, NULL } +}; + +struct ldexp_test ldexp_denormal[] = { + { 1.0, -1023, SKIP, "1.1125369292536006915451e-308" }, + { 1.0, -1022, -1, "1.1125369292536006915451e-308" }, + { 1.0, 1023, -2046, "1.1125369292536006915451e-308" }, + { 1.0, -1024, SKIP, "5.5626846462680034577256e-309" }, + { 1.0, -1074, SKIP, "4.9406564584124654417657e-324" }, + { -1.0, -1023, SKIP, "-1.1125369292536006915451e-308" }, + { -1.0, -1022, -1, "-1.1125369292536006915451e-308" }, + { -1.0, 1023, -2046, "-1.1125369292536006915451e-308" }, + { -1.0, -1024, SKIP, "-5.5626846462680034577256e-309" }, + { -1.0, -1074, SKIP, "-4.9406564584124654417657e-324" }, + { 0, 0, 0, NULL } +}; + +struct ldexp_test ldexp_underflow[] = { + { 1.0, -1075, SKIP, " 0" }, + { 1.0, -1074, -1, " 0" }, + { 1.0, 1023, -2098, " 0" }, + { 1.0, -1076, SKIP, " 0" }, + { -1.0, -1075, SKIP, " -0" }, + { -1.0, -1074, -1, " -0" }, + { -1.0, 1023, -2098, " -0" }, + { -1.0, -1076, SKIP, " -0" }, + { 0, 0, 0, NULL } +}; + +struct ldexp_test ldexp_denormal_large[] = { + { 1.0, -1028, 1024, " 0.0625" }, + { 1.0, -1028, 1025, " 0.125" }, + { 1.0, -1028, 1026, " 0.25" }, + { 1.0, -1028, 1027, " 0.5" }, + { 1.0, -1028, 1028, " 1" }, + { 1.0, -1028, 1029, " 2" }, + { 1.0, -1028, 1030, " 4" }, + { 1.0, -1028, 1040, " 4096" }, + { 1.0, -1028, 1050, " 4194304" }, + { 1.0, -1028, 1060, " 4294967296" }, + { 1.0, -1028, 1100, " 4722366482869645213696" }, + { 1.0, -1028, 1200, "5.9863107065073783529623e+51" }, + { 1.0, -1028, 1300, "7.5885503602567541832791e+81" }, + { 1.0, -1028, 1400, "9.6196304190416209014353e+111" }, + { 1.0, -1028, 1500, "1.2194330274671844653834e+142" }, + { 1.0, -1028, 1600, "1.5458150092069033378781e+172" }, + { 1.0, -1028, 1700, "1.9595533242629369747791e+202" }, + { 1.0, -1028, 1800, "2.4840289476811342962384e+232" }, + { 1.0, -1028, 1900, "3.1488807865122869393369e+262" }, + { 1.0, -1028, 2000, "3.9916806190694396233127e+292" }, + { 1.0, -1028, 2046, "2.808895523222368605827e+306" }, + { 1.0, -1028, 2047, "5.6177910464447372116541e+306" }, + { 1.0, -1028, 2048, "1.1235582092889474423308e+307" }, + { 1.0, -1028, 2049, "2.2471164185778948846616e+307" }, + { 1.0, -1028, 2050, "4.4942328371557897693233e+307" }, + { 1.0, -1028, 2051, "8.9884656743115795386465e+307" }, + { 0, 0, 0, NULL } +}; + +static void +run_test(struct ldexp_test *table) +{ + char outbuf[64]; + size_t i; + double v; + + for (i = 0; table->result != NULL; table++, i++) { + + v = ldexp(table->x, table->exp1); + + if (table->exp2 == SKIP) + continue; + + v = ldexp(v, table->exp2); + + (void)snprintf(outbuf, sizeof(outbuf), FORMAT, v); + + ATF_CHECK_STREQ_MSG(table->result, outbuf, + "Entry %zu:\n\tExp: \"%s\"\n\tAct: \"%s\"", + i, table->result, outbuf); + } +} + /* * ldexp(3) */ @@ -303,9 +447,43 @@ #endif } +#define TEST(name, desc) \ + ATF_TC(name); \ + ATF_TC_HEAD(name, tc) \ + { \ + \ + atf_tc_set_md_var(tc, "descr", \ + "Test ldexp(3) for " ___STRING(desc)); \ + } \ + ATF_TC_BODY(name, tc) \ + { \ + const char *machine; \ + \ + machine = atf_config_get("atf_machine"); \ + if (strcmp("vax", machine) == 0) \ + atf_tc_skip("Test not valid for %s", machine); \ + run_test(name); \ + } + +TEST(ldexp_basic, basics) +TEST(ldexp_zero, zero) +TEST(ldexp_infinity, infinity) +TEST(ldexp_overflow, overflow) +TEST(ldexp_denormal, denormal) +TEST(ldexp_denormal_large, large) +TEST(ldexp_underflow, underflow) + ATF_TP_ADD_TCS(tp) { + ATF_TP_ADD_TC(tp, ldexp_basic); + ATF_TP_ADD_TC(tp, ldexp_zero); + ATF_TP_ADD_TC(tp, ldexp_infinity); + ATF_TP_ADD_TC(tp, ldexp_overflow); + ATF_TP_ADD_TC(tp, ldexp_denormal); + ATF_TP_ADD_TC(tp, ldexp_underflow); + ATF_TP_ADD_TC(tp, ldexp_denormal_large); + ATF_TP_ADD_TC(tp, ldexp_exp2); ATF_TP_ADD_TC(tp, ldexp_nan); ATF_TP_ADD_TC(tp, ldexp_inf_neg);