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

Garrett Cooper yaneurabeya at gmail.com
Sun Jan 4 21:53:59 UTC 2015


On Jan 2, 2015, at 0:03, Bruce Evans <brde at optusnet.com.au> wrote:

> 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.

I’ll have to look again, but I’m pretty sure NetBSD is using this to test errors dealing with ranges and input, and it’s probably implementation dependent.

It’s still interesting that it was setting EINVAL (errno == 2) when running the tests and not others (and that potentially deserves investigation).

What’s also curious is that this issue doesn’t manifest itself on 11-CURRENT as well, but I haven’t taken the time to figure out why that is, yet (apart from having merged some revisions from head which didn’t affect things), so the underlying issue is probably buried somewhere in another library (libc, libthr, etc).

>> 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 implementation.

It definitely isn’t. It’s an item that I’ll need to bring up with the NetBSD folks/resolve differently in the future.

>> 		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).

Hmmm… How is MATH_ERRNO supposed to work in FreeBSD. Based on documentation I found — http://en.cppreference.com/w/cpp/numeric/math/math_errhandling — it’s supposed to be used for reporting errors with errno since c++11, but that doesn’t seem to be implemented in libc++/libstdc++ (at least not based on my limited grep)? FWIW it seems like this value should be 0, not 1...
Thanks!

$ grep -r MATH_ERRNO contrib/binutils contrib/gcc* contrib/lib* contrib/llvm/ include lib sys/sys/
lib/msun/src/math.h:#define     MATH_ERRNO      1
contrib/libc++/include/cmath:    MATH_ERRNO              // C99
$
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20150104/db6309a8/attachment.sig>


More information about the svn-src-head mailing list