diff options
author | patthoyts <patthoyts@users.sourceforge.net> | 2009-07-05 21:46:27 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@users.sourceforge.net> | 2009-07-05 21:46:27 (GMT) |
commit | 48a923c5b4899bc7055153a8e28e25489b33fab6 (patch) | |
tree | 26c66852446eb0f99c59734880f3a357551c592f | |
parent | cfa39b67096861fc66251643dfa7e91be2f3385d (diff) | |
download | tcl-48a923c5b4899bc7055153a8e28e25489b33fab6.zip tcl-48a923c5b4899bc7055153a8e28e25489b33fab6.tar.gz tcl-48a923c5b4899bc7055153a8e28e25489b33fab6.tar.bz2 |
Additional tests for zlib stacked channel with fcopy in various modes.
-rw-r--r-- | tests/zlib.test | 121 |
1 files changed, 120 insertions, 1 deletions
diff --git a/tests/zlib.test b/tests/zlib.test index dae1861..b8d6e66 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.8 2009/07/05 16:05:59 dkf Exp $ +# RCS: @(#) $Id: zlib.test,v 1.9 2009/07/05 21:46:27 patthoyts Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2.1 @@ -158,6 +158,125 @@ test zlib-8.3 {zlib transformation and fileevent} -constraints zlib -setup { close $srv removeFile $file } -result 81920-->81920 +test zlib-9.1 "check fcopy with push" -constraints zlib -setup { + set sfile [makeFile {} testsrc.gz] + set file [makeFile {} test.gz] + set f [open $sfile wb] + puts -nonewline $f [zlib gzip [string repeat a 81920]] + close $f +} -body { + set fin [zlib push gunzip [open $sfile rb]] + set fout [open $file wb] + set total [fcopy $fin $fout] + close $fin ; close $fout + list copied $total size [file size $file] +} -cleanup { + removeFile $file + 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} { + chan configure $c -encoding binary -translation binary + puts -nonewline $c [zlib gzip [string repeat a 81920]] + close $c + }}} 0] + set file [makeFile {} test.gz] +} -body { + lassign [chan configure $srv -sockname] addr name port + set sin [socket $addr $port] + chan configure $sin -translation binary + zlib push gunzip $sin + update + set total [fcopy $sin [set fout [open $file wb]]] + close $sin + close $fout + list read $total size [file size $file] +} -cleanup { + close $srv + 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} { + chan configure $c -encoding binary -translation binary + puts -nonewline $c [string repeat a 81920] + close $c + }}} 0] + set file [makeFile {} test.gz] +} -body { + lassign [chan configure $srv -sockname] addr name port + set sin [socket $addr $port] + chan configure $sin -translation binary + update + set fout [open $file wb] + after 1000 {set ::total timeout} + fcopy $sin $fout -command {apply {{c {e {}}} { + set ::total [expr {$e eq {} ? $c : $e}] + }}} + vwait ::total + close $sin; close $fout + list read $::total size [file size $file] +} -cleanup { + close $srv +} -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} { + chan configure $c -encoding binary -translation binary + puts -nonewline $c [zlib gzip [string repeat a 81920]] + close $c + }}} 0] + set file [makeFile {} test.gz] +} -body { + lassign [chan configure $srv -sockname] addr name port + set sin [socket $addr $port] + chan configure $sin -translation binary + zlib push gunzip $sin + update + set fout [open $file wb] + after 1000 {set ::total timeout} + fcopy $sin $fout -command {apply {{c {e {}}} { + set ::total [expr {$e eq {} ? $c : $e}] + }}} + vwait ::total + close $sin; close $fout + list read $::total size [file size $file] +} -cleanup { + close $srv + 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} { + chan configure $c -encoding binary -translation binary + puts -nonewline $c [zlib gzip [string repeat a 81920]] + close $c + }}} 0] + proc zlib95copy {i o t c {e {}}} { + incr t $c + if {$e ne {}} { + set ::total [list error $e] + } elseif {[eof $i]} { + set ::total [list eof $t] + } else { + fcopy $i $o -size 8192 -command [list zlib95copy $i $o $t] + } + } + set file [makeFile {} test.gz] +} -body { + lassign [chan configure $srv -sockname] addr name port + set sin [socket $addr $port] + chan configure $sin -translation binary + zlib push gunzip $sin + update + set fout [open $file wb] + after 1000 {set ::total timeout} + fcopy $sin $fout -size 8192 -command [list zlib95copy $sin $fout 0] + vwait ::total + close $sin; close $fout + list $::total size [file size $file] +} -cleanup { + close $srv + rename zlib95copy {} + removeFile $file +} -result {{eof 81920} size 81920} ::tcltest::cleanupTests return |