develooper Front page | perl.perl5.porters | Postings from August 2009

[PATCH] t/io/errno.t + Difference between stdio and perlio?

Thread Next
From:
Bram
Date:
August 1, 2009 13:21
Subject:
[PATCH] t/io/errno.t + Difference between stdio and perlio?
Message ID:
20090801222048.dbwqay70g84kskwc@horde.wizbit.be
While testing something I got a false positive in t/io/errno.t (  
http://perl5.git.perl.org/perl.git/commit/d7dfc388e04f41b8a0f5d8ef6e15ab3b79f483c8 ) but only in the tests that use stdio, the test that use perlio work  
fine.

It can be reproduced by setting $! to a value before the call to readline().
That is:

diff --git a/t/io/errno.t b/t/io/errno.t
index 6294ed7..3cd59c2 100644
--- a/t/io/errno.t
+++ b/t/io/errno.t
@@ -9,7 +9,7 @@ require './test.pl';

  plan( tests => 16 );

-my $test_prog = 'while(<>){print}; print $!';
+my $test_prog = '$!=1;while(<>){print}; print $!';
  my $saved_perlio;

  BEGIN {



Output of the test script:

./perl TEST -v io/errno.t
t/io/errno....1..16
ok 1 - Wrong errno, PERLIO=perlio stdin='test\n',
ok 2 - Wrong errno, PERLIO=perlio stdin='test\n', $/=undef
ok 3 - Wrong errno, PERLIO=perlio stdin='test\n', $/=\2
ok 4 - Wrong errno, PERLIO=perlio stdin='test\n', $/=\1024
ok 5 - Wrong errno, PERLIO=perlio stdin='test',
ok 6 - Wrong errno, PERLIO=perlio stdin='test', $/=undef
ok 7 - Wrong errno, PERLIO=perlio stdin='test', $/=\2
ok 8 - Wrong errno, PERLIO=perlio stdin='test', $/=\1024
# Failed at io/errno.t line 31
#      got 'test
# Operation not permitted'
# expected 'test
# '
not ok 9 - Wrong errno, PERLIO=stdio stdin='test\n',
[...]

This shows that under perlio $! was changed from 1 to undef and that  
under stdio $! remained unchanged.

Is this difference between perlio and stdio intentional? (read: can it  
be ignored?)


Either way, I belive the test should be updated to:

my $test_prog = 'undef $!;while(<>){print}; print $!';

so a patch for this is attached.
(In the current blead this creates no problem but in a future version  
it might. (I'm currently testing something and this test gave a false  
positive because of it))


Best regards,

Bram



Thread Next


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