author | joe |
Fri, 15 Mar 2013 19:39:10 -0400 | |
changeset 112 | b6b3d8435bb7 |
parent 71 | b5baf23694f3 |
permissions | -rw-r--r-- |
9 | 1 |
"{ Package: 'stx:goodies/xtreams/terminals/tests' }" |
2 |
||
3 |
"{ NameSpace: Xtreams }" |
|
4 |
||
5 |
FiniteReadingWritingTests subclass:#SocketReadingWritingTest |
|
6 |
instanceVariableNames:'' |
|
7 |
classVariableNames:'' |
|
26
d740fff525d4
added XtreamsPool to fix DefaultBufferSize; set proper category names
mkobetic
parents:
9
diff
changeset
|
8 |
poolDictionaries:'XtreamsPool' |
d740fff525d4
added XtreamsPool to fix DefaultBufferSize; set proper category names
mkobetic
parents:
9
diff
changeset
|
9 |
category:'Xtreams-Terminals-Tests' |
9 | 10 |
! |
11 |
||
12 |
||
13 |
!SocketReadingWritingTest methodsFor:'initialize-release'! |
|
14 |
||
15 |
setUp |
|
16 |
||
39 | 17 |
|listener| |
18 |
||
19 |
listener := Socket newTCP: 0. |
|
20 |
[ [ listener listenFor: 1. |
|
21 |
input := Socket newTCPclientToHost: #[127 0 0 1] port: listener port. |
|
22 |
output := listener accept |
|
23 |
] ifCurtailed: [ |
|
24 |
input notNil ifTrue: [ input close ]. |
|
25 |
output notNil ifTrue: [ output close ] ]. |
|
26 |
] ensure: [ listener close ]. |
|
27 |
input := input reading. |
|
28 |
output := output writing. |
|
9 | 29 |
! ! |
30 |
||
31 |
!SocketReadingWritingTest methodsFor:'utilities'! |
|
32 |
||
33 |
timeout: timeoutDuration server: serverBlock client: clientBlock |
|
58 | 34 |
"For tests that must be able to write and read at the same time, where they may block on each. |
35 |
Sockets, Pipes have an operating system buffer which dictates its bandwidth." |
|
9 | 36 |
|
58 | 37 |
| timeout |
38 |
serverSuccess serverProcess serverLock |
|
39 |
clientSuccess clientProcess clientLock| |
|
9 | 40 |
|
58 | 41 |
timeout := false. |
42 |
serverLock := Semaphore new. |
|
43 |
clientLock := Semaphore new. |
|
44 |
serverSuccess := clientSuccess := false. |
|
45 |
serverProcess := [serverSuccess := serverBlock value. serverLock signal] fork. |
|
46 |
clientProcess := [clientSuccess := clientBlock value. clientLock signal] fork. |
|
9 | 47 |
|
58 | 48 |
serverLock wait. |
49 |
clientLock wait. |
|
50 |
||
51 |
self assert: serverSuccess. |
|
52 |
self assert: clientSuccess. |
|
53 |
self deny: timeout |
|
9 | 54 |
! ! |
55 |
||
56 |
!SocketReadingWritingTest class methodsFor:'documentation'! |
|
57 |
||
112 | 58 |
version_HG |
59 |
||
60 |
^ '$Changeset: <not expanded> $' |
|
61 |
! |
|
62 |
||
9 | 63 |
version_SVN |
64 |
^ '$Id$' |
|
65 |
! ! |
|
112 | 66 |