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

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

Thread Previous
From:
Dominic Hargreaves
Date:
June 4, 2016 14:01
Subject:
[perl #128319] constant: flawed test: hardcoded E2BIG errno value
Message ID:
rt-4.0.18-21650-1465048868-748.128319-75-0@perl.org
# New Ticket Created by  Dominic Hargreaves 
# Please include the string:  [perl #128319]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=128319 >


As reported in Debian bug <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=825018> 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] <http://perl5.git.perl.org/perl.git/commit/21866d1330b560599ac45bc24574bbd830e59a37>


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About