--- a/RegressionTests__ProcessTest.st Fri Sep 19 13:36:57 2014 +0200
+++ b/RegressionTests__ProcessTest.st Fri Sep 19 14:58:12 2014 +0200
@@ -14,9 +14,43 @@
tearDown
- subProcesses do:[:aProcess|
- aProcess terminate.
+ subProcesses notEmptyOrNil ifTrue:[
+ subProcesses do:[:aProcess|
+ aProcess terminate.
+ ].
].
+
+ "Modified: / 19-09-2014 / 13:27:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testMaxProcessId
+ "This test makes sure a process id never exeeds MaxProcessId."
+
+ | blocker lastId maxId iters |
+
+ blocker := Semaphore new.
+ lastId := Processor activeProcess id.
+ maxId := Processor maxProcessId.
+ iters := 0.
+ [ lastId ~~ maxId ] whileTrue:[
+ [ lastId := Processor activeProcess id. blocker signal ] fork.
+ blocker wait.
+ iters := iters + 1.
+ iters > maxId ifTrue:[
+ "/ OK, we tried long enough. The system is probably already
+ "/ reusing Process id's so it may never reach maxId.
+ ^ self.
+ ].
+ ].
+ "/ OK, we reached the limit. Try once again to spawn a new
+ "/ thread and assert its id is smaller then the limit.
+ [ lastId := Processor activeProcess id. blocker signal ] fork.
+ blocker wait.
+
+ self assert: lastId < maxId.
+
+ "Created: / 19-09-2014 / 12:50:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 19-09-2014 / 13:54:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testTerminateWithAllSubProcesses
@@ -63,3 +97,4 @@
version
^ '$Header$'
! !
+