A new version of KernelTests was added to project The Inbox:
http://source.squeak.org/inbox/KernelTests-jar.405.mcz==================== Summary ====================
Name: KernelTests-jar.405
Author: jar
Time: 24 May 2021, 3:03:24.007073 pm
UUID: b261daff-2743-364f-876f-2049af8f75f7
Ancestors: KernelTests-nice.404
Add a stress test #testTerminateInEnsure presented by Martin McClure at 2019 Smalltalk conference. Tests unwind when a process gets terminated inside the #ensure unwind block. Complements latest #terminate in the Inbox.
=============== Diff against KernelTests-nice.404 ===============
Item was added:
+ ----- Method: ProcessTest>>testTerminateInEnsure (in category 'tests') -----
+ testTerminateInEnsure
+ "As shown in
+ Martin McClure's 'Threads, Critical Sections, and Termination' (Smalltalks 2019 conference)
+
https://youtu.be/AvM5YrjK9AE+ at 23:17
+ self new testTerminateInEnsure
+ "
+ | process count random delay |
+ random _ Random new.
+ 10 timesRepeat: [
+ process _ [
+ count _ 0.
+ [] ensure: [
+ 10 timesRepeat: [
+ count _ count + 1.
+ 1000000 timesRepeat: [12 factorial]].
+ count _ count + 1]
+ ] forkAt: Processor activeProcess priority - 1.
+ delay _ (random next * 100) asInteger + 10. "avoid 0-ms delay"
+ (Delay forMilliseconds: delay) wait.
+ self assert: process isTerminated not.
+ process terminate.
+ process priority: Processor activeProcess priority + 1.
+ self
+ assert: process isTerminated;
+ assert: count equals: 11 ]!