#BUGFIX by stefan
class: RegressionTests::PipeStreamTest
changed: #testPipeWriteRead
did not work - have to close filedescriptors
--- a/RegressionTests__PipeStreamTest.st Fri Feb 17 14:18:22 2017 +0100
+++ b/RegressionTests__PipeStreamTest.st Wed Feb 22 16:17:49 2017 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"{ Package: 'stx:goodies/regression' }"
"{ NameSpace: RegressionTests }"
@@ -15,47 +13,51 @@
!PipeStreamTest methodsFor:'tests'!
testPipeWriteRead
- | makeReader makeWriter count threads ok blocker |
+ | makeReader makeWriter count threads ok blocker|
count := 1000.
threads := 200.
"/ There's limit to 50 open files in BCC5.5 libc, sigh.
OperatingSystem isMSWINDOWSlike ifTrue:[
- threads := 20.
+ threads := 20.
].
ok := true.
blocker := Semaphore new: 2 - threads.
- makeReader := [ :stream |
- [
- | c |
- c := 0.
- [ stream atEnd ] whileFalse:[
- stream next.
- c := c + 1.
- ].
- ok := ok and:[ count == c ].
- blocker signal.
- ].
- ].
+ makeReader := [:stream |
+ [
+ | c |
+ c := 0.
+ [ stream atEnd ] whileFalse:[
+ stream next.
+ c := c + 1.
+ ].
+ stream close.
+ ok := ok and:[ count == c ].
+ blocker signal.
+ ]
+ ].
- makeWriter := [ :stream |
- [
- [ count timesRepeat:[stream nextPut: $P] ] on: Error do:[
- ok := false
- ]
- ]
- ].
+ makeWriter := [:stream |
+ [
+ [
+ count timesRepeat:[stream nextPut: $P]
+ ] on: Error do:[
+ ok := false
+ ].
+ stream close.
+ ]
+ ].
threads timesRepeat:[
- | pipe rs ws|
+ |pipe rs ws|
- pipe := NonPositionableExternalStream makePipe.
- rs := pipe at:1.
- ws := pipe at:2.
+ pipe := NonPositionableExternalStream makePipe.
+ rs := pipe at:1.
+ ws := pipe at:2.
- (makeReader value: rs) fork.
- (makeWriter value: ws) fork.
+ (makeReader value: rs) fork.
+ (makeWriter value: ws) fork.
].
blocker wait.