diff options
author | 2019-02-13 21:10:38 +0000 | |
---|---|---|
committer | 2019-02-13 21:10:38 +0000 | |
commit | 5759b3d249badf144a6240f7eec4dcf9df003e6b (patch) | |
tree | 88ca2f73bac6772bb3b7819e5ca28614859b0f2c /gnu/usr.bin/perl/ext/PerlIO-via/t/thread.t | |
parent | strsep the -e argument for execve; ok benno (diff) | |
download | wireguard-openbsd-5759b3d249badf144a6240f7eec4dcf9df003e6b.tar.xz wireguard-openbsd-5759b3d249badf144a6240f7eec4dcf9df003e6b.zip |
Import perl-5.28.1
looking good sthen@, Great! bluhm@
Diffstat (limited to 'gnu/usr.bin/perl/ext/PerlIO-via/t/thread.t')
-rw-r--r-- | gnu/usr.bin/perl/ext/PerlIO-via/t/thread.t | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/ext/PerlIO-via/t/thread.t b/gnu/usr.bin/perl/ext/PerlIO-via/t/thread.t new file mode 100644 index 00000000000..e4358f9c24b --- /dev/null +++ b/gnu/usr.bin/perl/ext/PerlIO-via/t/thread.t @@ -0,0 +1,73 @@ +#!perl +BEGIN { + unless (find PerlIO::Layer 'perlio') { + print "1..0 # Skip: not perlio\n"; + exit 0; + } + require Config; + unless ($Config::Config{'usethreads'}) { + print "1..0 # Skip -- need threads for this test\n"; + exit 0; + } + if (($Config::Config{'extensions'} !~ m!\bPerlIO/via\b!) ){ + print "1..0 # Skip -- Perl configured without PerlIO::via module\n"; + exit 0; + } +} + +use strict; +use warnings; +use threads; + +my $tmp = "via$$"; + +END { + 1 while unlink $tmp; +} + +use Test::More tests => 2; + +our $push_count = 0; + +{ + open my $fh, ">:via(Test1)", $tmp + or die "Cannot open $tmp: $!"; + $fh->autoflush; + + print $fh "AXAX"; + + # previously this would crash + threads->create( + sub { + print $fh "XZXZ"; + })->join; + + print $fh "BXBX"; + close $fh; + + open my $in, "<", $tmp; + my $line = <$in>; + close $in; + + is($line, "AYAYYZYZBYBY", "check thread data delivered"); + + is($push_count, 1, "PUSHED not called for dup on thread creation"); +} + +package PerlIO::via::Test1; + +sub PUSHED { + my ($class) = @_; + ++$main::push_count; + bless {}, $class; +} + +sub WRITE { + my ($self, $data, $fh) = @_; + $data =~ tr/X/Y/; + $fh->autoflush; + print $fh $data; + return length $data; +} + + |