Issue #94: added more tests for acquiring a free (fat) lock jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 12 Dec 2017 09:01:30 +0000
branchjv
changeset 1964 47797e5b62a6
parent 1963 d1eb7b03018a
child 1965 a787232be371
Issue #94: added more tests for acquiring a free (fat) lock
RegressionTests__RecursionLockTests.st
--- a/RegressionTests__RecursionLockTests.st	Mon Dec 11 14:11:56 2017 +0000
+++ b/RegressionTests__RecursionLockTests.st	Tue Dec 12 09:01:30 2017 +0000
@@ -363,22 +363,70 @@
     ] newProcess.
 
     p2 := [ 
-        | timeouted |
+        | timedout |
 
-        timeouted := false.
+        timedout := false.
         Delay waitForMilliseconds: 100. "/ Give p1 chance to lock the thread.
         self assert: lock owner == p1.
         self assert: lock count == 1.         
         lock critical: [ Delay waitForMilliseconds: 10 ] "/ Some tiny work.
             timeoutMs: 1000
-           ifBlocking: [ timeouted := true ].
-        self assert: timeouted not.
+           ifBlocking: [ timedout := true ].
+        self assert: timedout not.
     ] newProcess.
 
     p1 resume.
     p2 resume.
 
     "Created: / 11-12-2017 / 14:09:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_critical_10a
+
+    | timedout |
+
+    timedout := false.
+    lock inflate.
+    lock critical: [ ]
+        timeoutMs: 100
+       ifBlocking: [ timedout := true ].
+    self assert: timedout not.
+
+    "Created: / 11-12-2017 / 20:34:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_critical_10b
+
+    | p1 p2 |
+
+    p1 := [
+        lock critical:[ 
+            Delay waitForMilliseconds: 250.  
+        ].
+    ] newProcess.
+
+    p2 := [ 
+        | timedout |
+
+        timedout := false.
+        "/ Give p1 chance to lock the thread then try to lock
+        "/ to force a contention.
+        Delay waitForMilliseconds: 100. 
+        self assert: lock owner == p1.
+        self assert: lock count == 1.         
+        lock critical: [ Delay waitForMilliseconds: 10 ]. 
+        "/ Now try to lock again with timeout and make sure
+        "/ we do not timeout
+        lock critical: [ Delay waitForMilliseconds: 10 ]
+            timeoutMs: 100
+           ifBlocking: [ timedout := true ].
+        self assert: timedout not.    
+    ] newProcess.
+
+    p1 resume.
+    p2 resume.
+
+    "Created: / 12-12-2017 / 08:59:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !RecursionLockTests class methodsFor:'documentation'!