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

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

Thread Previous | Thread Next
From:
Rafael Garcia-Suarez
Date:
December 8, 2009 02:25
Subject:
Re: [PATCH] t/io/errno.t + Difference between stdio and perlio?
Message ID:
b77c1dce0912080225p68d2ab9fwa4f3668b20c9d26d@mail.gmail.com
2009/8/1 Bram <p5p@perl.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?)

I don't think it's intentional. I also think that you can't rely on $!
if there was no error.

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

Thanks, applied.

Thread Previous | 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