Index: tests/remote.tcl ================================================================== --- tests/remote.tcl +++ tests/remote.tcl @@ -7,11 +7,11 @@ # Copyright (c) 1995-1996 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: remote.tcl,v 1.2 2000/06/03 02:30:03 awb Exp $ +# RCS: @(#) $Id: remote.tcl,v 1.3 2000/06/03 05:01:32 awb Exp $ # load tls package package require tls # Initialize message delimitor @@ -94,10 +94,11 @@ global VERBOSE if {$VERBOSE} { puts "Server accepts new connection from $a:$p on $s" } + tls::handshake $s fileevent $s readable [list __readAndExecute__ $s] fconfigure $s -buffering line -translation crlf } set serverIsSilent 0 Index: tests/tlsIo.test ================================================================== --- tests/tlsIo.test +++ tests/tlsIo.test @@ -8,11 +8,11 @@ # Copyright (c) 1998-2000 Ajuba Solutions. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: tlsIo.test,v 1.11 2000/06/03 03:35:36 awb Exp $ +# RCS: @(#) $Id: tlsIo.test,v 1.12 2000/06/03 05:01:33 awb Exp $ # Running socket tests with a remote server: # ------------------------------------------ # # Some tests in socket.test depend on the existence of a remote server to @@ -208,59 +208,59 @@ } } } } -test socket-1.1 {arg parsing for socket command} {socket} { +test tlsIo-1.1 {arg parsing for socket command} {socket} { list [catch {tls::socket -server} msg] $msg } {1 {wrong # args: should be "tls::socket -server command ?options? port"}} -test socket-1.2 {arg parsing for socket command} {socket} { +test tlsIo-1.2 {arg parsing for socket command} {socket} { list [catch {tls::socket -server foo} msg] $msg } {1 {wrong # args: should be "tls::socket -server command ?options? port"}} -test socket-1.3 {arg parsing for socket command} {socket} { +test tlsIo-1.3 {arg parsing for socket command} {socket} { list [catch {tls::socket -myaddr} msg] $msg } {1 {wrong # args: should be "tls::socket ?options? host port"}} -test socket-1.4 {arg parsing for socket command} {socket} { +test tlsIo-1.4 {arg parsing for socket command} {socket} { list [catch {tls::socket -myaddr 127.0.0.1} msg] $msg } {1 {wrong # args: should be "tls::socket ?options? host port"}} -test socket-1.5 {arg parsing for socket command} {socket} { +test tlsIo-1.5 {arg parsing for socket command} {socket} { list [catch {tls::socket -myport} msg] $msg } {1 {wrong # args: should be "tls::socket ?options? host port"}} -test socket-1.6 {arg parsing for socket command} {socket} { +test tlsIo-1.6 {arg parsing for socket command} {socket} { list [catch {tls::socket -myport xxxx} msg] $msg } {1 {wrong # args: should be "tls::socket ?options? host port"}} -test socket-1.7 {arg parsing for socket command} {socket} { +test tlsIo-1.7 {arg parsing for socket command} {socket} { list [catch {tls::socket -myport 2522} msg] $msg } {1 {wrong # args: should be "tls::socket ?options? host port"}} -test socket-1.8 {arg parsing for socket command} {socket} { +test tlsIo-1.8 {arg parsing for socket command} {socket} { list [catch {tls::socket -froboz} msg] $msg } {1 {wrong # args: should be "tls::socket ?options? host port"}} -test socket-1.9 {arg parsing for socket command} {socket} { +test tlsIo-1.9 {arg parsing for socket command} {socket} { list [catch {tls::socket -server foo -myport 2521 3333} msg] $msg } {1 {wrong # args: should be "tls::socket -server command ?options? port"}} -test socket-1.10 {arg parsing for socket command} {socket} { +test tlsIo-1.10 {arg parsing for socket command} {socket} { list [catch {tls::socket host 2528 -junk} msg] $msg } {1 {wrong # args: should be "tls::socket ?options? host port"}} -test socket-1.11 {arg parsing for socket command} {socket} { +test tlsIo-1.11 {arg parsing for socket command} {socket} { list [catch {tls::socket -server callback 2520 --} msg] $msg } {1 {wrong # args: should be "tls::socket -server command ?options? port"}} -test socket-1.12 {arg parsing for socket command} {socket} { +test tlsIo-1.12 {arg parsing for socket command} {socket} { list [catch {tls::socket foo badport} msg] $msg } {1 {expected integer but got "badport"}} -test socket-2.1 {tcp connection} {socket stdio} { +test tlsIo-2.1 {tcp connection} {socket stdio} { removeFile script set f [open script w] puts $f { package require tls set timer [after 2000 "set x timed_out"] @@ -297,11 +297,11 @@ incr port } else { set port [expr 2048 + [pid]%1024] } -test socket-2.2 {tcp connection with client port specified} {socket stdio} { +test tlsIo-2.2 {tcp connection with client port specified} {socket stdio} { removeFile script set f [open script w] puts $f { package require tls set timer [after 2000 "set x done"] @@ -336,11 +336,11 @@ } close $f set x } [list ready "hello $port"] -test socket-2.3 {tcp connection with client interface specified} {socket stdio} { +test tlsIo-2.3 {tcp connection with client interface specified} {socket stdio} { removeFile script set f [open script w] puts $f { package require tls set timer [after 2000 "set x done"] @@ -373,11 +373,11 @@ } close $f set x } {ready {hello 127.0.0.1}} -test socket-2.4 {tcp connection with server interface specified} {socket stdio} { +test tlsIo-2.4 {tcp connection with server interface specified} {socket stdio} { removeFile script set f [open script w] puts $f { package require tls set timer [after 2000 "set x done"] @@ -409,11 +409,11 @@ } close $f set x } {ready hello} -test socket-2.5 {tcp connection with redundant server port} {socket stdio} { +test tlsIo-2.5 {tcp connection with redundant server port} {socket stdio} { removeFile script set f [open script w] puts $f { package require tls set timer [after 2000 "set x done"] @@ -444,11 +444,11 @@ close $sock } close $f set x } {ready hello} -test socket-2.6 {tcp connection} {socket} { +test tlsIo-2.6 {tcp connection} {socket} { set status ok if {![catch {set sock [tls::socket 127.0.0.1 2833]}]} { if {![catch {gets $sock}]} { set status broken } @@ -455,11 +455,11 @@ close $sock } set status } ok -test socket-2.7 {echo server, one line} {socket stdio} { +test tlsIo-2.7 {echo server, one line} {socket stdio} { removeFile script set f [open script w] puts $f { package require tls set timer [after 2000 "set x done"] @@ -499,11 +499,11 @@ set y [gets $f] close $f list $x $y } {{hello abcdefghijklmnop} done} -test socket-2.8 {echo server, loop 50 times, single connection} {socket stdio} { +test tlsIo-2.8 {echo server, loop 50 times, single connection} {socket stdio} { set f [open script w] puts $f { package require tls } puts $f "set f \[tls::socket -server accept -certfile $serverCert -cafile $caCert -keyfile $serverKey 2835 \]" @@ -548,11 +548,11 @@ catch {set x [gets $f]} close $f set x } {done 50} -test socket-2.9 {socket conflict} {socket stdio} { +test tlsIo-2.9 {socket conflict} {socket stdio} { set s [tls::socket -server accept 2828] removeFile script set f [open script w] puts -nonewline $f {package require tls; tls::socket -server accept 2828} close $f @@ -571,11 +571,11 @@ (procedure "tls::socket" line 62) invoked from within "tls::socket -server accept 2828" (file "script" line 1)}} -test socket-2.10 {close on accept, accepted socket lives} {socket knownBug} { +test tlsIo-2.10 {close on accept, accepted socket lives} {socket knownBug} { set done 0 set timer [after 20000 "set done timed_out"] set ss [tls::socket -server accept -certfile $serverCert -cafile $caCert \ -keyfile $serverKey 2830] proc accept {s a p} { @@ -597,11 +597,11 @@ vwait done after cancel $timer set done } 1 -test socket-2.11 {detecting new data} {socket knownBug} { +test tlsIo-2.11 {detecting new data} {socket knownBug} { proc accept {s a p} { global sock set sock $s set f [open awb.log w] puts $f [catch {tls::handshake $sock} err] @@ -632,11 +632,11 @@ close $s close $sock set result } {one {} two} -test socket-2.12 {tcp connection; no certificates specified} {socket stdio pcCrash} { +test tlsIo-2.12 {tcp connection; no certificates specified} {socket stdio pcCrash} { removeFile script set f [open script w] puts $f { package require tls set timer [after 2000 "set x timed_out"] @@ -667,11 +667,11 @@ } {ready done {}} -test socket-3.1 {socket conflict} {socket stdio} { +test tlsIo-3.1 {socket conflict} {socket stdio} { removeFile script set f [open script w] puts $f { package require tls } @@ -691,11 +691,11 @@ puts $f bye close $f set x } {1 {couldn't open socket: address already in use}} -test socket-3.2 {server with several clients} {socket stdio} { +test tlsIo-3.2 {server with several clients} {socket stdio} { removeFile script set f [open script w] puts $f { package require tls set t1 [after 30000 "set x timed_out"] @@ -758,11 +758,11 @@ lappend x [gets $f] close $f set x } {ready done} -test socket-4.1 {server with several clients} {socket stdio} { +test tlsIo-4.1 {server with several clients} {socket stdio} { removeFile script set f [open script w] puts $f { package require tls gets stdin @@ -826,48 +826,48 @@ close $p2 close $p3 set l } {{p1 bye done} {p2 bye done} {p3 bye done}} -test socket-4.2 {byte order problems, socket numbers, htons} {socket} { +test tlsIo-4.2 {byte order problems, socket numbers, htons} {socket} { set x ok if {[catch {tls::socket -server dodo 0x3000} msg]} { set x $msg } else { close $msg } set x } ok -test socket-5.1 {byte order problems, socket numbers, htons} \ +test tlsIo-5.1 {byte order problems, socket numbers, htons} \ {socket unixOnly notRoot} { set x {couldn't open socket: not owner} if {![catch {tls::socket -server dodo 0x1} msg]} { set x {htons problem, should be disallowed, are you running as SU?} close $msg } set x } {couldn't open socket: not owner} -test socket-5.2 {byte order problems, socket numbers, htons} {socket} { +test tlsIo-5.2 {byte order problems, socket numbers, htons} {socket} { set x {couldn't open socket: port number too high} if {![catch {tls::socket -server dodo 0x10000} msg]} { set x {port resolution problem, should be disallowed} close $msg } set x } {couldn't open socket: port number too high} -test socket-5.3 {byte order problems, socket numbers, htons} \ +test tlsIo-5.3 {byte order problems, socket numbers, htons} \ {socket unixOnly notRoot} { set x {couldn't open socket: not owner} if {![catch {tls::socket -server dodo 21} msg]} { set x {htons problem, should be disallowed, are you running as SU?} close $msg } set x } {couldn't open socket: not owner} -test socket-6.1 {accept callback error} {socket stdio pcCrash} { +test tlsIo-6.1 {accept callback error} {socket stdio pcCrash} { removeFile script set f [open script w] puts $f { package require tls gets stdin @@ -889,11 +889,11 @@ close $s rename bgerror {} set x } {{divide by zero}} -test socket-7.1 {testing socket specific options} {socket stdio} { +test tlsIo-7.1 {testing socket specific options} {socket stdio} { removeFile script set f [open script w] puts $f { package require tls } @@ -921,11 +921,11 @@ lappend l [string compare [lindex $p 0] 127.0.0.1] lappend l [string compare [lindex $p 2] 2820] lappend l [llength $p] } {0 0 3} -test socket-7.2 {testing socket specific options} {socket stdio} { +test tlsIo-7.2 {testing socket specific options} {socket stdio} { removeFile script set f [open script w] puts $f { package require tls } @@ -950,24 +950,24 @@ close $s close $f set l "" lappend l [llength $p] lappend l [lindex $p 0] - lappend l [expr [lindex $p 2] == 2821] + lappend l [string equal [lindex $p 2] 2821] } {3 127.0.0.1 0} -test socket-7.3 {testing socket specific options} {socket} { +test tlsIo-7.3 {testing socket specific options} {socket} { set s [tls::socket \ -certfile $serverCert -cafile $caCert -keyfile $serverKey \ -server accept 2822] set l [fconfigure $s] close $s update llength $l } 12 -test socket-7.4 {testing socket specific options} {socket} { +test tlsIo-7.4 {testing socket specific options} {socket} { set s [tls::socket \ -certfile $serverCert -cafile $caCert -keyfile $serverKey \ -server accept 2823] proc accept {s a p} { global x @@ -984,11 +984,11 @@ close $s1 set l "" lappend l [lindex $x 2] [llength $x] } {2823 3} -test socket-7.5 {testing socket specific options} {socket unixOrPc} { +test tlsIo-7.5 {testing socket specific options} {socket unixOrPc} { set s [tls::socket \ -certfile $serverCert -cafile $caCert -keyfile $serverKey \ -server accept 2829] proc accept {s a p} { global x @@ -1005,11 +1005,12 @@ close $s1 set l "" lappend l [lindex $x 0] [lindex $x 2] [llength $x] } {127.0.0.1 2829 3} -test socket-8.1 {testing -async flag on sockets} {empty socket} { +test tlsIo-8.1 {testing -async flag on sockets} {empty socket} { + # test seems to hang -- awb 6/2/2000 # NOTE: This test may fail on some Solaris 2.4 systems. If it does, # check that you have these patches installed (using showrev -p): # # 101907-05, 101925-02, 101945-14, 101959-03, 101969-05, 101973-03, # 101977-03, 101981-02, 101985-01, 102001-03, 102003-01, 102007-01, @@ -1039,11 +1040,12 @@ close $s close $s1 set z } bye -test socket-9.1 {testing spurious events} {empty socket pcCrash} { +test tlsIo-9.1 {testing spurious events} {empty socket} { + # locks up set len 0 set spurious 0 set done 0 proc readlittle {s} { global spurious done len @@ -1061,29 +1063,35 @@ } proc accept {s a p} { fconfigure $s -buffering none -blocking off fileevent $s readable [list readlittle $s] } - set s [tls::socket -server accept 2831] - set c [tls::socket [info hostname] 2831] + set s [tls::socket \ + -certfile $serverCert -cafile $caCert -keyfile $serverKey \ + -server accept 2831] + set c [tls::socket \ + -certfile $clientCert -cafile $caCert -keyfile $clientKey \ + [info hostname] 2831] puts -nonewline $c 01234567890123456789012345678901234567890123456789 close $c set timer [after 10000 "set done timed_out"] vwait done after cancel $timer close $s list $spurious $len } {0 50} -test socket-9.2 {testing async write, fileevents, flush on close} {empty socket pcCrash} { +test tlsIo-9.2 {testing async write, fileevents, flush on close} {socket} { set firstblock "" for {set i 0} {$i < 5} {incr i} {set firstblock "a$firstblock$firstblock"} set secondblock "" for {set i 0} {$i < 16} {incr i} { set secondblock "b$secondblock$secondblock" } - set l [tls::socket -server accept 2832] + set l [tls::socket \ + -certfile $serverCert -cafile $caCert -keyfile $serverKey \ + -server accept 2832] proc accept {s a p} { fconfigure $s -blocking 0 -translation lf -buffersize 16384 \ -buffering line fileevent $s readable "readable $s" } @@ -1100,11 +1108,13 @@ proc writedata {s} { global secondblock puts -nonewline $s $secondblock close $s } - set s [tls::socket [info hostname] 2832] + set s [tls::socket \ + -certfile $clientCert -cafile $caCert -keyfile $clientKey \ + [info hostname] 2832] fconfigure $s -blocking 0 -trans lf -buffering line set count 0 puts $s hello proc readit {s} { global count done @@ -1121,11 +1131,12 @@ after cancel $timer close $l set count } 65566 -test socket-9.3 {testing EOF stickyness} {empty socket pcCrash} { +test tlsIo-9.3 {testing EOF stickyness} {empty socket} { + # hangs proc count_to_eof {s} { global count done timer set l [gets $s] if {[eof $s]} { incr count @@ -1151,12 +1162,16 @@ } proc accept {s a p} { fconfigure $s -buffering line -translation lf fileevent $s writable "write_then_close $s" } - set s [tls::socket -server accept 2833] - set c [tls::socket [info hostname] 2833] + set s [tls::socket \ + -certfile $serverCert -cafile $caCert -keyfile $serverKey \ + -server accept 2833] + set c [tls::socket \ + -certfile $clientCert -cafile $caCert -keyfile $clientKey \ + [info hostname] 2833] fconfigure $c -blocking off -buffering line -translation lf fileevent $c readable "count_to_eof $c" set timer [after 1000 timerproc] vwait done close $s @@ -1163,27 +1178,27 @@ set count } {eof is sticky} removeFile script -test socket-10.1 {testing socket accept callback error handling} {socket pcCrash} { +test tlsIo-10.1 {testing socket accept callback error handling} {socket} { set goterror 0 proc bgerror args {global goterror; set goterror 1} set s [tls::socket \ -certfile $serverCert -cafile $caCert -keyfile $serverKey \ -server accept 2898] proc accept {s a p} {close $s; error} - set c [tls::socket \ + set c [tls::socket \ -certfile $clientCert -cafile $caCert -keyfile $clientKey \ 127.0.0.1 2898] vwait goterror close $s close $c set goterror } 1 -test socket-11.1 {tcp connection} {socket doTestsWithRemoteServer} { +test tlsIo-11.1 {tcp connection} {socket doTestsWithRemoteServer} { sendCommand "set caCert $caCert" sendCommand "set serverCert $serverCert" sendCommand "set clientCert $clientCert" sendCommand "set serverKey $serverKey" sendCommand "set clientKey $clientKey" @@ -1206,11 +1221,11 @@ close $s sendCommand {close $socket9_1_test_server} set r } done -test socket-11.2 {client specifies its port} {socket doTestsWithRemoteServer} { +test tlsIo-11.2 {client specifies its port} {socket doTestsWithRemoteServer} { sendCommand "set caCert $caCert" sendCommand "set serverCert $serverCert" sendCommand "set clientCert $clientCert" sendCommand "set serverKey $serverKey" sendCommand "set clientKey $clientKey" @@ -1224,10 +1239,11 @@ -certfile $serverCert \ -cafile $caCert \ -keyfile $serverKey \ 2835] proc accept {s a p} { + tls::handshake $s puts $s $p close $s } } set s [tls::socket \ @@ -1241,11 +1257,11 @@ } else { set result broken } set result } ok -test socket-11.3 {trying to connect, no server} {socket doTestsWithRemoteServer} { +test tlsIo-11.3 {trying to connect, no server} {socket doTestsWithRemoteServer} { set status ok if {![catch {set s [tls::socket \ -certfile $clientCert -cafile $caCert -keyfile $clientKey \ $remoteServerIp 2836]}]} { if {![catch {gets $s}]} { @@ -1254,11 +1270,11 @@ close $s } set status } ok -test socket-11.4 {remote echo, one line} {socket doTestsWithRemoteServer} { +test tlsIo-11.4 {remote echo, one line} {socket doTestsWithRemoteServer} { sendCommand "set caCert $caCert" sendCommand "set serverCert $serverCert" sendCommand "set clientCert $clientCert" sendCommand "set serverKey $serverKey" sendCommand "set clientKey $clientKey" @@ -1270,10 +1286,11 @@ -certfile $serverCert \ -cafile $caCert \ -keyfile $serverKey \ -server accept 2836] proc accept {s a p} { + tls::handshake $s fileevent $s readable [list echo $s] fconfigure $s -buffering line -translation crlf } proc echo {s} { set l [gets $s] @@ -1293,11 +1310,11 @@ close $f sendCommand {close $socket10_6_test_server} set r } hello -test socket-11.5 {remote echo, 50 lines} {socket doTestsWithRemoteServer} { +test tlsIo-11.5 {remote echo, 50 lines} {socket doTestsWithRemoteServer} { sendCommand "set caCert $caCert" sendCommand "set serverCert $serverCert" sendCommand "set clientCert $clientCert" sendCommand "set serverKey $serverKey" sendCommand "set clientKey $clientKey" @@ -1306,10 +1323,11 @@ -certfile $serverCert \ -cafile $caCert \ -keyfile $serverKey \ 2836] proc accept {s a p} { + tls::handshake $s fileevent $s readable [list echo $s] fconfigure $s -buffering line -translation crlf } proc echo {s} { set l [gets $s] @@ -1340,11 +1358,11 @@ set conflictResult {0 2836} } else { set conflictResult {1 {couldn't open socket: address already in use}} } -test socket-11.6 {socket conflict} {socket doTestsWithRemoteServer} { +test tlsIo-11.6 {socket conflict} {socket doTestsWithRemoteServer} { set s1 [tls::socket \ -certfile $serverCert -cafile $caCert -keyfile $serverKey \ -server accept 2836] if {[catch {set s2 [tls::socket \ -certfile $serverCert -cafile $caCert -keyfile $serverKey \ @@ -1356,18 +1374,20 @@ } close $s1 set result } $conflictResult -test socket-11.7 {server with several clients} {socket doTestsWithRemoteServer} { +test tlsIo-11.7 {server with several clients} {socket doTestsWithRemoteServer} { sendCommand { set socket10_9_test_server [tls::socket \ -certfile [file join [pwd] certs server.pem] \ -cafile [file join [pwd] certs caFile.pem] \ -keyfile [file join [pwd] certs skey.pem] \ -server accept 2836] proc accept {s a p} { + # handshake locks up the three synchronous clients + # tls::handshake $s fconfigure $s -buffering line fileevent $s readable [list echo $s] } proc echo {s} { set l [gets $s] @@ -1403,12 +1423,12 @@ close $s3 sendCommand {close $socket10_9_test_server} set i } 100 -test socket-11.8 {client with several servers} {knownBug socket doTestsWithRemoteServer} { - # this one seems to hang -- awb 6/2/2000 +test tlsIo-11.8 {client with several servers} {empty socket doTestsWithRemoteServer} { + # this one seems to hang -- awb 6/2/2000 sendCommand { set s1 [tls::socket \ -certfile [file join [pwd] certs server.pem] \ -cafile [file join [pwd] certs caFile.pem] \ -keyfile [file join [pwd] certs skey.pem] \ @@ -1422,10 +1442,11 @@ -certfile [file join [pwd] certs server.pem] \ -cafile [file join [pwd] certs caFile.pem] \ -keyfile [file join [pwd] certs skey.pem] \ -server "accept 4005" 4005] proc accept {mp s a p} { + tls::handshake $s puts $s $mp close $s } } set s1 [tls::socket \ @@ -1449,11 +1470,11 @@ close $s3 } set l } {4003 {} 1 4004 {} 1 4005 {} 1} -test socket-11.9 {accept callback error} {socket pcCrash doTestsWithRemoteServer} { +test tlsIo-11.9 {accept callback error} {socket doTestsWithRemoteServer} { set s [tls::socket \ -certfile $serverCert -cafile $caCert -keyfile $serverKey \ -server accept 2836] proc accept {s a p} {expr 10 / 0} proc bgerror args { @@ -1483,11 +1504,11 @@ close $s rename bgerror {} set x } {{divide by zero}} -test socket-11.10 {testing socket specific options} {socket doTestsWithRemoteServer} { +test tlsIo-11.10 {testing socket specific options} {socket doTestsWithRemoteServer} { sendCommand "set caCert $caCert" sendCommand "set serverCert $serverCert" sendCommand "set clientCert $clientCert" sendCommand "set serverKey $serverKey" sendCommand "set clientKey $clientKey" @@ -1509,11 +1530,12 @@ close $s sendCommand {close $socket10_12_test_server} set l } {2836 3 3} -test socket-11.11 {testing spurious events} {empty socket doTestsWithRemoteServer} { +test tlsIo-11.11 {testing spurious events} {empty socket doTestsWithRemoteServer} { + # hangs sendCommand "set caCert $caCert" sendCommand "set serverCert $serverCert" sendCommand "set clientCert $clientCert" sendCommand "set serverKey $serverKey" sendCommand "set clientKey $clientKey" @@ -1522,10 +1544,11 @@ -certfile $serverCert \ -cafile $caCert \ -keyfile $serverKey \ -server accept 2836] proc accept {s a p} { + tls::handshake $s fconfigure $s -translation "auto lf" after 100 writesome $s } proc writesome {s} { for {set i 0} {$i < 100} {incr i} { @@ -1560,11 +1583,11 @@ after cancel $timer sendCommand {close $socket10_13_test_server} list $spurious $len } {0 2690} -test socket-11.12 {testing EOF stickyness} {socket doTestsWithRemoteServer} { +test tlsIo-11.12 {testing EOF stickyness} {socket doTestsWithRemoteServer} { set counter 0 set done 0 proc count_up {s} { global counter done after_id set l [gets $s] @@ -1592,10 +1615,11 @@ -certfile $serverCert \ -cafile $caCert \ -keyfile $serverKey \ -server accept 2836] proc accept {s a p} { + tls::handshake $s after 100 close $s } } set c [tls::socket \ -certfile $clientCert -cafile $caCert -keyfile $clientKey \ @@ -1605,11 +1629,11 @@ vwait done sendCommand {close $socket10_14_test_server} set done } {EOF is sticky} -test socket-11.13 {testing async write, async flush, async close} \ +test tlsIo-11.13 {testing async write, async flush, async close} \ {socket doTestsWithRemoteServer} { proc readit {s} { global count done set l [read $s] incr count [string length $l] @@ -1636,10 +1660,11 @@ -certfile $serverCert \ -cafile $caCert \ -keyfile $serverKey \ -server accept 2845] proc accept {s a p} { + tls::handshake $s fconfigure $s -blocking 0 -translation lf -buffersize 16384 \ -buffering line fileevent $s readable "readable $s" } proc readable {s} { @@ -1670,11 +1695,11 @@ after cancel $timer sendCommand {close $l} set count } 65566 -test socket-12.1 {testing inheritance of server sockets} \ +test tlsIo-12.1 {testing inheritance of server sockets} \ {socket doTestsWithRemoteServer} { removeFile script1 removeFile script2 # Script1 is just a 10 second delay. If the server socket @@ -1690,30 +1715,33 @@ # Script2 creates the server socket, launches script1, # waits a second, and exits. The server socket will now # be closed unless script1 inherited it. set f [open script2 w] - puts $f [list set tcltest $::tcltest::tcltest] + # puts $f [list set tcltest $::tcltest::tcltest] + puts $f [list set tclsh [info nameofexecutable]] puts $f { package require tcltest package require tls } puts $f "set f \[tls::socket -server accept -certfile $serverCert -cafile $caCert -keyfile $serverKey 2828 \]" puts $f { proc accept { file addr port } { close $file } - exec $::tcltest::tcltest script1 & + # exec $::tcltest::tcltest script1 & + exec $tclsh script1 & close $f after 1000 exit vwait forever } close $f # Launch script2 and wait 5 seconds - exec $::tcltest::tcltest script2 & + # exec $::tcltest::tcltest script2 & + exec [info nameofexecutable] script2 & after 5000 { set ok_to_proceed 1 } vwait ok_to_proceed # If we can still connect to the server, the socket got inherited. @@ -1729,11 +1757,11 @@ removeFile script1 removeFile script2 set x } {server socket was not inherited} -test socket-12.2 {testing inheritance of client sockets} \ +test tlsIo-12.2 {testing inheritance of client sockets} \ {socket doTestsWithRemoteServer} { removeFile script1 removeFile script2 # Script1 is just a 10 second delay. If the server socket @@ -1749,17 +1777,17 @@ # Script2 opens the client socket and writes to it. It then # launches script1 and exits. If the child process inherited the # client socket, the socket will still be open. set f [open script2 w] - puts $f [list set tcltest $::tcltest::tcltest] + puts $f [list set tclsh [info nameofexecutable]] puts $f { package require tls } puts $f "set f \[tls::socket -certfile $clientCert -cafile $caCert -keyfile $clientKey 127.0.0.1 2829 \]" puts $f { - exec $::tcltest::tcltest script1 & + exec $tclsh script1 & puts $f testing flush $f after 1000 exit vwait forever } @@ -1810,11 +1838,11 @@ set failed 0 after 5000 [list set failed 1] # Launch the script2 process - exec $::tcltest::tcltest script2 & + exec [info nameofexecutable] script2 & vwait x if {!$failed} { vwait failed } @@ -1821,12 +1849,13 @@ removeFile script1 removeFile script2 set x } {client socket was not inherited} -test socket-12.3 {testing inheritance of accepted sockets} \ - {socket doTestsWithRemoteServer} { +test tlsIo-12.3 {testing inheritance of accepted sockets} \ + {empty socket doTestsWithRemoteServer} { + # hangs on Linux removeFile script1 removeFile script2 set f [open script1 w] puts $f { @@ -1834,30 +1863,30 @@ vwait forever } close $f set f [open script2 w] - puts $f [list set tcltest $::tcltest::tcltest] + puts $f [list set tclsh [info nameofexecutable]] puts $f { package require tls } - puts $f "set f \[tls::socket -server accept -certfile $serverCert -cafile $caCert -keyfile $serverKey 2930 \]" + puts $f "catch {set f \[tls::socket -server accept -certfile $serverCert -cafile $caCert -keyfile $serverKey 2930 \]}" puts $f { proc accept { file host port } { - global tcltest + global tclsh puts $file {test data on socket} - exec $::tcltest::tcltest script1 & + exec $tclsh script1 & after 1000 exit } - vwait forever + catch {vwait forever} } close $f # Launch the script2 process and connect to it. See how long # the socket stays open - exec $::tcltest::tcltest script2 & + exec [info nameofexecutable] script2 & after 1000 set ok_to_proceed 1 vwait ok_to_proceed set f [tls::socket \ @@ -1902,11 +1931,11 @@ removeFile script1 removeFile script2 set x } {accepted socket was not inherited} -test socket-13.1 {Testing use of shared socket between two threads} \ +test tlsIo-13.1 {Testing use of shared socket between two threads} \ {socket testthread} { removeFile script threadReap