From 320f78f060cb457a0c0ebfa559d276f48e0230da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppi...@redhat.com>
Date: Fri, 4 Mar 2016 15:21:53 +0100
Subject: Fix a race in t/read-write.t test

---
 ...sy-0.09-Fix-a-race-in-t-read-write.t-test.patch | 53 ++++++++++++++++++++++
 perl-IO-Pty-Easy.spec                              |  8 +++-
 2 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 IO-Pty-Easy-0.09-Fix-a-race-in-t-read-write.t-test.patch

diff --git a/IO-Pty-Easy-0.09-Fix-a-race-in-t-read-write.t-test.patch 
b/IO-Pty-Easy-0.09-Fix-a-race-in-t-read-write.t-test.patch
new file mode 100644
index 0000000..5e75aba
--- /dev/null
+++ b/IO-Pty-Easy-0.09-Fix-a-race-in-t-read-write.t-test.patch
@@ -0,0 +1,53 @@
+From 577a0eeb998f5bb120304f91b5a8a33bc8d3c6c7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppi...@redhat.com>
+Date: Fri, 4 Mar 2016 15:04:48 +0100
+Subject: [PATCH] Fix a race in t/read-write.t test
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+There was a race between filling a write buffer and testing
+a subsequent write would block.
+
+This patch fills the buffer first, and then it tests the blocking.
+
+CPAN RT#95702
+
+Signed-off-by: Petr Písař <ppi...@redhat.com>
+---
+ t/read-write.t | 18 ++++++++----------
+ 1 file changed, 8 insertions(+), 10 deletions(-)
+
+diff --git a/t/read-write.t b/t/read-write.t
+index 21fe729..03c0bc0 100644
+--- a/t/read-write.t
++++ b/t/read-write.t
+@@ -12,17 +12,15 @@ like($pty->read, qr/testing/, "basic read/write testing");
+ is($pty->read(0.1), undef, "read returns undef on timeout");
+ $pty->kill;
+ 
+-$pty->spawn("$^X -e 'sleep(1) while 1'");
+-eval {
+-    local $SIG{ALRM} = sub {
+-        is($pty->write("should fail", 0.1), undef,
+-           "write returns undef on timeout");
+-        $SIG{ALRM} = 'DEFAULT';
+-        alarm 1;
+-    };
+-    alarm 1;
+-    $pty->write('a'x(1024*1024));
++ok($pty->spawn("$^X -e 'print qq{start\n}; sleep(1) while 1'"),
++    'Program spawned');
++ok($pty->read, 'Program is ready');
++my $ret;
++while (defined ($ret = $pty->write('a' x 1024, 1))) {
++    diag("Filling write buffer: +$ret");
+ };
++diag "Writte buffer filled";
++is($pty->write("should fail", 0.1), undef, "write returns undef on timeout");
+ $pty->kill;
+ $pty->close;
+ 
+-- 
+2.5.0
+
diff --git a/perl-IO-Pty-Easy.spec b/perl-IO-Pty-Easy.spec
index efdd166..69d4011 100644
--- a/perl-IO-Pty-Easy.spec
+++ b/perl-IO-Pty-Easy.spec
@@ -1,11 +1,13 @@
 Name:           perl-IO-Pty-Easy
 Version:        0.09
-Release:        5%{?dist}
+Release:        6%{?dist}
 Summary:        Easy interface to IO::Pty
 License:        GPL+ or Artistic
 Group:          Development/Libraries
 URL:            http://search.cpan.org/dist/IO-Pty-Easy/
 Source0:        
http://www.cpan.org/modules/by-module/IO/IO-Pty-Easy-%{version}.tar.gz
+# Fix a race in t/read-write.t test, bug #1314777, CPAN RT#95702
+Patch0:         IO-Pty-Easy-0.09-Fix-a-race-in-t-read-write.t-test.patch
 BuildArch:      noarch
 BuildRequires:  perl
 BuildRequires:  perl(base)
@@ -29,6 +31,7 @@ spawn/read/write commands.
 
 %prep
 %setup -q -n IO-Pty-Easy-%{version}
+%patch0 -p1
 
 %build
 %{__perl} Makefile.PL INSTALLDIRS=vendor
@@ -50,6 +53,9 @@ make test
 %{_mandir}/man3/*
 
 %changelog
+* Fri Mar 04 2016 Petr Pisar <ppi...@redhat.com> - 0.09-6
+- Fix a race in t/read-write.t test (bug #1314777)
+
 * Thu Feb 04 2016 Fedora Release Engineering <rel...@fedoraproject.org> - 
0.09-5
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
 
-- 
cgit v0.12


        
http://pkgs.fedoraproject.org/cgit/perl-IO-Pty-Easy.git/commit/?h=master&id=320f78f060cb457a0c0ebfa559d276f48e0230da
--
Fedora Extras Perl SIG
http://www.fedoraproject.org/wiki/Extras/SIGs/Perl
perl-devel mailing list
perl-devel@lists.fedoraproject.org
http://lists.fedoraproject.org/admin/lists/perl-devel@lists.fedoraproject.org

Reply via email to