RegressionTests__PipeStreamTest.st
branchjv
changeset 1476 cd772f7900fe
parent 1289 e1b9697a5b5e
child 1478 84b9cfc40f37
equal deleted inserted replaced
1475:ea3d40ebae8f 1476:cd772f7900fe
     1 "{ Encoding: utf8 }"
       
     2 
       
     3 "{ Package: 'exept:regression' }"
     1 "{ Package: 'exept:regression' }"
     4 
     2 
     5 "{ NameSpace: RegressionTests }"
     3 "{ NameSpace: RegressionTests }"
     6 
     4 
     7 TestCase subclass:#PipeStreamTest
     5 TestCase subclass:#PipeStreamTest
    18     | makeReader makeWriter count threads ok blocker |
    16     | makeReader makeWriter count threads ok blocker |
    19 
    17 
    20     count := 1000.
    18     count := 1000.
    21     threads := 200.
    19     threads := 200.
    22     "/ There's limit to 50 open files in BCC5.5 libc, sigh.
    20     "/ There's limit to 50 open files in BCC5.5 libc, sigh.
    23     OperatingSystem isMSWINDOWSlike ifTrue:[
    21     (OperatingSystem getCCDefine = '__BORLANDC__') ifTrue:[
    24         threads := 20.
    22         threads := 20.
    25     ].
    23     ].
    26     ok := true.
    24     ok := true.
    27     blocker := Semaphore new: 2 - threads.
    25     blocker := Semaphore new: 2 - threads.
    28 
    26 
    39         ].
    37         ].
    40     ].
    38     ].
    41 
    39 
    42     makeWriter := [ :stream | 
    40     makeWriter := [ :stream | 
    43         [ 
    41         [ 
    44             [ count timesRepeat:[stream nextPut: $P] ] on: Error do:[ 
    42             [ count timesRepeat:[stream nextPut: $P] ] on: Error do:[ :ex |
       
    43                 Transcript showCR: 'ERROR in writer: ',  ex description.
       
    44                 ex suspendedContext fullPrintOn: Transcript.
    45                 ok := false 
    45                 ok := false 
       
    46             ] ensure:[ 
       
    47                 stream close.
    46             ]
    48             ]
    47         ]
    49         ]                                                   
    48     ].
    50     ].
    49 
    51 
    50     threads timesRepeat:[
    52     2 to: threads do:[:i |
    51        | pipe rs ws|
    53        | pipe rs rp ws wp |
    52 
    54 
    53         pipe := NonPositionableExternalStream makePipe.
    55         pipe := NonPositionableExternalStream makePipe.
    54         rs := pipe at:1.
    56         rs := pipe at:1.
    55         ws := pipe at:2.     
    57         ws := pipe at:2.     
    56 
    58 
    57         (makeReader value: rs) fork.
    59         rp := (makeReader value: rs) newProcess.
    58         (makeWriter value: ws) fork.
    60         rp name: i printString , ' R ' , testSelector.
       
    61         wp := (makeWriter value: ws) newProcess.
       
    62         wp name: i printString , ' W ' , testSelector.
       
    63         rp resume.
       
    64         wp resume.
    59     ].
    65     ].
    60 
    66 
    61     blocker wait.
    67     blocker wait.
    62     self assert: ok.
    68     self assert: ok.
    63 
    69 
    64     "Created: / 27-03-2014 / 16:21:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    70     "Created: / 27-03-2014 / 16:21:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    71     "Modified: / 28-12-2015 / 13:17:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    65 !
    72 !
    66 
    73 
    67 testReadCheckPipe4
    74 testReadCheckPipe4
    68     "readCheck a pipe.
    75     "readCheck a pipe.
    69      Do this and interrupt the reading thread heavily"
    76      Do this and interrupt the reading thread heavily"
   209 
   216 
   210 !PipeStreamTest class methodsFor:'documentation'!
   217 !PipeStreamTest class methodsFor:'documentation'!
   211 
   218 
   212 version
   219 version
   213     ^ '$Header$'
   220     ^ '$Header$'
       
   221 !
       
   222 
       
   223 version_HG
       
   224 
       
   225     ^ '$Changeset: <not expanded> $'
   214 ! !
   226 ! !
   215 
   227