# HG changeset patch # User Jan Vrany # Date 1513069290 0 # Node ID 47797e5b62a6be72dbe1a9f6222585e8c106b8c8 # Parent d1eb7b03018a2b2b2af3f9fb0f0bb1a2d0c8f9a1 Issue #94: added more tests for acquiring a free (fat) lock diff -r d1eb7b03018a -r 47797e5b62a6 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 " +! + +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 " +! + +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 " ! ! !RecursionLockTests class methodsFor:'documentation'!