summaryrefslogtreecommitdiffstats
path: root/tests/http11.test
diff options
context:
space:
mode:
authorkjnash <k.j.nash@usa.net>2023-12-19 17:26:09 (GMT)
committerkjnash <k.j.nash@usa.net>2023-12-19 17:26:09 (GMT)
commit5e4e23217ab53c221a1ac6c7d756d8d6d6c1b3f3 (patch)
treebf0fea23221aa917669cf8f04670804b67fbfd59 /tests/http11.test
parente7bda898c7a30c0cb7d4f08b91582ee7129fc01c (diff)
downloadtcl-5e4e23217ab53c221a1ac6c7d756d8d6d6c1b3f3.zip
tcl-5e4e23217ab53c221a1ac6c7d756d8d6d6c1b3f3.tar.gz
tcl-5e4e23217ab53c221a1ac6c7d756d8d6d6c1b3f3.tar.bz2
Improve tests/http.test, tests/http11.test, tests/httpPipeline.test. Catch unimportant cleanup errors. Print full-file summary by default (not per-ThreadLevel).
Diffstat (limited to 'tests/http11.test')
-rw-r--r--tests/http11.test115
1 files changed, 64 insertions, 51 deletions
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 "<html><head><title>test</title></head><body><p>this is a test</p>\n[st
makeFile "<html><head><title>test</title></head><body><p>this is a test</p>\n[string repeat {<p>This is a tcl test file.</p>} 5000]\n</body></html>" 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
+}