Eliot Miranda uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-eem.345.mcz ==================== Summary ==================== Name: KernelTests-eem.345 Author: eem Time: 26 July 2018, 10:36:36.042879 pm UUID: 8331a012-d142-483a-85c3-18ef3059a66a Ancestors: KernelTests-eem.344 Add tests for critical: being in ensure: but not having evaluated ensure:'s receiver yet. =============== Diff against KernelTests-eem.344 =============== Item was added: + ----- Method: MutexTest>>testMutexCriticalBlockedInEnsure (in category 'testing') ----- + testMutexCriticalBlockedInEnsure "self run: #testMutexCriticalBlockedInEnsure" + "This tests whether a mutex that is in the ensure: in critical: but has yet to evaluate the valueNoContextSwitch + leaves it with the mutex unlocked." + | lock proc | + lock := Mutex new. + proc := [lock critical: []] newProcess. + proc priority: Processor activePriority - 1. + "step until in critical:" + [proc suspendedContext selector == #critical:] whileFalse: [proc step]. + "step until in ensure: (can't do this until in critical: cuz ensure: may be in newProcess etc...)" + [proc suspendedContext selector == #ensure:] whileFalse: [proc step]. + "Now check that the lock is owned." + self assert: lock isOwned. + "Now that proc is at the right point, resume the process and immediately terminate it." + proc resume; terminate. + self deny: lock isOwned. + self assert: lock isEmpty! Item was added: + ----- Method: SemaphoreTest>>testSemaCriticalBlockedInEnsure (in category 'testing') ----- + testSemaCriticalBlockedInEnsure "self run: #testSemaCriticalBlockedInEnsure" + "This tests whether a semaphore that is in ensure: but has yet to evaluate the valueNoContextSwitch + leaves it with signaling the associated semaphore." + | decompilation needSignalToEnterEnsure s p | + "Distinguish between e.g. + critical: t1 <criticalSection> ^[self wait. t1 value] ensure: [self signal] + and + critical: t1 <criticalSection> self wait. ^t1 ensure: [self signal]" + decompilation := (Semaphore>>#critical:) decompileString. + needSignalToEnterEnsure := (decompilation indexOfSubCollection: #wait) < (decompilation indexOf: $[). + s := Semaphore new. + needSignalToEnterEnsure ifTrue: [s signal]. + p := [s critical: []] newProcess. + p priority: Processor activePriority - 1. + "step until in critical:" + [p suspendedContext selector == #critical:] whileFalse: [p step]. + "step until in ensure: (can't do this until in critical: cuz ensure: may be in newProcess etc...)" + [p suspendedContext selector == #ensure:] whileFalse: [p step]. + "Now check that if we needed a signal to enter ensure: it has been consumed." + self assert: 0 equals: s excessSignals. + "Now that p is at the right point, resume the process and immediately terminate it." + p resume; terminate. + self assert: (needSignalToEnterEnsure ifTrue: [1] ifFalse: [0]) equals: s excessSignals! |
Free forum by Nabble | Edit this page |