From f76fe71e68ec63ca5fd7068025e772ffdf758789 Mon Sep 17 00:00:00 2001 From: aspect Date: Sat, 11 Feb 2017 05:06:43 +0000 Subject: zlib stream finalize calls deflate with no input - this case (and this case only) must be allowed. Fixes 2nd issue in [25842c161f], introduced by [c1aff52ef3] --- generic/tclZlib.c | 4 ++-- tests/zlib.test | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/generic/tclZlib.c b/generic/tclZlib.c index e5a5946..82486d2 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -1204,10 +1204,10 @@ Tcl_ZlibStreamPut( zshPtr->stream.avail_in = size; /* - * Must not do a zero-length compress. [Bug 25842c161] + * Must not do a zero-length compress unless finalizing. [Bug 25842c161] */ - if (size == 0) { + if (size == 0 && flush != Z_FINISH) { return TCL_OK; } diff --git a/tests/zlib.test b/tests/zlib.test index ae8742b..3ee7a45 100644 --- a/tests/zlib.test +++ b/tests/zlib.test @@ -157,6 +157,18 @@ test zlib-7.8 {zlib stream: Bug b26e38a3e4} -constraints zlib -setup { catch {$strm close} unset -nocomplain randdata data } -result {120185 18003000} +test zlib-7.9 {zlib stream finalize (bug 25842c161)} -constraints zlib -setup { + set z1 [zlib stream gzip] + set z2 [zlib stream gzip] +} -body { + $z1 put ABCDEedbca.. + $z1 finalize + $z2 put -finalize ABCDEedbca.. + expr {[$z1 get] eq [$z2 get]} +} -cleanup { + $z1 close + $z2 close +} -result 1 test zlib-8.1 {zlib transformation} -constraints zlib -setup { set file [makeFile {} test.gz] -- cgit v0.12 From 946a00999108508220f54a76817b73262a6aa827 Mon Sep 17 00:00:00 2001 From: aspect Date: Sat, 11 Feb 2017 07:18:08 +0000 Subject: better tests for finalization --- tests/zlib.test | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/zlib.test b/tests/zlib.test index 3ee7a45..9497979 100644 --- a/tests/zlib.test +++ b/tests/zlib.test @@ -169,6 +169,30 @@ test zlib-7.9 {zlib stream finalize (bug 25842c161)} -constraints zlib -setup { $z1 close $z2 close } -result 1 +test zlib-7.9.1 {zlib stream put -finalize (bug 25842c161)} -constraints zlib -setup { + set c [zlib stream gzip] + set d [zlib stream gunzip] +} -body { + $c put abcdeEDCBA.. + $c finalize + $d put [$c get] + $d finalize + $d get +} -cleanup { + $c close + $d close +} -result abcdeEDCBA.. +test zlib-7.9.2 {zlib stream put; zlib stream finalize (bug 25842c161)} -constraints zlib -setup { + set c [zlib stream gzip] + set d [zlib stream gunzip] +} -body { + $c put -finalize abcdeEDCBA.. + $d put -finalize [$c get] + $d get +} -cleanup { + $c close + $d close +} -result abcdeEDCBA.. test zlib-8.1 {zlib transformation} -constraints zlib -setup { set file [makeFile {} test.gz] -- cgit v0.12 From 6a29cbc151dd60bc01bd1f272be2b9c48371b453 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 26 Feb 2017 13:19:08 +0000 Subject: Make tests produce more meaningful information when they fail. --- tests/zlib.test | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/zlib.test b/tests/zlib.test index 9497979..ba861e0 100644 --- a/tests/zlib.test +++ b/tests/zlib.test @@ -163,13 +163,19 @@ test zlib-7.9 {zlib stream finalize (bug 25842c161)} -constraints zlib -setup { } -body { $z1 put ABCDEedbca.. $z1 finalize - $z2 put -finalize ABCDEedbca.. - expr {[$z1 get] eq [$z2 get]} + zlib gunzip [$z1 get] } -cleanup { $z1 close +} -result ABCDEedbca.. +test zlib-7.9.1 {zlib stream finalize (bug 25842c161)} -constraints zlib -setup { + set z2 [zlib stream gzip] +} -body { + $z2 put -finalize ABCDEedbca.. + zlib gunzip [$z2 get] +} -cleanup { $z2 close -} -result 1 -test zlib-7.9.1 {zlib stream put -finalize (bug 25842c161)} -constraints zlib -setup { +} -result ABCDEedbca.. +test zlib-7.9.2 {zlib stream put -finalize (bug 25842c161)} -constraints zlib -setup { set c [zlib stream gzip] set d [zlib stream gunzip] } -body { @@ -182,7 +188,7 @@ test zlib-7.9.1 {zlib stream put -finalize (bug 25842c161)} -constraints zlib -s $c close $d close } -result abcdeEDCBA.. -test zlib-7.9.2 {zlib stream put; zlib stream finalize (bug 25842c161)} -constraints zlib -setup { +test zlib-7.9.3 {zlib stream put; zlib stream finalize (bug 25842c161)} -constraints zlib -setup { set c [zlib stream gzip] set d [zlib stream gunzip] } -body { -- cgit v0.12 From a9c42fa686ab9236f5218c276ce4bfdc7655ab16 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 26 Feb 2017 15:28:29 +0000 Subject: Might as well number tests more conventionally. --- tests/zlib.test | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/zlib.test b/tests/zlib.test index ba861e0..1e69745 100644 --- a/tests/zlib.test +++ b/tests/zlib.test @@ -167,7 +167,7 @@ test zlib-7.9 {zlib stream finalize (bug 25842c161)} -constraints zlib -setup { } -cleanup { $z1 close } -result ABCDEedbca.. -test zlib-7.9.1 {zlib stream finalize (bug 25842c161)} -constraints zlib -setup { +test zlib-7.10 {zlib stream finalize (bug 25842c161)} -constraints zlib -setup { set z2 [zlib stream gzip] } -body { $z2 put -finalize ABCDEedbca.. @@ -175,7 +175,7 @@ test zlib-7.9.1 {zlib stream finalize (bug 25842c161)} -constraints zlib -setup } -cleanup { $z2 close } -result ABCDEedbca.. -test zlib-7.9.2 {zlib stream put -finalize (bug 25842c161)} -constraints zlib -setup { +test zlib-7.11 {zlib stream put -finalize (bug 25842c161)} -constraints zlib -setup { set c [zlib stream gzip] set d [zlib stream gunzip] } -body { @@ -188,7 +188,7 @@ test zlib-7.9.2 {zlib stream put -finalize (bug 25842c161)} -constraints zlib -s $c close $d close } -result abcdeEDCBA.. -test zlib-7.9.3 {zlib stream put; zlib stream finalize (bug 25842c161)} -constraints zlib -setup { +test zlib-7.12 {zlib stream put; zlib stream finalize (bug 25842c161)} -constraints zlib -setup { set c [zlib stream gzip] set d [zlib stream gunzip] } -body { -- cgit v0.12