@@ -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.2 2000/06/05 20:32:06 aborr Exp $ +# RCS: @(#) $Id: tlsIO.test,v 1.3 2000/06/05 20:39:31 aborr 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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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"] @@ -664,11 +664,11 @@ lappend x [gets $f] close $f set x } {ready done {}} -test tlsIo-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 } @@ -688,11 +688,11 @@ puts $f bye close $f set x } {1 {couldn't open socket: address already in use}} -test tlsIo-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"] @@ -755,11 +755,11 @@ lappend x [gets $f] close $f set x } {ready done} -test tlsIo-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 @@ -823,59 +823,48 @@ close $p2 close $p3 set l } {{p1 bye done} {p2 bye done} {p3 bye done}} -test tlsIo-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 tlsIo-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 tlsIo-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 tlsIo-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} -################################# -if {[string match sock* $commandSocket] == 1} { - puts $commandSocket exit - flush $commandSocket -} -catch {close $commandSocket} -catch {close $remoteProcChan} -::tcltest::cleanupTests -flush stdout -return -################################# -test tlsIo-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 @@ -897,11 +886,11 @@ close $s rename bgerror {} set x } {{divide by zero}} -test tlsIo-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 } @@ -929,11 +918,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 tlsIo-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 } @@ -961,21 +950,21 @@ lappend l [llength $p] lappend l [lindex $p 0] lappend l [string equal [lindex $p 2] 2821] } {3 127.0.0.1 0} -test tlsIo-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 tlsIo-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 @@ -992,11 +981,11 @@ close $s1 set l "" lappend l [lindex $x 2] [llength $x] } {2823 3} -test tlsIo-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 @@ -1013,11 +1002,11 @@ close $s1 set l "" lappend l [lindex $x 0] [lindex $x 2] [llength $x] } {127.0.0.1 2829 3} -test tlsIo-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, @@ -1048,11 +1037,11 @@ close $s close $s1 set z } bye -test tlsIo-9.1 {testing spurious events} {empty socket} { +test tlsIO-9.1 {testing spurious events} {empty socket} { # locks up set len 0 set spurious 0 set done 0 proc readlittle {s} { @@ -1086,11 +1075,11 @@ after cancel $timer close $s list $spurious $len } {0 50} -test tlsIo-9.2 {testing async write, fileevents, flush on close} {socket} { +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" @@ -1139,11 +1128,11 @@ after cancel $timer close $l set count } 65566 -test tlsIo-9.3 {testing EOF stickyness} {empty socket} { +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]} { @@ -1186,11 +1175,11 @@ set count } {eof is sticky} removeFile script -test tlsIo-10.1 {testing socket accept callback error handling} {socket} { +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] @@ -1202,11 +1191,11 @@ close $s close $c set goterror } 1 -test tlsIo-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" @@ -1229,11 +1218,11 @@ close $s sendCommand {close $socket9_1_test_server} set r } done -test tlsIo-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" @@ -1265,11 +1254,11 @@ } else { set result broken } set result } ok -test tlsIo-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}]} { @@ -1278,11 +1267,11 @@ close $s } set status } ok -test tlsIo-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" @@ -1318,11 +1307,11 @@ close $f sendCommand {close $socket10_6_test_server} set r } hello -test tlsIo-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" @@ -1366,11 +1355,11 @@ set conflictResult {0 2836} } else { set conflictResult {1 {couldn't open socket: address already in use}} } -test tlsIo-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 \ @@ -1382,11 +1371,11 @@ } close $s1 set result } $conflictResult -test tlsIo-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] \ @@ -1431,11 +1420,11 @@ close $s3 sendCommand {close $socket10_9_test_server} set i } 100 -test tlsIo-11.8 {client with several servers} {empty socket doTestsWithRemoteServer} { +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] \ @@ -1478,11 +1467,11 @@ close $s3 } set l } {4003 {} 1 4004 {} 1 4005 {} 1} -test tlsIo-11.9 {accept callback error} {socket 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 { @@ -1512,11 +1501,11 @@ close $s rename bgerror {} set x } {{divide by zero}} -test tlsIo-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" @@ -1538,11 +1527,11 @@ close $s sendCommand {close $socket10_12_test_server} set l } {2836 3 3} -test tlsIo-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" @@ -1591,11 +1580,11 @@ after cancel $timer sendCommand {close $socket10_13_test_server} list $spurious $len } {0 2690} -test tlsIo-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] @@ -1637,11 +1626,11 @@ vwait done sendCommand {close $socket10_14_test_server} set done } {EOF is sticky} -test tlsIo-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] @@ -1703,11 +1692,11 @@ after cancel $timer sendCommand {close $l} set count } 65566 -test tlsIo-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 @@ -1765,11 +1754,11 @@ removeFile script1 removeFile script2 set x } {server socket was not inherited} -test tlsIo-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 @@ -1857,11 +1846,11 @@ removeFile script1 removeFile script2 set x } {client socket was not inherited} -test tlsIo-12.3 {testing inheritance of accepted sockets} \ +test tlsIO-12.3 {testing inheritance of accepted sockets} \ {empty socket doTestsWithRemoteServer} { # hangs on Linux removeFile script1 removeFile script2 @@ -1939,11 +1928,11 @@ removeFile script1 removeFile script2 set x } {accepted socket was not inherited} -test tlsIo-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