From 5e4e23217ab53c221a1ac6c7d756d8d6d6c1b3f3 Mon Sep 17 00:00:00 2001 From: kjnash Date: Tue, 19 Dec 2023 17:26:09 +0000 Subject: Improve tests/http.test, tests/http11.test, tests/httpPipeline.test. Catch unimportant cleanup errors. Print full-file summary by default (not per-ThreadLevel). --- tests/http.test | 124 +++++++++++++++++++++++++++--------------------- tests/http11.test | 115 ++++++++++++++++++++++++-------------------- tests/httpPipeline.test | 15 +++++- tests/httpProxy.test | 18 +++---- 4 files changed, 157 insertions(+), 115 deletions(-) diff --git a/tests/http.test b/tests/http.test index 2240d41..c77dceb 100644 --- a/tests/http.test +++ b/tests/http.test @@ -20,6 +20,9 @@ source [file join [file dirname [info script]] tcltests.tcl] package require http 2.10 #http::register http 80 ::socket +# To write a separate summary for each value of ThreadLevel, set constraint ThreadLevelSummary. +#testConstraint ThreadLevelSummary 0 + proc bgerror {args} { global errorInfo puts stderr "http.test bgerror" @@ -69,6 +72,11 @@ if {[catch {package present Thread}] == 0 && [file exists $httpdFile]} { set threadStack {} } +if 0 { + # For debugging: run with a single value of ThreadLevel: 0|1|2 + set ThreadLevel 0 + testConstraint ThreadLevelSummary 1 +} if {![info exists ThreadLevel]} { if {[catch {package require Thread}] == 0} { set ValueRange {0 1 2} @@ -86,6 +94,9 @@ if {![info exists ThreadLevel]} { } catch {unset ThreadLevel} catch {unset ValueRange} + if {![testConstraint ThreadLevelSummary]} { + ::tcltest::cleanupTests + } return } @@ -163,7 +174,7 @@ test http-3.3.$ThreadLevel {http::geturl} -body { set token [http::geturl $url] http::data $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

GET /

@@ -183,7 +194,7 @@ test http-3.4.$ThreadLevel {http::geturl} -body { set token [http::geturl $url] http::data $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

GET $tail

@@ -198,7 +209,7 @@ test http-3.5.$ThreadLevel {http::geturl} -body { http::data $token } -cleanup { http::config -proxyfilter http::ProxyRequired - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

GET http:$url

@@ -209,7 +220,7 @@ test http-3.6.$ThreadLevel {http::geturl} -body { http::data $token } -cleanup { http::config -proxyfilter http::ProxyRequired - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

GET $tail

@@ -218,7 +229,7 @@ test http-3.7.$ThreadLevel {http::geturl} -body { set token [http::geturl $url -headers {Pragma no-cache}] http::data $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

GET $tail

@@ -227,7 +238,7 @@ test http-3.8.$ThreadLevel {http::geturl} -body { set token [http::geturl $url -query Name=Value&Foo=Bar -timeout 3000] http::data $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

POST $tail

@@ -241,7 +252,7 @@ test http-3.9.$ThreadLevel {http::geturl} -body { set token [http::geturl $url -validate 1] http::code $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 200 OK" test http-3.10.$ThreadLevel {http::geturl queryprogress} -setup { set query foo=bar @@ -254,17 +265,17 @@ test http-3.10.$ThreadLevel {http::geturl queryprogress} -setup { set sep & } } -body { - proc postProgress {token x y} { + proc postProgress {tok x y} { global postProgress lappend postProgress $y } set postProgress {} - set t [http::geturl $posturl -keepalive 0 -query $query \ + set token [http::geturl $posturl -keepalive 0 -query $query \ -queryprogress postProgress -queryblocksize 16384] - http::wait $t - list [http::status $t] [string length $query] $postProgress [http::data $t] + http::wait $token + list [http::status $token] [string length $query] $postProgress [http::data $token] } -cleanup { - http::cleanup $t + catch {http::cleanup $token} } -result {ok 122879 {16384 32768 49152 65536 81920 98304 114688 122879} {Got 122879 bytes}} test http-3.11.$ThreadLevel {http::geturl querychannel with -command} -setup { set query foo=bar @@ -279,26 +290,26 @@ test http-3.11.$ThreadLevel {http::geturl querychannel with -command} -setup { set file [makeFile $query outdata] } -body { set fp [open $file] - proc asyncCB {token} { + proc asyncCB {tok} { global postResult - lappend postResult [http::data $token] + lappend postResult [http::data $tok] } set postResult [list ] - set t [http::geturl $posturl -querychannel $fp] - http::wait $t - set testRes [list [http::status $t] [string length $query] [http::data $t]] + set token [http::geturl $posturl -querychannel $fp] + http::wait $token + set testRes [list [http::status $token] [string length $query] [http::data $token]] # Now do async - http::cleanup $t + http::cleanup $token close $fp set fp [open $file] - set t [http::geturl $posturl -querychannel $fp -command asyncCB] + set token [http::geturl $posturl -querychannel $fp -command asyncCB] set postResult [list PostStart] - http::wait $t + http::wait $token close $fp - lappend testRes [http::status $t] $postResult + lappend testRes [http::status $token] $postResult } -cleanup { removeFile outdata - http::cleanup $t + catch {http::cleanup $token} } -result {ok 122879 {Got 122880 bytes} ok {PostStart {Got 122880 bytes}}} # On Linux platforms when the client and server are on the same host, the # client is unable to read the server's response one it hits the write error. @@ -318,11 +329,11 @@ test http-3.12.$ThreadLevel {http::geturl querychannel with aborted request} -se set file [makeFile $query outdata] } -constraints {nonPortable} -body { set fp [open $file] - proc asyncCB {token} { + proc asyncCB {tok} { global postResult - lappend postResult [http::data $token] + lappend postResult [http::data $tok] } - proc postProgress {token x y} { + proc postProgress {tok x y} { global postProgress lappend postProgress $y } @@ -330,18 +341,18 @@ test http-3.12.$ThreadLevel {http::geturl querychannel with aborted request} -se # Now do async set postResult [list PostStart] if {[catch { - set t [http::geturl $badposturl -querychannel $fp -command asyncCB \ + set token [http::geturl $badposturl -querychannel $fp -command asyncCB \ -queryprogress postProgress] - http::wait $t - upvar #0 $t state + http::wait $token + upvar #0 $token state } err]} { puts $::errorInfo error $err } - list [http::status $t] [http::code $t] + list [http::status $token] [http::code $token] } -cleanup { removeFile outdata - http::cleanup $t + catch {http::cleanup $token} } -result {ok {HTTP/1.0 200 Data follows}} test http-3.13.$ThreadLevel {http::geturl socket leak test} { set chanCount [llength [file channels]] @@ -355,7 +366,7 @@ test http-3.14.$ThreadLevel "http::geturl $fullurl" -body { set token [http::geturl $fullurl -validate 1] http::code $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 200 OK" test http-3.15.$ThreadLevel {http::geturl parse failures} -body { http::geturl "{invalid}:url" @@ -394,7 +405,7 @@ test http-3.25.$ThreadLevel {http::meta} -setup { array set m [http::meta $token] lsort [array names m] } -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain m token } -result {content-length content-type date} test http-3.26.$ThreadLevel {http::meta} -setup { @@ -404,7 +415,7 @@ test http-3.26.$ThreadLevel {http::meta} -setup { array set m [http::meta $token] lsort [array names m] } -cleanup { - http::cleanup $token + catch {http::cleanup $token} unset -nocomplain m token } -result {content-length content-type date x-check} test http-3.27.$ThreadLevel {http::geturl: -headers override -type} -body { @@ -412,7 +423,7 @@ test http-3.27.$ThreadLevel {http::geturl: -headers override -type} -body { -headers [list "Content-Type" "text/plain;charset=utf-8"]] http::data $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -match regexp -result {(?n)Host .* User-Agent .* Content-Type {text/plain;charset=utf-8} @@ -425,7 +436,7 @@ test http-3.28.$ThreadLevel {http::geturl: -headers override -type default} -bod -headers [list "Content-Type" "text/plain;charset=utf-8"]] http::data $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -match regexp -result {(?n)Host .* User-Agent .* Content-Type {text/plain;charset=utf-8} @@ -445,19 +456,19 @@ test http-3.29.$ThreadLevel {http::geturl IPv6 address} -body { } set error } -cleanup { - catch { http::cleanup $token } + catch {http::cleanup $token} } -result 0 test http-3.30.$ThreadLevel {http::geturl query without path} -body { set token [http::geturl $authorityurl?var=val] http::ncode $token } -cleanup { - catch { http::cleanup $token } + catch {http::cleanup $token} } -result 200 test http-3.31.$ThreadLevel {http::geturl fragment without path} -body { set token [http::geturl "$authorityurl#fragment42"] http::ncode $token } -cleanup { - catch { http::cleanup $token } + catch {http::cleanup $token} } -result 200 # Bug c11a51c482 test http-3.32.$ThreadLevel {http::geturl: -headers override -accept default} -body { @@ -465,7 +476,7 @@ test http-3.32.$ThreadLevel {http::geturl: -headers override -accept default} -b -headers [list "Accept" "text/plain,application/tcl-test-value"]] http::data $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -match regexp -result {(?n)Host .* User-Agent .* Accept text/plain,application/tcl-test-value @@ -478,7 +489,7 @@ test http-3.33.$ThreadLevel {http::geturl application/xml is text} -body { set token [http::geturl "$xmlurl"] scan [http::data $token] "<%\[^>]>%c<%\[^>]>" } -cleanup { - catch { http::cleanup $token } + catch {http::cleanup $token} } -result {test 4660 /test} test http-3.34.$ThreadLevel {http::geturl -headers not a list} -returnCodes error -body { http::geturl http://test/t -headers \" @@ -493,7 +504,7 @@ test http-4.1.$ThreadLevel {http::Event} -body { array set meta $data(meta) expr {($data(totalsize) == $meta(content-length))} } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result 1 test http-4.2.$ThreadLevel {http::Event} -body { set token [http::geturl $url] @@ -501,13 +512,13 @@ test http-4.2.$ThreadLevel {http::Event} -body { array set meta $data(meta) string compare $data(type) [string trim $meta(content-type)] } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result 0 test http-4.3.$ThreadLevel {http::Event} -body { set token [http::geturl $url] http::code $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {HTTP/1.0 200 Data follows} test http-4.4.$ThreadLevel {http::Event} -setup { set testfile [makeFile "" testfile] @@ -521,7 +532,7 @@ test http-4.4.$ThreadLevel {http::Event} -setup { catch {close $in} catch {close $out} removeFile $testfile - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

GET $tail

@@ -537,7 +548,7 @@ test http-4.5.$ThreadLevel {http::Event} -setup { expr {$data(currentsize) == $data(totalsize)} } -cleanup { removeFile $testfile - http::cleanup $token + catch {http::cleanup $token} } -result 1 test http-4.6.$ThreadLevel {http::Event} -setup { set testfile [makeFile "" testfile] @@ -552,7 +563,7 @@ test http-4.6.$ThreadLevel {http::Event} -setup { catch {close $in} catch {close $out} removeFile $testfile - http::cleanup $token + catch {http::cleanup $token} } -result "$bindata[string trimleft $binurl /]" proc myProgress {token total current} { global progress httpLog @@ -569,25 +580,25 @@ test http-4.7.$ThreadLevel {http::Event} -body { set token [http::geturl $url -keepalive 0 -progress myProgress] return $progress } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {111 111} test http-4.8.$ThreadLevel {http::Event} -body { set token [http::geturl $url] http::status $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {ok} test http-4.9.$ThreadLevel {http::Event} -body { set token [http::geturl $url -progress myProgress] http::code $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {HTTP/1.0 200 Data follows} test http-4.10.$ThreadLevel {http::Event} -body { set token [http::geturl $url -progress myProgress] http::size $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {111} # Timeout cases @@ -598,7 +609,7 @@ test http-4.11.$ThreadLevel {http::Event} -body { http::reset $token http::status $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {reset} # Longer timeout with reset. @@ -607,7 +618,7 @@ test http-4.12.$ThreadLevel {http::Event} -body { http::reset $token http::status $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {reset} # Medium timeout to working server that waits even longer. The timeout @@ -617,7 +628,7 @@ test http-4.13.$ThreadLevel {http::Event} -body { http::wait $token http::status $token } -cleanup { - http::cleanup $token + catch {http::cleanup $token} } -result {timeout} # Longer timeout to good host, bad port, gets an error after the @@ -705,7 +716,7 @@ test http-6.1.$ThreadLevel {http::ProxyRequired} -body { set data(body) } -cleanup { http::config -proxyhost {} -proxyport {} - http::cleanup $token + catch {http::cleanup $token} } -result "HTTP/1.0 TEST

Hello, World!

GET http:$url

@@ -1201,7 +1212,10 @@ if {[info exists removeHttpd]} { } rename bgerror {} -::tcltest::cleanupTests + +if {[testConstraint ThreadLevelSummary]} { + ::tcltest::cleanupTests +} # Local variables: # mode: tcl diff --git a/tests/http11.test b/tests/http11.test index af35763..0b3c560 100644 --- a/tests/http11.test +++ b/tests/http11.test @@ -87,6 +87,14 @@ makeFile "test

this is a test

\n[st makeFile "test

this is a test

\n[string repeat {

This is a tcl test file.

} 5000]\n" largedoc.html +# To write a separate summary for each value of ThreadLevel, set constraint ThreadLevelSummary. +#testConstraint ThreadLevelSummary 0 + +if 0 { + # For debugging: run with a single value of ThreadLevel: 0|1|2 + set ThreadLevel 0 + testConstraint ThreadLevelSummary 1 +} if {![info exists ThreadLevel]} { if {[catch {package require Thread}] == 0} { set ValueRange {0 1 2} @@ -101,6 +109,9 @@ if {![info exists ThreadLevel]} { } catch {unset ThreadLevel} catch {unset ValueRange} + if {![testConstraint ThreadLevelSummary]} { + ::tcltest::cleanupTests + } return } @@ -116,7 +127,7 @@ test http11-1.0.$ThreadLevel "normal request for document " -setup { http::wait $tok list [http::status $tok] [http::code $tok] [check_crc $tok] [meta $tok connection] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok close} @@ -130,7 +141,7 @@ test http11-1.1.$ThreadLevel "normal,gzip,non-chunked" -setup { [meta $tok content-encoding] [meta $tok transfer-encoding] \ [http::meta $tok content-encoding] [http::meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok gzip {} {content-encoding gzip} {}} @@ -143,7 +154,7 @@ test http11-1.2.$ThreadLevel "normal,deflated,non-chunked" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok deflate {}} @@ -156,7 +167,7 @@ test http11-1.2.1.$ThreadLevel "normal,deflated,non-chunked,msdeflate" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok deflate {}} @@ -171,7 +182,7 @@ test http11-1.3.$ThreadLevel "normal,compressed,non-chunked" -constraints badCom list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok compress {}} @@ -184,7 +195,7 @@ test http11-1.4.$ThreadLevel "normal,identity,non-chunked" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok {} {}} @@ -197,7 +208,7 @@ test http11-1.5.$ThreadLevel "normal request for document, unsupported coding" - list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok {}} @@ -211,7 +222,7 @@ test http11-1.6.$ThreadLevel "normal, specify 1.1 " -setup { [meta $tok connection] [meta $tok transfer-encoding] \ [http::meta $tok connection] [http::meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok close chunked {connection close} {transfer-encoding chunked}} @@ -224,7 +235,7 @@ test http11-1.7.$ThreadLevel "normal, 1.1 and keepalive " -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok connection] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok {} chunked} @@ -237,7 +248,7 @@ test http11-1.8.$ThreadLevel "normal, 1.1 and keepalive, server close" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok connection] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok close {}} @@ -250,7 +261,7 @@ test http11-1.9.$ThreadLevel "normal,gzip,chunked" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok gzip chunked} @@ -263,7 +274,7 @@ test http11-1.10.$ThreadLevel "normal,deflate,chunked" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok deflate chunked} @@ -276,7 +287,7 @@ test http11-1.10.1.$ThreadLevel "normal,deflate,chunked,msdeflate" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok deflate chunked} @@ -291,7 +302,7 @@ test http11-1.11.$ThreadLevel "normal,compress,chunked" -constraints badCompress list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok compress chunked} @@ -304,7 +315,7 @@ test http11-1.12.$ThreadLevel "normal,identity,chunked" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok] \ [meta $tok content-encoding] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {ok {HTTP/1.1 200 OK} ok {} chunked} @@ -325,8 +336,8 @@ test http11-1.13.$ThreadLevel "normal, 1.1 and keepalive as server default, no z [meta $toj connection] [meta $toj transfer-encoding] [state $toj reusing] [state $toj connection]] concat $res1 -- $res2 } -cleanup { - http::cleanup $tok - http::cleanup $toj + catch {http::cleanup $tok} + catch {http::cleanup $toj} halt_httpd http::config -zip $zipTmp } -result {ok {HTTP/1.1 200 OK} ok {} {} 0 keep-alive -- ok {HTTP/1.1 200 OK} ok {} {} 1 keep-alive} @@ -359,7 +370,7 @@ test http11-2.0.$ThreadLevel "-channel" -setup { list [http::status $tok] [http::code $tok] [check_crc $tok $data]\ [meta $tok connection] [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -379,7 +390,7 @@ test http11-2.1.$ThreadLevel "-channel, encoding gzip" -setup { [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] -- $diff bytes lost } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -403,7 +414,7 @@ test http11-2.1.1.$ThreadLevel "-channel, encoding gzip" -setup { [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] -- $diff bytes lost } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -422,7 +433,7 @@ test http11-2.2.$ThreadLevel "-channel, encoding deflate" -setup { [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -441,7 +452,7 @@ test http11-2.2.1.$ThreadLevel "-channel, encoding deflate,msdeflate" -setup { [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -463,7 +474,7 @@ test http11-2.3.$ThreadLevel "-channel,encoding compress" -constraints badCompre [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -483,7 +494,7 @@ test http11-2.4.$ThreadLevel "-channel,encoding identity" -setup { [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -508,7 +519,7 @@ test http11-2.4.1.$ThreadLevel "-channel,encoding identity with -progress" -setu [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ [expr {[lindex $logdata 0] - [string length $data]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -534,7 +545,7 @@ test http11-2.4.2.$ThreadLevel "-channel,encoding identity with -progress progre [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ [expr {[lindex $logdata 0] - [string length $data]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -555,7 +566,7 @@ test http11-2.5.$ThreadLevel "-channel,encoding unsupported" -setup { [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -575,7 +586,7 @@ test http11-2.6.$ThreadLevel "-channel,encoding gzip,non-chunked" -setup { [meta $tok transfer-encoding]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -595,7 +606,7 @@ test http11-2.7.$ThreadLevel "-channel,encoding deflate,non-chunked" -setup { [meta $tok transfer-encoding]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -618,7 +629,7 @@ test http11-2.7.1.$ThreadLevel "-channel,encoding deflate,non-chunked,msdeflate" [meta $tok transfer-encoding]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -640,7 +651,7 @@ test http11-2.8.$ThreadLevel "-channel,encoding compress,non-chunked" -constrain [meta $tok transfer-encoding]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -660,7 +671,7 @@ test http11-2.9.$ThreadLevel "-channel,encoding identity,non-chunked" -setup { [meta $tok transfer-encoding]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -681,7 +692,7 @@ test http11-2.10.$ThreadLevel "-channel,deflate,keepalive" -setup { [meta $tok transfer-encoding]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -702,7 +713,7 @@ test http11-2.10.1.$ThreadLevel "-channel,deflate,keepalive,msdeflate" -setup { [meta $tok transfer-encoding]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -722,7 +733,7 @@ test http11-2.11.$ThreadLevel "-channel,identity,keepalive" -setup { [meta $tok connection] [meta $tok content-encoding]\ [meta $tok transfer-encoding] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -742,7 +753,7 @@ test http11-2.12.$ThreadLevel "-channel,negotiate,keepalive" -setup { [meta $tok transfer-encoding] [meta $tok x-requested-encodings]\ [expr {[file size testdoc.html]-[file size testfile.tmp]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -788,7 +799,7 @@ test http11-3.0.$ThreadLevel "-handler,close,identity" -setup { [meta $tok transfer-encoding] \ [expr {[file size testdoc.html]-[string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata halt_httpd } -result {ok {HTTP/1.0 200 OK} ok close {} {} 0} @@ -806,7 +817,7 @@ test http11-3.1.$ThreadLevel "-handler,protocol1.0" -setup { [meta $tok transfer-encoding] \ [expr {[file size testdoc.html]-[string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata halt_httpd } -result {ok {HTTP/1.0 200 OK} ok close {} {} 0} @@ -824,7 +835,7 @@ test http11-3.2.$ThreadLevel "-handler,close,chunked" -setup { [meta $tok transfer-encoding] \ [expr {[file size testdoc.html]-[string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata halt_httpd } -result {ok {HTTP/1.0 200 OK} ok close {} {} 0} @@ -842,7 +853,7 @@ test http11-3.3.$ThreadLevel "-handler,keepalive,chunked" -setup { [meta $tok transfer-encoding] \ [expr {[file size testdoc.html]-[string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata halt_httpd } -result {ok {HTTP/1.0 200 OK} ok close {} {} 0} @@ -869,7 +880,7 @@ test http11-3.4.$ThreadLevel "-handler,close,identity; HTTP/1.0 server does not [meta $tok transfer-encoding] \ [expr {[file size testdoc.html]-[string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata halt_httpd } -result {ok {HTTP/1.0 200 OK} ok {} {} {} 0} @@ -887,7 +898,7 @@ test http11-3.5.$ThreadLevel "-handler,close,identity as http11-3.0 but handlerP [meta $tok transfer-encoding] \ [expr {[file size testdoc.html]-[string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata ::WaitHere halt_httpd } -result {ok {HTTP/1.0 200 OK} ok close {} {} 0} @@ -908,7 +919,7 @@ test http11-3.6.$ThreadLevel "-handler,close,identity as http11-3.0 but with -pr [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ [expr {[lindex $logdata 0] - [string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata logdata ::WaitHere halt_httpd } -result {ok {HTTP/1.0 200 OK} ok close {} {} 0 0 0} @@ -929,7 +940,7 @@ test http11-3.7.$ThreadLevel "-handler,close,identity as http11-3.0 but with -pr [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ [expr {[lindex $logdata 0] - [string length $testdata]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain testdata logdata ::WaitHere halt_httpd } -result {ok {HTTP/1.0 200 OK} ok close {} {} 0 0 0} @@ -950,7 +961,7 @@ test http11-3.8.$ThreadLevel "close,identity no -handler but with -progress" -se [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ [expr {[lindex $logdata 0] - [string length [http::data $tok]]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain logdata ::WaitHere halt_httpd } -result {ok {HTTP/1.1 200 OK} ok close {} {} 0 0 0} @@ -971,7 +982,7 @@ test http11-3.9.$ThreadLevel "close,identity no -handler but with -progress prog [expr {[lindex $logdata 0] - [lindex $logdata 1]}] \ [expr {[lindex $logdata 0] - [string length [http::data $tok]]}] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} unset -nocomplain logdata ::WaitHere halt_httpd } -result {ok {HTTP/1.1 200 OK} ok close {} {} 0 0 0} @@ -988,7 +999,7 @@ test http11-4.0.$ThreadLevel "normal post request" -setup { connection [meta $tok connection]\ query-length [meta $tok x-query-length] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {status ok code {HTTP/1.1 200 OK} crc ok connection close query-length 7} @@ -1005,7 +1016,7 @@ test http11-4.1.$ThreadLevel "normal post request, check query length" -setup { connection [meta $tok connection]\ query-length [meta $tok x-query-length] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {status ok code {HTTP/1.1 200 OK} crc ok connection close query-length 7} @@ -1022,7 +1033,7 @@ test http11-4.2.$ThreadLevel "normal post request, check long query length" -set connection [meta $tok connection]\ query-length [meta $tok x-query-length] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} halt_httpd } -result {status ok code {HTTP/1.1 200 OK} crc ok connection close query-length 24576} @@ -1042,7 +1053,7 @@ test http11-4.3.$ThreadLevel "normal post request, check channel query length" - connection [meta $tok connection]\ query-length [meta $tok x-query-length] } -cleanup { - http::cleanup $tok + catch {http::cleanup $tok} close $chan removeFile testfile.tmp halt_httpd @@ -1064,4 +1075,6 @@ removeFile testdoc.html removeFile largedoc.html unset -nocomplain httpd_port httpd p -::tcltest::cleanupTests +if {[testConstraint ThreadLevelSummary]} { + ::tcltest::cleanupTests +} diff --git a/tests/httpPipeline.test b/tests/httpPipeline.test index 491aae0..ef62aa3 100644 --- a/tests/httpPipeline.test +++ b/tests/httpPipeline.test @@ -19,6 +19,14 @@ package require http 2.10 # (0) Socket Creation in Thread, which triples the number of tests. # ------------------------------------------------------------------------------ +# To write a separate summary for each value of ThreadLevel, set constraint ThreadLevelSummary. +#testConstraint ThreadLevelSummary 0 + +if 0 { + # For debugging: run with a single value of ThreadLevel: 0|1|2 + set ThreadLevel 0 + testConstraint ThreadLevelSummary 1 +} if {![info exists ThreadLevel]} { if {[catch {package require Thread}] == 0} { set ValueRange {0 1 2} @@ -33,6 +41,9 @@ if {![info exists ThreadLevel]} { } catch {unset ThreadLevel} catch {unset ValueRange} + if {![testConstraint ThreadLevelSummary]} { + ::tcltest::cleanupTests + } return } @@ -889,4 +900,6 @@ unset header footer delay label suffix match cons name te namespace delete ::httpTest namespace delete ::httpTestScript -::tcltest::cleanupTests +if {[testConstraint ThreadLevelSummary]} { + ::tcltest::cleanupTests +} diff --git a/tests/httpProxy.test b/tests/httpProxy.test index 2429811..49818c9 100644 --- a/tests/httpProxy.test +++ b/tests/httpProxy.test @@ -41,16 +41,18 @@ proc stopMe {token} { set ${token}(z) done } proc putsBlurb {} { + puts {} puts {- Constraints needsTls, knownTwapiFullBugThreadlevelAny, knownTwapiFullBugThreadUsed are} puts { always set by the script, not by the caller.} puts {- Set one of needsTclTls, needsTwapi, needsTwapiFull instead of needsTls.} puts {- Set knownBug instead of knownTwapiFullBugThreadlevelAny, knownTwapiFullBugThreadUsed.} puts {- If the caller sets constraint needsTwapi, the script forces needsSquidNoAuth and needsSquidAuth to 0.} + puts {} return } if 0 { - # Run with a single velue of ThreadLevel: 0|1|2 + # For debugging: run with a single value of ThreadLevel: 0|1|2 set ThreadLevel 0 testConstraint ThreadLevelSummary 1 } @@ -68,10 +70,9 @@ if {![info exists ThreadLevel]} { } catch {unset ThreadLevel} catch {unset ValueRange} - if {![testConstraint ThreadLevelSummary] - } { - ::tcltest::cleanupTests + if {![testConstraint ThreadLevelSummary]} { putsBlurb + ::tcltest::cleanupTests } return } @@ -187,9 +188,10 @@ foreach constr { knownTwapiFullBugThreadlevelAny knownTwapiFullBugThreadUsed } { - puts [list testConstraint $constr [testConstraint $constr]] + # For debugging. + # puts [list testConstraint $constr [testConstraint $constr]] } -putsBlurb +#putsBlurb test httpProxy-1.1.$ThreadLevel {squid is running - ipv4 no-auth} -constraints {needsSquidNoAuth} -setup { } -body { @@ -1373,11 +1375,11 @@ rename bgerror {} rename stopMe {} if {[testConstraint ThreadLevelSummary]} { - ::tcltest::cleanupTests putsBlurb + ::tcltest::cleanupTests + rename putsBlurb {} } - # Local variables: # mode: tcl # End: -- cgit v0.12