svn commit: r276521 - head/contrib/netbsd-tests/lib/libm

Bruce Evans brde at optusnet.com.au
Fri Jan 2 08:29:02 UTC 2015


On Fri, 2 Jan 2015, Garrett Cooper wrote:

> Log:
>  Reset errno in :scalbnf_val and :scalbnl_val before running the tests so the
>  tested errno isn't stale

It is a bug to even test errno.  No function in libm accesses errno.

>  This was needed in order for the test to pass on amd64 with stable/10
>
>  MFC after: 3 days
>
> Modified:
>  head/contrib/netbsd-tests/lib/libm/t_scalbn.c
>
> Modified: head/contrib/netbsd-tests/lib/libm/t_scalbn.c
> ==============================================================================
> --- head/contrib/netbsd-tests/lib/libm/t_scalbn.c	Thu Jan  1 23:21:46 2015	(r276520)
> +++ head/contrib/netbsd-tests/lib/libm/t_scalbn.c	Fri Jan  2 00:57:40 2015	(r276521)
> @@ -225,6 +225,9 @@ ATF_TC_BODY(scalbnf_val, tc)
> 	double rv;
>
> 	for (i = 0; i < tcnt; i++) {
> +#ifdef __FreeBSD__
> +		errno = 0;
> +#endif

This is not FreeBSD-specific.  A correct test might test
errno under the condition (math_errhandling & MATH_ERRNO), but that
would be a lot of work to test a fundamentally broken implementataion.

> 		rv = scalbnf(tests[i].inval, tests[i].exp);
> 		ATF_CHECK_EQ_MSG(errno, tests[i].error,
> 		    "test %zu: errno %d instead of %d", i, errno,

The tests might set errno elsewhere, but scalbnf() obviously doesn't
in FreeBSD (and shouldn't unless MATH_ERRNO), so the ATF_CHECK_EQ_MSG()
test can have no effect.  It is surprising that it doesn't sometimes
fail if errno is always 0.  If it always succeeds, then tests[i].error
must be dead data (always 0) and the ATF_CHECK_EQ_MSG() test dead code
(always pass).

Bruce


More information about the svn-src-head mailing list