Module Name: src Committed By: riastradh Date: Sun Jun 9 16:53:12 UTC 2024
Modified Files: src/tests/lib/libm: t_cos.c t_log.c t_scalbn.c t_sin.c t_tan.c Log Message: tests/lib/libm: Fix various xfails related to PR lib/45362. Writing if (condition) { atf_tc_expect_fail(...); atf_tc_fail(...); } in order to paper over a bug in qemu renders the test nearly useless because it will never actually fail in the event that something unexpected is broken. atf_tc_expect_fail only makes senes _before_ doing the test. If we want to paper over a bug in qemu, we can do: if (isQEMU) atf_tc_expect_fail("qemu is broken, PR lib/..."); ATF_CHECK(condition); That way, we are still doing the test in non-qemu circumstances, and if the qemu bug is fixed the test will give the feedback of an unexpected pass. While here: Use `volatile double x = ...' as input so the compiler doesn't optimize calls like sin(x) away at build-time, and print the bad values with ATF_CHECK_MSG on failure in case anything goes wrong. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libm/t_cos.c cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libm/t_log.c cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libm/t_scalbn.c cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libm/t_sin.c \ src/tests/lib/libm/t_tan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/lib/libm/t_cos.c diff -u src/tests/lib/libm/t_cos.c:1.11 src/tests/lib/libm/t_cos.c:1.12 --- src/tests/lib/libm/t_cos.c:1.11 Mon May 6 15:45:20 2024 +++ src/tests/lib/libm/t_cos.c Sun Jun 9 16:53:12 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_cos.c,v 1.11 2024/05/06 15:45:20 riastradh Exp $ */ +/* $NetBSD: t_cos.c,v 1.12 2024/06/09 16:53:12 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -114,9 +114,10 @@ ATF_TC_HEAD(cosl_inf_neg, tc) ATF_TC_BODY(cosl_inf_neg, tc) { - const long double x = -1.0L / 0.0L; + const volatile long double x = -1.0L / 0.0L; + const long double y = cosl(x); - ATF_CHECK(isnan(cosl(x)) != 0); + ATF_CHECK_MSG(isnan(y), "y=%La", y); } ATF_TC(cosl_inf_pos); @@ -127,9 +128,10 @@ ATF_TC_HEAD(cosl_inf_pos, tc) ATF_TC_BODY(cosl_inf_pos, tc) { - const long double x = 1.0L / 0.0L; + const volatile long double x = 1.0L / 0.0L; + const long double y = cosl(x); - ATF_CHECK(isnan(cosl(x)) != 0); + ATF_CHECK_MSG(isnan(y), "y=%La", y); } ATF_TC(cosl_zero_neg); @@ -208,9 +210,10 @@ ATF_TC_HEAD(cos_inf_neg, tc) ATF_TC_BODY(cos_inf_neg, tc) { - const double x = -1.0L / 0.0L; + const volatile double x = -1.0 / 0.0; + const double y = cos(x); - ATF_CHECK(isnan(cos(x)) != 0); + ATF_CHECK_MSG(isnan(y), "y=%a", y); } ATF_TC(cos_inf_pos); @@ -221,9 +224,10 @@ ATF_TC_HEAD(cos_inf_pos, tc) ATF_TC_BODY(cos_inf_pos, tc) { - const double x = 1.0L / 0.0L; + const volatile double x = 1.0 / 0.0; + const double y = cos(x); - ATF_CHECK(isnan(cos(x)) != 0); + ATF_CHECK_MSG(isnan(y), "y=%a", y); } ATF_TC(cos_zero_neg); @@ -316,12 +320,10 @@ ATF_TC_HEAD(cosf_inf_neg, tc) ATF_TC_BODY(cosf_inf_neg, tc) { - const float x = -1.0L / 0.0L; + const volatile float x = -1.0f / 0.0f; + const float y = cosf(x); - if (isnan(cosf(x)) == 0) { - atf_tc_expect_fail("PR lib/45362"); - atf_tc_fail("cosf(-Inf) != NaN"); - } + ATF_CHECK_MSG(isnan(y), "y=%a", y); } ATF_TC(cosf_inf_pos); @@ -332,12 +334,10 @@ ATF_TC_HEAD(cosf_inf_pos, tc) ATF_TC_BODY(cosf_inf_pos, tc) { - const float x = 1.0L / 0.0L; + const volatile float x = 1.0f / 0.0f; + const float y = cosf(x); - if (isnan(cosf(x)) == 0) { - atf_tc_expect_fail("PR lib/45362"); - atf_tc_fail("cosf(+Inf) != NaN"); - } + ATF_CHECK_MSG(isnan(y), "y=%a", y); } Index: src/tests/lib/libm/t_log.c diff -u src/tests/lib/libm/t_log.c:1.14 src/tests/lib/libm/t_log.c:1.15 --- src/tests/lib/libm/t_log.c:1.14 Wed Nov 7 03:59:36 2018 +++ src/tests/lib/libm/t_log.c Sun Jun 9 16:53:12 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_log.c,v 1.14 2018/11/07 03:59:36 riastradh Exp $ */ +/* $NetBSD: t_log.c,v 1.15 2024/06/09 16:53:12 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_log.c,v 1.14 2018/11/07 03:59:36 riastradh Exp $"); +__RCSID("$NetBSD: t_log.c,v 1.15 2024/06/09 16:53:12 riastradh Exp $"); #include <atf-c.h> @@ -257,13 +257,10 @@ ATF_TC_HEAD(log1p_inf_neg, tc) ATF_TC_BODY(log1p_inf_neg, tc) { - const double x = -1.0L / 0.0L; + const volatile double x = -1.0 / 0.0; const double y = log1p(x); - if (isnan(y) == 0) { - atf_tc_expect_fail("PR lib/45362"); - atf_tc_fail("log1p(-Inf) != NaN"); - } + ATF_CHECK_MSG(isnan(y), "y=%a", y); } ATF_TC(log1p_inf_pos); @@ -287,12 +284,10 @@ ATF_TC_HEAD(log1p_one_neg, tc) ATF_TC_BODY(log1p_one_neg, tc) { - const double x = log1p(-1.0); + const volatile double x = -1.0; + const double y = log1p(x); - if (x != -HUGE_VAL) { - atf_tc_expect_fail("PR lib/45362"); - atf_tc_fail("log1p(-1.0) != -HUGE_VAL"); - } + ATF_CHECK_EQ_MSG(y, -HUGE_VAL, "y=%a", y); } ATF_TC(log1p_zero_neg); @@ -346,13 +341,10 @@ ATF_TC_HEAD(log1pf_inf_neg, tc) ATF_TC_BODY(log1pf_inf_neg, tc) { - const float x = -1.0L / 0.0L; + const volatile float x = -1.0f / 0.0f; const float y = log1pf(x); - if (isnan(y) == 0) { - atf_tc_expect_fail("PR lib/45362"); - atf_tc_fail("log1pf(-Inf) != NaN"); - } + ATF_CHECK_MSG(isnan(y), "y=%a", y); } ATF_TC(log1pf_inf_pos); @@ -376,12 +368,10 @@ ATF_TC_HEAD(log1pf_one_neg, tc) ATF_TC_BODY(log1pf_one_neg, tc) { - const float x = log1pf(-1.0); + const volatile float x = -1.0f; + const float y = log1pf(x); - if (x != -HUGE_VALF) { - atf_tc_expect_fail("PR lib/45362"); - atf_tc_fail("log1pf(-1.0) != -HUGE_VALF"); - } + ATF_CHECK_EQ_MSG(y, -HUGE_VALF, "y=%a", y); } ATF_TC(log1pf_zero_neg); Index: src/tests/lib/libm/t_scalbn.c diff -u src/tests/lib/libm/t_scalbn.c:1.17 src/tests/lib/libm/t_scalbn.c:1.18 --- src/tests/lib/libm/t_scalbn.c:1.17 Mon May 6 15:49:31 2024 +++ src/tests/lib/libm/t_scalbn.c Sun Jun 9 16:53:12 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_scalbn.c,v 1.17 2024/05/06 15:49:31 riastradh Exp $ */ +/* $NetBSD: t_scalbn.c,v 1.18 2024/06/09 16:53:12 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_scalbn.c,v 1.17 2024/05/06 15:49:31 riastradh Exp $"); +__RCSID("$NetBSD: t_scalbn.c,v 1.18 2024/06/09 16:53:12 riastradh Exp $"); #include <math.h> #include <limits.h> @@ -408,14 +408,11 @@ ATF_TC_BODY(scalbnl_nan, tc) long double y; size_t i; - if (isnan(x) == 0) { - atf_tc_expect_fail("PR lib/45362"); - atf_tc_fail("(0.0L / 0.0L) != NaN"); - } + ATF_CHECK_MSG(isnan(x), "x=%La", x); for (i = 0; i < __arraycount(exps); i++) { y = scalbnl(x, exps[i]); - ATF_CHECK(isnan(y) != 0); + ATF_CHECK_MSG(isnan(y), "y=%La", y); } } Index: src/tests/lib/libm/t_sin.c diff -u src/tests/lib/libm/t_sin.c:1.7 src/tests/lib/libm/t_sin.c:1.8 --- src/tests/lib/libm/t_sin.c:1.7 Mon May 27 00:24:37 2019 +++ src/tests/lib/libm/t_sin.c Sun Jun 9 16:53:12 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_sin.c,v 1.7 2019/05/27 00:24:37 maya Exp $ */ +/* $NetBSD: t_sin.c,v 1.8 2024/06/09 16:53:12 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -117,9 +117,10 @@ ATF_TC_HEAD(sin_inf_neg, tc) ATF_TC_BODY(sin_inf_neg, tc) { - const double x = -1.0L / 0.0L; + const volatile double x = -1.0 / 0.0; + const double y = sin(x); - ATF_CHECK(isnan(sin(x)) != 0); + ATF_CHECK_MSG(isnan(y), "y=%a", y); } ATF_TC(sin_inf_pos); @@ -130,9 +131,10 @@ ATF_TC_HEAD(sin_inf_pos, tc) ATF_TC_BODY(sin_inf_pos, tc) { - const double x = 1.0L / 0.0L; + const volatile double x = 1.0 / 0.0; + const double y = sin(x); - ATF_CHECK(isnan(sin(x)) != 0); + ATF_CHECK_MSG(isnan(y), "y=%a", y); } @@ -222,12 +224,10 @@ ATF_TC_HEAD(sinf_inf_neg, tc) ATF_TC_BODY(sinf_inf_neg, tc) { - const float x = -1.0L / 0.0L; + const volatile float x = -1.0f / 0.0f; + const float y = sinf(x); - if (isnan(sinf(x)) == 0) { - atf_tc_expect_fail("PR lib/45362"); - atf_tc_fail("sinf(-Inf) != NaN"); - } + ATF_CHECK_MSG(isnan(y), "y=%a", y); } ATF_TC(sinf_inf_pos); @@ -238,12 +238,10 @@ ATF_TC_HEAD(sinf_inf_pos, tc) ATF_TC_BODY(sinf_inf_pos, tc) { - const float x = 1.0L / 0.0L; + const volatile float x = -1.0f / 0.0f; + const float y = sinf(x); - if (isnan(sinf(x)) == 0) { - atf_tc_expect_fail("PR lib/45362"); - atf_tc_fail("sinf(+Inf) != NaN"); - } + ATF_CHECK_MSG(isnan(y), "y=%a", y); } Index: src/tests/lib/libm/t_tan.c diff -u src/tests/lib/libm/t_tan.c:1.7 src/tests/lib/libm/t_tan.c:1.8 --- src/tests/lib/libm/t_tan.c:1.7 Wed Nov 7 04:00:13 2018 +++ src/tests/lib/libm/t_tan.c Sun Jun 9 16:53:12 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_tan.c,v 1.7 2018/11/07 04:00:13 riastradh Exp $ */ +/* $NetBSD: t_tan.c,v 1.8 2024/06/09 16:53:12 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -113,9 +113,10 @@ ATF_TC_HEAD(tan_inf_neg, tc) ATF_TC_BODY(tan_inf_neg, tc) { - const double x = -1.0L / 0.0L; + const volatile double x = -1.0 / 0.0; + const double y = tan(x); - ATF_CHECK(isnan(tan(x)) != 0); + ATF_CHECK_MSG(isnan(y), "y=%a", y); } ATF_TC(tan_inf_pos); @@ -126,9 +127,10 @@ ATF_TC_HEAD(tan_inf_pos, tc) ATF_TC_BODY(tan_inf_pos, tc) { - const double x = 1.0L / 0.0L; + const volatile double x = 1.0 / 0.0; + const double y = tan(x); - ATF_CHECK(isnan(tan(x)) != 0); + ATF_CHECK_MSG(isnan(y), "y=%a", y); } @@ -220,12 +222,10 @@ ATF_TC_HEAD(tanf_inf_neg, tc) ATF_TC_BODY(tanf_inf_neg, tc) { - const float x = -1.0L / 0.0L; + const volatile float x = -1.0f / 0.0f; + const float y = tanf(x); - if (isnan(tanf(x)) == 0) { - atf_tc_expect_fail("PR lib/45362"); - atf_tc_fail("tanf(-Inf) != NaN"); - } + ATF_CHECK_MSG(isnan(y), "y=%a", y); } ATF_TC(tanf_inf_pos); @@ -236,12 +236,10 @@ ATF_TC_HEAD(tanf_inf_pos, tc) ATF_TC_BODY(tanf_inf_pos, tc) { - const float x = 1.0L / 0.0L; + const volatile float x = 1.0f / 0.0f; + const float y = tanf(x); - if (isnan(tanf(x)) == 0) { - atf_tc_expect_fail("PR lib/45362"); - atf_tc_fail("tanf(+Inf) != NaN"); - } + ATF_CHECK_MSG(isnan(y), "y=%a", y); }