From 07fa017898edeacecf2cf454f053948cc7263d0d Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 2 Aug 2017 23:38:20 +0000 Subject: Fix weird hangs in macOS Sierra on some networks. Name resolution timeouts not what we want to test in the http package. --- tests/http.test | 29 ++++++++++++++++++----------- tests/httpd | 9 ++++++++- tests/httpold.test | 17 ++++++++++++----- 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/tests/http.test b/tests/http.test index e8f78e3..c2d2fe8 100644 --- a/tests/http.test +++ b/tests/http.test @@ -36,6 +36,13 @@ proc bgerror {args} { puts stderr $errorInfo } +if {$::tcl_platform(os) eq "Darwin"} { + # Name resolution often a problem on OSX; not focus of HTTP package anyway + set HOST localhost +} else { + set HOST [info hostname] +} + set port 8010 set bindata "This is binary data\x0d\x0amore\x0dmore\x0amore\x00null" catch {unset data} @@ -118,8 +125,8 @@ test http-3.1 {http::geturl} -returnCodes error -body { test http-3.2 {http::geturl} -returnCodes error -body { http::geturl http:junk } -result {Unsupported URL: http:junk} -set url //[info hostname]:$port -set badurl //[info hostname]:[expr $port+1] +set url //${::HOST}:$port +set badurl //${::HOST}:[expr $port+1] test http-3.3 {http::geturl} -body { set token [http::geturl $url] http::data $token @@ -130,13 +137,13 @@ test http-3.3 {http::geturl} -body {

GET /

" set tail /a/b/c -set url //[info hostname]:$port/a/b/c -set fullurl HTTP://user:pass@[info hostname]:$port/a/b/c -set binurl //[info hostname]:$port/binary -set xmlurl //[info hostname]:$port/xml -set posturl //[info hostname]:$port/post -set badposturl //[info hostname]:$port/droppost -set authorityurl //[info hostname]:$port +set url //${::HOST}:$port/a/b/c +set fullurl HTTP://user:pass@${::HOST}:$port/a/b/c +set binurl //${::HOST}:$port/binary +set xmlurl //${::HOST}:$port/xml +set posturl //${::HOST}:$port/post +set badposturl //${::HOST}:$port/droppost +set authorityurl //${::HOST}:$port set ipv6url http://\[::1\]:$port/ test http-3.4 {http::geturl} -body { set token [http::geturl $url] @@ -149,7 +156,7 @@ test http-3.4 {http::geturl} -body { " proc selfproxy {host} { global port - return [list [info hostname] $port] + return [list ${::HOST} $port] } test http-3.5 {http::geturl} -body { http::config -proxyfilter selfproxy @@ -620,7 +627,7 @@ test http-5.5 {http::formatQuery} { } {name1=~bwelch&name2=%A1%A2%A2} test http-6.1 {http::ProxyRequired} -body { - http::config -proxyhost [info hostname] -proxyport $port + http::config -proxyhost ${::HOST} -proxyport $port set token [http::geturl $url] http::wait $token upvar #0 $token data diff --git a/tests/httpd b/tests/httpd index 8753912..16e0382 100644 --- a/tests/httpd +++ b/tests/httpd @@ -10,6 +10,13 @@ #set httpLog 1 +if {$::tcl_platform(os) eq "Darwin"} { + # Name resolution often a problem on OSX; not focus of HTTP package anyway + set HOST localhost +} else { + set HOST [info hostname] +} + proc httpd_init {{port 8015}} { socket -server httpdAccept $port } @@ -168,7 +175,7 @@ proc httpdRespond { sock } { switch -glob -- $data(url) { *binary* { - set html "$bindata[info hostname]:$port$data(url)" + set html "$bindata${::HOST}:$port$data(url)" set type application/octet-stream } *xml* { diff --git a/tests/httpold.test b/tests/httpold.test index 5995bed..e63bcda 100644 --- a/tests/httpold.test +++ b/tests/httpold.test @@ -33,6 +33,13 @@ if {[catch {package require http 1.0}]} { } } +if {$::tcl_platform(os) eq "Darwin"} { + # Name resolution often a problem on OSX; not focus of HTTP package anyway + set HOST localhost +} else { + set HOST [info hostname] +} + set bindata "This is binary data\x0d\x0amore\x0dmore\x0amore\x00null" catch {unset data} @@ -85,7 +92,7 @@ test httpold-3.2 {http_get} { set err } {Unsupported URL: http:junk} -set url [info hostname]:$port +set url ${::HOST}:$port test httpold-3.3 {http_get} { set token [http_get $url] http_data $token @@ -95,8 +102,8 @@ test httpold-3.3 {http_get} { " set tail /a/b/c -set url [info hostname]:$port/a/b/c -set binurl [info hostname]:$port/binary +set url ${::HOST}:$port/a/b/c +set binurl ${::HOST}:$port/binary test httpold-3.4 {http_get} { set token [http_get $url] @@ -108,7 +115,7 @@ test httpold-3.4 {http_get} { proc selfproxy {host} { global port - return [list [info hostname] $port] + return [list ${::HOST} $port] } test httpold-3.5 {http_get} { http_config -proxyfilter selfproxy @@ -273,7 +280,7 @@ test httpold-5.3 {http_formatQuery} { test httpold-6.1 {httpProxyRequired} { update - http_config -proxyhost [info hostname] -proxyport $port + http_config -proxyhost ${::HOST} -proxyport $port set token [http_get $url] http_wait $token http_config -proxyhost {} -proxyport {} -- cgit v0.12 From c5d2a041f09785727fad67a457ca2b28aecefe82 Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 3 Aug 2017 14:39:59 +0000 Subject: Improved test http-4.16. --- tests/http.test | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/http.test b/tests/http.test index c2d2fe8..5a00cd5 100644 --- a/tests/http.test +++ b/tests/http.test @@ -599,14 +599,20 @@ test http-4.15 {http::Event} -body { } -cleanup { catch {http::cleanup $token} } -returnCodes 1 -match glob -result "couldn't open socket*" -test http-4.16 {Leak with Close vs Keepalive (bug [6ca52aec14]} -body { +test http-4.16 {Leak with Close vs Keepalive (bug [6ca52aec14]} -setup { + proc list-difference {l1 l2} { + lmap item $l2 {if {$item in $l1} continue; set item} + } +} -body { set before [chan names] set token [http::geturl $url -headers {X-Connection keep-alive}] http::cleanup $token update - set after [chan names] - expr {$before eq $after} -} -result 1 + # Compute what channels have been unexpectedly leaked past cleanup + list-difference $before [chan names] +} -cleanup { + rename list-difference {} +} -result {} test http-5.1 {http::formatQuery} { http::formatQuery name1 value1 name2 "value two" -- cgit v0.12