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:#PipeReadingWritingTest |
|
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 |
!PipeReadingWritingTest methodsFor:'initialize-release'! |
|
14 |
||
15 |
setUp |
|
43 | 16 |
| pipe | |
17 |
pipe := PipeStream makePipe. |
|
18 |
input := pipe first reading. |
|
19 |
output := pipe last writing. |
|
9 | 20 |
! |
21 |
||
22 |
tearDown |
|
23 |
input close. |
|
24 |
output close. |
|
25 |
! ! |
|
26 |
||
27 |
!PipeReadingWritingTest methodsFor:'utilities'! |
|
28 |
||
29 |
timeout: timeoutDuration server: serverBlock client: clientBlock |
|
43 | 30 |
"For tests that must be able to write and read at the same time, where they may block on each. |
31 |
Sockets, Pipes have an operating system buffer which dictates its bandwidth." |
|
9 | 32 |
|
43 | 33 |
| timeout |
34 |
serverSuccess serverProcess serverLock |
|
35 |
clientSuccess clientProcess clientLock| |
|
9 | 36 |
|
43 | 37 |
timeout := false. |
38 |
serverLock := Semaphore new. |
|
39 |
clientLock := Semaphore new. |
|
40 |
serverSuccess := clientSuccess := false. |
|
41 |
serverProcess := [serverSuccess := serverBlock value. serverLock signal] fork. |
|
42 |
clientProcess := [clientSuccess := clientBlock value. clientLock signal] fork. |
|
9 | 43 |
|
43 | 44 |
serverLock wait. |
45 |
clientLock wait. |
|
46 |
||
47 |
self assert: serverSuccess. |
|
48 |
self assert: clientSuccess. |
|
49 |
self deny: timeout |
|
9 | 50 |
! ! |
51 |
||
52 |
!PipeReadingWritingTest class methodsFor:'documentation'! |
|
53 |
||
112 | 54 |
version_HG |
55 |
||
56 |
^ '$Changeset: <not expanded> $' |
|
57 |
! |
|
58 |
||
9 | 59 |
version_SVN |
60 |
^ '$Id$' |
|
61 |
! ! |
|
112 | 62 |