summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclZlib.c4
-rw-r--r--tests/zlib.test100
3 files changed, 101 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index a3de07b..29d88db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-09 Pat Thoyts <patthoyts@users.sourceforge.net>
+
+ * tests/zlib.test: [Bug #2818131] Added tests and fixed a typo
+ that broke zlib push for deflate format.
+
2009-07-09 Donal K. Fellows <dkf@users.sf.net>
* compat/mkstemp.c (mkstemp): [Bug 2819227]: Use rand() for random
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index 378c123..96d68c1 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclZlib.c,v 1.28 2009/07/06 21:38:21 patthoyts Exp $
+ * RCS: @(#) $Id: tclZlib.c,v 1.29 2009/07/09 22:48:44 patthoyts Exp $
*/
#include "tclInt.h"
@@ -1940,7 +1940,7 @@ TclZlibCmd(
switch ((enum zlibFormats) format) {
case f_deflate:
mode = TCL_ZLIB_STREAM_DEFLATE;
- format = TCL_ZLIB_FORMAT_GZIP;
+ format = TCL_ZLIB_FORMAT_RAW;
break;
case f_inflate:
mode = TCL_ZLIB_STREAM_INFLATE;
diff --git a/tests/zlib.test b/tests/zlib.test
index b8d6e66..3705419 100644
--- a/tests/zlib.test
+++ b/tests/zlib.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: zlib.test,v 1.9 2009/07/05 21:46:27 patthoyts Exp $
+# RCS: @(#) $Id: zlib.test,v 1.10 2009/07/09 22:48:44 patthoyts Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2.1
@@ -175,7 +175,7 @@ test zlib-9.1 "check fcopy with push" -constraints zlib -setup {
removeFile $sfile
} -returnCodes {ok} -result {copied 81920 size 81920}
test zlib-9.2 "socket fcopy with push" -constraints zlib -setup {
- set srv [socket -server {apply {{c a p} {
+ set srv [socket -myaddr localhost -server {apply {{c a p} {
chan configure $c -encoding binary -translation binary
puts -nonewline $c [zlib gzip [string repeat a 81920]]
close $c
@@ -196,7 +196,8 @@ test zlib-9.2 "socket fcopy with push" -constraints zlib -setup {
removeFile $file
} -returnCodes {ok error} -result {read 81920 size 81920}
test zlib-9.3 "socket fcopy bg (identity)" -constraints zlib -setup {
- set srv [socket -server {apply {{c a p} {
+ set srv [socket -myaddr localhost -server {apply {{c a p} {
+ puts "connection from $a:$p on $c"
chan configure $c -encoding binary -translation binary
puts -nonewline $c [string repeat a 81920]
close $c
@@ -204,7 +205,8 @@ test zlib-9.3 "socket fcopy bg (identity)" -constraints zlib -setup {
set file [makeFile {} test.gz]
} -body {
lassign [chan configure $srv -sockname] addr name port
- set sin [socket $addr $port]
+ puts "listening for connections on $addr $port"
+ set sin [socket localhost $port]
chan configure $sin -translation binary
update
set fout [open $file wb]
@@ -217,9 +219,10 @@ test zlib-9.3 "socket fcopy bg (identity)" -constraints zlib -setup {
list read $::total size [file size $file]
} -cleanup {
close $srv
+ removeFile $file
} -returnCodes {ok error} -result {read 81920 size 81920}
test zlib-9.4 "socket fcopy bg (gzip)" -constraints zlib -setup {
- set srv [socket -server {apply {{c a p} {
+ set srv [socket -myaddr localhost -server {apply {{c a p} {
chan configure $c -encoding binary -translation binary
puts -nonewline $c [zlib gzip [string repeat a 81920]]
close $c
@@ -244,7 +247,7 @@ test zlib-9.4 "socket fcopy bg (gzip)" -constraints zlib -setup {
removeFile $file
} -result {read 81920 size 81920}
test zlib-9.5 "socket fcopy incremental (gzip)" -constraints zlib -setup {
- set srv [socket -server {apply {{c a p} {
+ set srv [socket -myaddr localhost -server {apply {{c a p} {
chan configure $c -encoding binary -translation binary
puts -nonewline $c [zlib gzip [string repeat a 81920]]
close $c
@@ -277,6 +280,91 @@ test zlib-9.5 "socket fcopy incremental (gzip)" -constraints zlib -setup {
rename zlib95copy {}
removeFile $file
} -result {{eof 81920} size 81920}
+
+test zlib-9.6 "bug #2818131 (gzip)" -constraints zlib -setup {
+ proc zlib96read {c} {
+ set d [read $c]
+ if {[eof $c]} {
+ chan event $c readable {}
+ set ::total [list eof [string length $d]]
+ }
+ }
+ set srv [socket -myaddr localhost -server {apply {{c a p} {
+ chan configure $c -translation binary -buffering none
+ zlib push gzip $c
+ puts -nonewline $c [string repeat hello 100]
+ close $c
+ }}} 0]
+} -body {
+ lassign [chan configure $srv -sockname] addr name port
+ after 1000 {set ::total timeout}
+ set s [socket $addr $port]
+ chan configure $s -translation binary -buffering none
+ zlib push gunzip $s
+ chan event $s readable [list zlib96read $s]
+ vwait ::total
+ close $s
+ set ::total
+} -cleanup {
+ close $srv
+ rename zlib96read {}
+} -returnCodes {ok error} -result {eof 500}
+test zlib-9.7 "bug #2818131 (compress)" -constraints zlib -setup {
+ proc zlib97read {c} {
+ set d [read $c]
+ if {[eof $c]} {
+ chan event $c readable {}
+ set ::total [list eof [string length $d]]
+ }
+ }
+ set srv [socket -myaddr localhost -server {apply {{c a p} {
+ chan configure $c -translation binary -buffering none
+ zlib push compress $c
+ puts -nonewline $c [string repeat hello 100]
+ close $c
+ }}} 0]
+} -body {
+ lassign [chan configure $srv -sockname] addr name port
+ after 1000 {set ::total timeout}
+ set s [socket $addr $port]
+ chan configure $s -translation binary -buffering none
+ zlib push decompress $s
+ chan event $s readable [list zlib97read $s]
+ vwait ::total
+ close $s
+ set ::total
+} -cleanup {
+ close $srv
+ rename zlib97read {}
+} -returnCodes {ok error} -result {eof 500}
+test zlib-9.8 "bug #2818131 (deflate)" -constraints zlib -setup {
+ proc zlib98read {c} {
+ set d [read $c]
+ if {[eof $c]} {
+ chan event $c readable {}
+ set ::total [list eof [string length $d]]
+ }
+ }
+ set srv [socket -myaddr localhost -server {apply {{c a p} {
+ chan configure $c -translation binary -buffering none
+ zlib push deflate $c
+ puts -nonewline $c [string repeat hello 100]
+ close $c
+ }}} 0]
+} -body {
+ lassign [chan configure $srv -sockname] addr name port
+ after 1000 {set ::total timeout}
+ set s [socket $addr $port]
+ chan configure $s -translation binary -buffering none
+ zlib push inflate $s
+ chan event $s readable [list zlib98read $s]
+ vwait ::total
+ close $s
+ set ::total
+} -cleanup {
+ close $srv
+ rename zlib98read {}
+} -returnCodes {ok error} -result {eof 500}
::tcltest::cleanupTests
return