develooper Front page | perl.perl5.porters | Postings from June 2016

[perl #128319] constant: flawed test: hardcoded E2BIG errno value

Thread Previous
Dominic Hargreaves
June 4, 2016 14:01
[perl #128319] constant: flawed test: hardcoded E2BIG errno value
Message ID:
# New Ticket Created by  Dominic Hargreaves 
# Please include the string:  [perl #128319]
# in the subject line of all future correspondence about this issue. 
# <URL: >

As reported in Debian bug <> dist/constant/t/constant.t has a test which has two separate bugs which conspire to cancel each other out.

Firstly, the test hardcodes that E2BIG is supposed to be 7, but nothing asserts that
in C and POSIX, and hurd-i386 happens to be using other values.

This would cause the test suite to fail, were it not for a second bug, which is that the test for the correct error message being produced is rather weak (it only checks for a long enough string):

use constant E2BIG => $! = 7;
cmp_ok E2BIG, '==', 7;
# This is something like "Arg list too long", but the actual message
# text may vary, so we can't test much better than this.
cmp_ok length(E2BIG), '>', 6;

I've pushed a patch for the first issue to simply skip the test on Hurd[1], but it would be nice to have a more accurate test in any case. Based on observations on different platforms, would

E2BIG =~ /list too long/i

be a good test, or are there other variants?

What does 

perl -e '$! = 7; print $! . "\n"'

print on other platforms? (On Linux it's "Argument list too long").

Note that the reason that this was noticed was that that test *did* fail as a side-effect of #128279, now also fixed...

[1] <>

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About