Diff

Differences From Artifact [ff25032914]:

To Artifact [d49a17444f]:


1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
20












-
+







# Commands tested in this file: socket.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
# 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.9 2000/06/03 03:00:22 awb Exp $
# RCS: @(#) $Id: tlsIo.test,v 1.10 2000/06/03 03:17:58 awb Exp $

# Running socket tests with a remote server:
# ------------------------------------------
# 
# Some tests in socket.test depend on the existence of a remote server to
# which they connect. The remote server must be an instance of tcltest and it
# must run the script found in the file "remote.tcl" in this directory. You
876
877
878
879
880
881
882

883


884
885
886
887
888
889
890
891
892
893
894
895
896



897
898
899
900
901
902
903
904

905

906
907
908
909

910


911
912
913
914
915
916
917
918
919
920
921
922
923



924
925
926
927
928
929
930
931

932
933


934
935
936
937
938

939
940


941
942
943
944
945
946


947
948
949
950
951
952
953
876
877
878
879
880
881
882
883

884
885
886
887
888
889
890
891
892
893
894
895
896
897

898
899
900
901
902
903
904
905
906
907
908
909

910
911
912
913
914
915

916
917
918
919
920
921
922
923
924
925
926
927
928
929

930
931
932
933
934
935
936
937
938
939
940
941
942

943
944
945
946
947
948
949
950
951

952
953
954
955
956
957
958

959
960
961
962
963
964
965
966
967







+
-
+
+












-
+
+
+








+
-
+




+
-
+
+












-
+
+
+








+

-
+
+





+

-
+
+





-
+
+







} {{divide by zero}}

test socket-7.1 {testing socket specific options} {socket stdio pcCrash} {
    removeFile script
    set f [open script w]
    puts $f {
	package require tls
    }
	tls::socket -server accept 2820
    puts $f "tls::socket -server accept -certfile $serverCert -cafile $caCert -keyfile $serverKey 2820"
    puts $f {
	proc accept args {
	    global x
	    set x done
	}
	puts ready
	set timer [after 10000 "set x timed_out"]
	vwait x
	after cancel $timer
    }
    close $f
    set f [open "|[list $::tcltest::tcltest script]" r]
    gets $f
    set s [tls::socket 127.0.0.1 2820]
    set s [tls::socket \
	    -certfile $clientCert -cafile $caCert -keyfile $clientKey \
	    127.0.0.1 2820]
    set p [fconfigure $s -peername]
    close $s
    close $f
    set l ""
    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 pcCrash} {
test socket-7.2 {testing socket specific options} {socket stdio} {
    removeFile script
    set f [open script w]
    puts $f {
	package require tls
    }
	tls::socket -server accept 2821
    puts $f "tls::socket -server accept -certfile $serverCert -cafile $caCert -keyfile $serverKey 2821"
    puts $f {
	proc accept args {
	    global x
	    set x done
	}
	puts ready
	set timer [after 10000 "set x timed_out"]
	vwait x
	after cancel $timer
    }
    close $f
    set f [open "|[list $::tcltest::tcltest script]" r]
    gets $f
    set s [tls::socket 127.0.0.1 2821]
    set s [tls::socket \
	    -certfile $clientCert -cafile $caCert -keyfile $clientKey \
	    127.0.0.1 2821]
    set p [fconfigure $s -sockname]
    close $s
    close $f
    set l ""
    lappend l [llength $p]
    lappend l [lindex $p 0]
    lappend l [expr [lindex $p 2] == 2821]
} {3 127.0.0.1 0}

test socket-7.3 {testing socket specific options} {socket} {
    set s [tls::socket -server accept 2822]
    set s [tls::socket \
    	-server accept 2822]
    set l [fconfigure $s]
    close $s
    update
    llength $l
} 12

test socket-7.4 {testing socket specific options} {socket pcCrash} {
    set s [tls::socket -server accept 2823]
    set s [tls::socket \
    	-server accept 2823]
    proc accept {s a p} {
	global x
	set x [fconfigure $s -sockname]
	close $s
    }
    set s1 [tls::socket [info hostname] 2823]
    set s1 [tls::socket \
    	[info hostname] 2823]
    set timer [after 10000 "set x timed_out"]
    vwait x
    after cancel $timer
    close $s
    close $s1
    set l ""
    lappend l [lindex $x 2] [llength $x]