Adapt tests to zlib-1.2.11

This commit is contained in:
Petr Písař 2017-02-07 15:01:08 +01:00
parent 5dcc72c9ee
commit 61217e9d9d
2 changed files with 101 additions and 1 deletions

View File

@ -0,0 +1,94 @@
From b42f5c088158f473116d3aca2d050d4efb95b021 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Tue, 7 Feb 2017 14:44:48 +0100
Subject: [PATCH] Adapt tests to zlib 1.2.11
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Since zlib-1.2.9 it's not safe to invoke deflateParams() when not all
input was consumed by deflate(). deflateParams() could return
Z_BUF_ERROR in some cases:
commit 7161ad76e2d0ac7de2a6235fcad3b9dfc99e9140
Author: Mark Adler <madler@alumni.caltech.edu>
Date: Tue Nov 22 23:29:19 2016 -0800
Assure that deflateParams() will not switch functions mid-block.
This alters the specification in zlib.h, so that deflateParams()
will not change any parameters if there is not enough output space
in the event that a block is emitted in order to allow switching
the compression function.
zlib documentation recommends two fixes:
To retry deflateParams() as it processes a piece of input underneath
until something else than Z_BUF_ERROR is returned. However this does
not work for me because then the compressed stream gets corrupted
and the subsequent inflate() returns a failure.
Another fix is to flush the deflated stream with Z_BLOCK just before
any deflateParams() call that follows unifinished deflate(). This
assures the new deflate options will be applied immediatelly on next
deflate() call. This fix works for me. Thus I implemented it in the
tests.
The new tests pass with zlib 1.2.8 as well as 1.2.11. 1.2.9 and 1.2.10
seems broken changing the deflate options was fixed in 1.2.11.
CPAN RT#119762
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
t/02zlib.t | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/t/02zlib.t b/t/02zlib.t
index 2c9aad6..50f6a82 100644
--- a/t/02zlib.t
+++ b/t/02zlib.t
@@ -24,13 +24,13 @@ BEGIN
my $count = 0 ;
if ($] < 5.005) {
- $count = 232 ;
+ $count = 236 ;
}
elsif ($] >= 5.006) {
- $count = 317 ;
+ $count = 320 ;
}
else {
- $count = 275 ;
+ $count = 278 ;
}
plan tests => $count + $extra;
@@ -537,6 +537,7 @@ SKIP:
$status = $x->deflate($hello, $Answer) ;
cmp_ok $status, '==', Z_OK ;
+ cmp_ok $x->flush($Answer, Z_BLOCK), '==', Z_OK ;
$input .= $hello;
# error cases
@@ -561,6 +562,7 @@ SKIP:
$status = $x->deflate($goodbye, $Answer) ;
cmp_ok $status, '==', Z_OK ;
+ cmp_ok $x->flush($Answer, Z_BLOCK), '==', Z_OK ;
$input .= $goodbye;
# change only Level
@@ -572,6 +574,7 @@ SKIP:
$status = $x->deflate($goodbye, $Answer) ;
cmp_ok $status, '==', Z_OK ;
+ cmp_ok $x->flush($Answer, Z_BLOCK), '==', Z_OK ;
$input .= $goodbye;
# change only Strategy
--
2.7.4

View File

@ -1,6 +1,6 @@
Name: perl-Compress-Raw-Zlib
Version: 2.071
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Low-level interface to the zlib compression library
# Zlib.xs: (GPL+ or Artistic) and zlib
# Others: GPL+ or Artistic
@ -8,6 +8,8 @@ License: (GPL+ or Artistic) and zlib
Group: Development/Libraries
URL: http://search.cpan.org/dist/Compress-Raw-Zlib/
Source0: http://search.cpan.org/CPAN/authors/id/P/PM/PMQS/Compress-Raw-Zlib-%{version}.tar.gz
# Adapt tests to zlib-1.2.11, bug #1419841, CPAN RT#119762
Patch0: Compress-Raw-Zlib-2.071-Adapt-tests-to-zlib-1.2.11.patch
# Module Build
BuildRequires: coreutils
BuildRequires: findutils
@ -56,6 +58,7 @@ compression library, which is used by IO::Compress::Zlib.
%prep
%setup -q -n Compress-Raw-Zlib-%{version}
%patch0 -p1
%build
OLD_ZLIB=False
@ -82,6 +85,9 @@ make test COMPRESS_ZLIB_RUN_MOST=1
%{_mandir}/man3/Compress::Raw::Zlib.3*
%changelog
* Tue Feb 07 2017 Petr Pisar <ppisar@redhat.com> - 2.071-2
- Adapt tests to zlib-1.2.11 (bug #1419841)
* Sat Dec 31 2016 Paul Howarth <paul@city-fan.org> - 2.071-1
- Update to 2.071
- One (last?) compilation warning in bundled inflate.c (CPAN RT#119580,