RegressionTests__SocketTests.st
changeset 1716 54d81e306117
parent 1715 247143b085d4
child 1721 ea19dde999b3
equal deleted inserted replaced
1715:247143b085d4 1716:54d81e306117
    46 
    46 
    47     Delay waitForSeconds:20.
    47     Delay waitForSeconds:20.
    48     p1 terminate.
    48     p1 terminate.
    49     p2 terminate.
    49     p2 terminate.
    50 
    50 
       
    51     self assert:(n1 > 0).
       
    52     self assert:(n2 > 0).
    51     Transcript showCR:'n1: %1; n2: %2' with:n1 with:n2
    53     Transcript showCR:'n1: %1; n2: %2' with:n1 with:n2
    52 
    54 
    53     "Created: / 29-11-2011 / 14:43:57 / cg"
    55     "Created: / 29-11-2011 / 14:43:57 / cg"
    54     "Modified: / 10-10-2017 / 12:07:30 / cg"
    56     "Modified: / 10-10-2017 / 12:15:10 / cg"
    55 !
    57 !
    56 
    58 
    57 test11_concurrentOpenClose
    59 test11_concurrentOpenClose
    58     "using a non-existing host name (hoping that the connect will take longer then,
    60     "using a non-existing host name (hoping that the connect will take longer then,
    59      and we can enforce concurrent execution)"
    61      and we can enforce concurrent execution)"
    60 
    62 
    61     |p1 p2 sock port n1 n2|
    63     |p1 p2 sock port n1 n2 nerr1 nerr2|
    62 
    64 
    63     port := 80.
    65     port := 80.
    64     n1 := n2 := 0.
    66     n1 := n2 := 0.
    65 
    67     nerr1 := nerr2 := 0.
       
    68     
    66     p1 :=
    69     p1 :=
    67         [
    70         [
    68             |host|
    71             |host|
    69 
    72 
    70             [true] whileTrue:[
    73             [true] whileTrue:[
    71                 host := 'www.nonexisting-%1.de' bindWith:(UUID genRandomUUID).
    74                 host := 'www.nonexisting-%1.de' bindWith:(UUID genRandomUUID).
    72                 HostNameLookupError handle:[:ex |
    75                 HostNameLookupError handle:[:ex |
       
    76                     nerr1 := nerr1 + 1.
    73                 ] do:[
    77                 ] do:[
    74                     sock := Socket newTCPclientToHost:host port:port.
    78                     sock := Socket newTCPclientToHost:host port:port.
       
    79                     self assert:(sock notNil).
    75                     Processor yield.
    80                     Processor yield.
    76                     n1 := n1 + 1.
    81                     n1 := n1 + 1.
    77                     sock close
    82                     sock close
    78                 ].
    83                 ].
    79             ]
    84             ]
    84             |host|
    89             |host|
    85 
    90 
    86             [true] whileTrue:[
    91             [true] whileTrue:[
    87                 host := 'www.nonexisting-%1.de' bindWith:(UUID genRandomUUID).
    92                 host := 'www.nonexisting-%1.de' bindWith:(UUID genRandomUUID).
    88                 HostNameLookupError handle:[:ex |
    93                 HostNameLookupError handle:[:ex |
       
    94                     nerr2 := nerr2 + 1.
    89                 ] do:[
    95                 ] do:[
    90                     sock := Socket newTCPclientToHost:host port:port.
    96                     sock := Socket newTCPclientToHost:host port:port.
       
    97                     self assert:(sock notNil).
    91                     Processor yield.
    98                     Processor yield.
    92                     n2 := n2 + 1.
    99                     n2 := n2 + 1.
    93                     sock close
   100                     sock close
    94                 ]
   101                 ]
    95             ]
   102             ]
   100 
   107 
   101     Delay waitForSeconds:20.
   108     Delay waitForSeconds:20.
   102     p1 terminate.
   109     p1 terminate.
   103     p2 terminate.
   110     p2 terminate.
   104 
   111 
       
   112     self assert:(n1 = 0).
       
   113     self assert:(n2 = 0).
       
   114     self assert:(nerr1 > 0).
       
   115     self assert:(nerr2 > 0).
   105     Transcript showCR:'n1: %1; n2: %2' with:n1 with:n2
   116     Transcript showCR:'n1: %1; n2: %2' with:n1 with:n2
   106 
   117 
   107     "Created: / 29-11-2011 / 18:17:04 / cg"
   118     "Created: / 29-11-2011 / 18:17:04 / cg"
   108     "Modified: / 10-10-2017 / 12:11:21 / cg"
   119     "Modified: / 10-10-2017 / 12:18:08 / cg"
   109 ! !
   120 ! !
   110 
   121 
   111 !SocketTests methodsFor:'tests - socket address'!
   122 !SocketTests methodsFor:'tests - socket address'!
   112 
   123 
   113 test20_localAddress
   124 test20_localAddress