From owner-svn-src-stable@freebsd.org Fri Sep 8 04:35:46 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 98F8DE01DC9; Fri, 8 Sep 2017 04:35:46 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 40DFA70D70; Fri, 8 Sep 2017 04:35:46 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v884ZjV9029069; Fri, 8 Sep 2017 04:35:45 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v884Zj1S029067; Fri, 8 Sep 2017 04:35:45 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201709080435.v884Zj1S029067@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 8 Sep 2017 04:35:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r323298 - stable/11/lib/msun/tests X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/11/lib/msun/tests X-SVN-Commit-Revision: 323298 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Sep 2017 04:35:46 -0000 Author: ngie Date: Fri Sep 8 04:35:44 2017 New Revision: 323298 URL: https://svnweb.freebsd.org/changeset/base/323298 Log: MFC r321456,r321484,r321486: r321456: Convert lib/msun/trig_test from TAP to ATF format Only expose :accuracy and :reduction if !i386, similar to before, but more holistically to avoid future -Wunused issue with the unused functions. r321484: Only test ld_pi_odd with LDBL_MANT_DIG == 64 to fix the build The empty (unimplemented) test inputs for sparc64 trigger a -Wtype-limits build failure because nitems of an empty array is always false, i.e., deadcode. MFC with: r321455 r321486: Re-add #endif accidentally deleted in r321484 MFC with: r321455, r321484 Modified: stable/11/lib/msun/tests/Makefile stable/11/lib/msun/tests/trig_test.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/msun/tests/Makefile ============================================================================== --- stable/11/lib/msun/tests/Makefile Fri Sep 8 04:33:24 2017 (r323297) +++ stable/11/lib/msun/tests/Makefile Fri Sep 8 04:35:44 2017 (r323298) @@ -70,7 +70,7 @@ TAP_TESTS_C+= nan_test TAP_TESTS_C+= nearbyint_test TAP_TESTS_C+= next_test TAP_TESTS_C+= rem_test -TAP_TESTS_C+= trig_test +ATF_TESTS_C+= trig_test .if !empty(PROG) && !empty(TAP_TESTS_C:M${PROG}) CFLAGS+= -O0 Modified: stable/11/lib/msun/tests/trig_test.c ============================================================================== --- stable/11/lib/msun/tests/trig_test.c Fri Sep 8 04:33:24 2017 (r323297) +++ stable/11/lib/msun/tests/trig_test.c Fri Sep 8 04:35:44 2017 (r323298) @@ -44,6 +44,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include "test-utils.h" #pragma STDC FENV_ACCESS ON @@ -63,9 +65,9 @@ __FBSDID("$FreeBSD$"); */ #define test(func, x, result, exceptmask, excepts) do { \ volatile long double _d = x; \ - assert(feclearexcept(FE_ALL_EXCEPT) == 0); \ - assert(fpequal((func)(_d), (result))); \ - assert(((void)(func), fetestexcept(exceptmask) == (excepts))); \ + ATF_CHECK(feclearexcept(FE_ALL_EXCEPT) == 0); \ + ATF_CHECK(fpequal((func)(_d), (result))); \ + ATF_CHECK(((void)(func), fetestexcept(exceptmask) == (excepts))); \ } while (0) #define testall(prefix, x, result, exceptmask, excepts) do { \ @@ -79,13 +81,16 @@ __FBSDID("$FreeBSD$"); test(prefix##f, x, (float)result, exceptmask, excepts); \ } while (0) -/* - * Test special cases in sin(), cos(), and tan(). - */ -static void -run_special_tests(void) +ATF_TC(special); +ATF_TC_HEAD(special, tc) { + atf_tc_set_md_var(tc, "descr", + "test special cases in sin(), cos(), and tan()"); +} +ATF_TC_BODY(special, tc) +{ + /* Values at 0 should be exact. */ testall(tan, 0.0, 0.0, ALL_STD_EXCEPT, 0); testall(tan, -0.0, -0.0, ALL_STD_EXCEPT, 0); @@ -108,12 +113,16 @@ run_special_tests(void) testall(cos, NAN, NAN, ALL_STD_EXCEPT, 0); } -/* - * Tests to ensure argument reduction for large arguments is accurate. - */ -static void -run_reduction_tests(void) +#ifndef __i386__ +ATF_TC(reduction); +ATF_TC_HEAD(reduction, tc) { + + atf_tc_set_md_var(tc, "descr", + "tests to ensure argument reduction for large arguments is accurate"); +} +ATF_TC_BODY(reduction, tc) +{ /* floats very close to odd multiples of pi */ static const float f_pi_odd[] = { 85563208.0f, @@ -147,78 +156,77 @@ run_reduction_tests(void) 9.8477555741888350649e+4314L, 1.6061597222105160737e+4326L, }; -#elif LDBL_MANT_DIG == 113 - static const long double ld_pi_odd[] = { - /* XXX */ - }; #endif unsigned i; for (i = 0; i < nitems(f_pi_odd); i++) { - assert(fabs(sinf(f_pi_odd[i])) < FLT_EPSILON); - assert(cosf(f_pi_odd[i]) == -1.0); - assert(fabs(tan(f_pi_odd[i])) < FLT_EPSILON); + ATF_CHECK(fabs(sinf(f_pi_odd[i])) < FLT_EPSILON); + ATF_CHECK(cosf(f_pi_odd[i]) == -1.0); + ATF_CHECK(fabs(tan(f_pi_odd[i])) < FLT_EPSILON); - assert(fabs(sinf(-f_pi_odd[i])) < FLT_EPSILON); - assert(cosf(-f_pi_odd[i]) == -1.0); - assert(fabs(tanf(-f_pi_odd[i])) < FLT_EPSILON); + ATF_CHECK(fabs(sinf(-f_pi_odd[i])) < FLT_EPSILON); + ATF_CHECK(cosf(-f_pi_odd[i]) == -1.0); + ATF_CHECK(fabs(tanf(-f_pi_odd[i])) < FLT_EPSILON); - assert(fabs(sinf(f_pi_odd[i] * 2)) < FLT_EPSILON); - assert(cosf(f_pi_odd[i] * 2) == 1.0); - assert(fabs(tanf(f_pi_odd[i] * 2)) < FLT_EPSILON); + ATF_CHECK(fabs(sinf(f_pi_odd[i] * 2)) < FLT_EPSILON); + ATF_CHECK(cosf(f_pi_odd[i] * 2) == 1.0); + ATF_CHECK(fabs(tanf(f_pi_odd[i] * 2)) < FLT_EPSILON); - assert(fabs(sinf(-f_pi_odd[i] * 2)) < FLT_EPSILON); - assert(cosf(-f_pi_odd[i] * 2) == 1.0); - assert(fabs(tanf(-f_pi_odd[i] * 2)) < FLT_EPSILON); + ATF_CHECK(fabs(sinf(-f_pi_odd[i] * 2)) < FLT_EPSILON); + ATF_CHECK(cosf(-f_pi_odd[i] * 2) == 1.0); + ATF_CHECK(fabs(tanf(-f_pi_odd[i] * 2)) < FLT_EPSILON); } for (i = 0; i < nitems(d_pi_odd); i++) { - assert(fabs(sin(d_pi_odd[i])) < 2 * DBL_EPSILON); - assert(cos(d_pi_odd[i]) == -1.0); - assert(fabs(tan(d_pi_odd[i])) < 2 * DBL_EPSILON); + ATF_CHECK(fabs(sin(d_pi_odd[i])) < 2 * DBL_EPSILON); + ATF_CHECK(cos(d_pi_odd[i]) == -1.0); + ATF_CHECK(fabs(tan(d_pi_odd[i])) < 2 * DBL_EPSILON); - assert(fabs(sin(-d_pi_odd[i])) < 2 * DBL_EPSILON); - assert(cos(-d_pi_odd[i]) == -1.0); - assert(fabs(tan(-d_pi_odd[i])) < 2 * DBL_EPSILON); + ATF_CHECK(fabs(sin(-d_pi_odd[i])) < 2 * DBL_EPSILON); + ATF_CHECK(cos(-d_pi_odd[i]) == -1.0); + ATF_CHECK(fabs(tan(-d_pi_odd[i])) < 2 * DBL_EPSILON); - assert(fabs(sin(d_pi_odd[i] * 2)) < 2 * DBL_EPSILON); - assert(cos(d_pi_odd[i] * 2) == 1.0); - assert(fabs(tan(d_pi_odd[i] * 2)) < 2 * DBL_EPSILON); + ATF_CHECK(fabs(sin(d_pi_odd[i] * 2)) < 2 * DBL_EPSILON); + ATF_CHECK(cos(d_pi_odd[i] * 2) == 1.0); + ATF_CHECK(fabs(tan(d_pi_odd[i] * 2)) < 2 * DBL_EPSILON); - assert(fabs(sin(-d_pi_odd[i] * 2)) < 2 * DBL_EPSILON); - assert(cos(-d_pi_odd[i] * 2) == 1.0); - assert(fabs(tan(-d_pi_odd[i] * 2)) < 2 * DBL_EPSILON); + ATF_CHECK(fabs(sin(-d_pi_odd[i] * 2)) < 2 * DBL_EPSILON); + ATF_CHECK(cos(-d_pi_odd[i] * 2) == 1.0); + ATF_CHECK(fabs(tan(-d_pi_odd[i] * 2)) < 2 * DBL_EPSILON); } -#if LDBL_MANT_DIG > 53 +#if LDBL_MANT_DIG == 64 /* XXX: || LDBL_MANT_DIG == 113 */ for (i = 0; i < nitems(ld_pi_odd); i++) { - assert(fabsl(sinl(ld_pi_odd[i])) < LDBL_EPSILON); - assert(cosl(ld_pi_odd[i]) == -1.0); - assert(fabsl(tanl(ld_pi_odd[i])) < LDBL_EPSILON); + ATF_CHECK(fabsl(sinl(ld_pi_odd[i])) < LDBL_EPSILON); + ATF_CHECK(cosl(ld_pi_odd[i]) == -1.0); + ATF_CHECK(fabsl(tanl(ld_pi_odd[i])) < LDBL_EPSILON); - assert(fabsl(sinl(-ld_pi_odd[i])) < LDBL_EPSILON); - assert(cosl(-ld_pi_odd[i]) == -1.0); - assert(fabsl(tanl(-ld_pi_odd[i])) < LDBL_EPSILON); + ATF_CHECK(fabsl(sinl(-ld_pi_odd[i])) < LDBL_EPSILON); + ATF_CHECK(cosl(-ld_pi_odd[i]) == -1.0); + ATF_CHECK(fabsl(tanl(-ld_pi_odd[i])) < LDBL_EPSILON); - assert(fabsl(sinl(ld_pi_odd[i] * 2)) < LDBL_EPSILON); - assert(cosl(ld_pi_odd[i] * 2) == 1.0); - assert(fabsl(tanl(ld_pi_odd[i] * 2)) < LDBL_EPSILON); + ATF_CHECK(fabsl(sinl(ld_pi_odd[i] * 2)) < LDBL_EPSILON); + ATF_CHECK(cosl(ld_pi_odd[i] * 2) == 1.0); + ATF_CHECK(fabsl(tanl(ld_pi_odd[i] * 2)) < LDBL_EPSILON); - assert(fabsl(sinl(-ld_pi_odd[i] * 2)) < LDBL_EPSILON); - assert(cosl(-ld_pi_odd[i] * 2) == 1.0); - assert(fabsl(tanl(-ld_pi_odd[i] * 2)) < LDBL_EPSILON); + ATF_CHECK(fabsl(sinl(-ld_pi_odd[i] * 2)) < LDBL_EPSILON); + ATF_CHECK(cosl(-ld_pi_odd[i] * 2) == 1.0); + ATF_CHECK(fabsl(tanl(-ld_pi_odd[i] * 2)) < LDBL_EPSILON); } #endif } -/* - * Tests the accuracy of these functions over the primary range. - */ -static void -run_accuracy_tests(void) +ATF_TC(accuracy); +ATF_TC_HEAD(accuracy, tc) { + atf_tc_set_md_var(tc, "descr", + "tests the accuracy of these functions over the primary range"); +} +ATF_TC_BODY(accuracy, tc) +{ + /* For small args, sin(x) = tan(x) = x, and cos(x) = 1. */ testall(sin, 0xd.50ee515fe4aea16p-114L, 0xd.50ee515fe4aea16p-114L, ALL_STD_EXCEPT, FE_INEXACT); @@ -256,25 +264,17 @@ run_accuracy_tests(void) * - tests for large numbers that get reduced to hi+lo with lo!=0 */ } +#endif -int -main(void) +ATF_TP_ADD_TCS(tp) { - printf("1..3\n"); + ATF_TP_ADD_TC(tp, special); - run_special_tests(); - printf("ok 1 - trig\n"); - #ifndef __i386__ - run_reduction_tests(); + ATF_TP_ADD_TC(tp, accuracy); + ATF_TP_ADD_TC(tp, reduction); #endif - printf("ok 2 - trig\n"); -#ifndef __i386__ - run_accuracy_tests(); -#endif - printf("ok 3 - trig\n"); - - return (0); + return (atf_no_error()); }