[squeak-dev] The Trunk: KernelTests-ct.415.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Dec 16 01:31:13 UTC 2021
Christoph Thiede uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-ct.415.mcz
==================== Summary ====================
Name: KernelTests-ct.415
Author: ct
Time: 16 December 2021, 2:23:31.207664 am
UUID: dd59e950-527f-d946-8274-fec0314de879
Ancestors: KernelTests-ct.414
Complements Kernel-ct.1434 (revised termination modi on Process). Tests process-faithful debugging, process states, and nested unwinding for all termination modi. Adds tests for #complete:ifError. (No tests were deleted, just reorganized.)
=============== Diff against KernelTests-ct.414 ===============
Item was added:
+ ----- Method: ProcessTest>>testComplete (in category 'tests') -----
+ testComplete
+
+ 1 to: 5 do: [:i | | process z expected result |
+ process := [z := 1
+ in: [:x | 2
+ in: [:y |
+ Processor activeProcess suspend.
+ x + y]]] fork.
+ Processor yield.
+
+ expected := process suspendedContext stack at: i + 1.
+ result := process
+ complete: (process suspendedContext stack at: i)
+ ifError: [:error | self fail].
+
+ self assert: expected equals: result.
+ self assert: expected equals: process suspendedContext.
+
+ process runUntil: [:ctx | ctx isDead].
+
+ self should: process isTerminated.
+ self assert: 3 equals: z].!
Item was added:
+ ----- Method: ProcessTest>>testCompleteError (in category 'tests') -----
+ testCompleteError
+
+ 1 to: 5 do: [:i | | process z result error |
+ process := [z := 1
+ in: [:x | 0
+ in: [:y |
+ Processor activeProcess suspend.
+ x / y]]] fork.
+ Processor yield.
+
+ result := process
+ complete: (process suspendedContext stack at: i)
+ ifError: [:ex | error := ex].
+
+ self assert: (error isKindOf: ZeroDivide).
+ self assert: process suspendedContext equals: result.
+
+ process runUntil: [:ctx | ctx isDead].
+
+ self should: process isTerminated.
+ self assert: error equals: z].!
Item was removed:
- ----- Method: ProcessTest>>testNestedUnwind (in category 'tests') -----
- testNestedUnwind
- "Test all nested unwind blocks are correctly unwound; all unwind blocks halfway through their execution should be completed or at least attempted to complete, not only the innermost one"
-
- | p x1 x2 x3 |
- x1 := x2 := x3 := false.
- p :=
- [
- [
- [ ] ensure: [ "halfway through completion when suspended"
- [ ] ensure: [ "halfway through completion when suspended"
- Processor activeProcess suspend.
- x1 := true].
- x2 := true]
- ] ensure: [ "not started yet when suspended"
- x3 := true]
- ] fork.
- Processor yield.
- p terminate.
-
- self assert: x1 & x2 & x3!
Item was added:
+ ----- Method: ProcessTest>>testProcessFaithfulTerminate (in category 'tests') -----
+ testProcessFaithfulTerminate
+
+ ^ self testProcessFaithfulTermination: #terminate!
Item was added:
+ ----- Method: ProcessTest>>testProcessFaithfulTerminateAggressively (in category 'tests') -----
+ testProcessFaithfulTerminateAggressively
+
+ ^ self testProcessFaithfulTermination: #terminateAggressively!
Item was removed:
- ----- Method: ProcessTest>>testProcessFaithfulTermination (in category 'tests') -----
- testProcessFaithfulTermination
- "When terminating a process, unwind blocks should be evaluated as if they were executed by the process being terminated."
-
- | process result |
- process := [
- [Processor activeProcess suspend]
- ensure: [result := Processor activeProcess environmentAt: #foo]]
- fork.
- Processor yield.
- process environmentAt: #foo put: 42.
-
- process terminate.
-
- self should: process isTerminated.
- self assert: 42 equals: result.!
Item was added:
+ ----- Method: ProcessTest>>testProcessFaithfulTermination: (in category 'tests') -----
+ testProcessFaithfulTermination: terminator
+ "When terminating a process, unwind blocks should be evaluated as if they were executed by the process being terminated."
+
+ | process result |
+ process := [
+ [Processor activeProcess suspend]
+ ensure: [result := Processor activeProcess environmentAt: #foo]]
+ fork.
+ Processor yield.
+ process environmentAt: #foo put: 42.
+
+ terminator value: process.
+
+ self should: process isTerminated.
+ self assert: 42 equals: result.!
Item was added:
+ ----- Method: ProcessTest>>testProcessStateTestDestroy (in category 'tests') -----
+ testProcessStateTestDestroy
+
+ ^ self testProcessStateTestTermination: #destroy!
Item was added:
+ ----- Method: ProcessTest>>testProcessStateTestTerminate (in category 'tests') -----
+ testProcessStateTestTerminate
+
+ ^ self testProcessStateTestTermination: #terminate!
Item was added:
+ ----- Method: ProcessTest>>testProcessStateTestTerminateAggressively (in category 'tests') -----
+ testProcessStateTestTerminateAggressively
+
+ ^ self testProcessStateTestTermination: #terminateAggressively!
Item was added:
+ ----- Method: ProcessTest>>testProcessStateTestTermination: (in category 'tests') -----
+ testProcessStateTestTermination: terminator
+ "I test that a process is terminated when it reaches the last instruction
+ of the bottom context for methods other than Process>>#terminate;
+ this test would fail with the version of isTerminated before 3/11/2021."
+
+ | bottomContext newProcess |
+
+ newProcess := Process new.
+ bottomContext := Context
+ sender: nil
+ receiver: newProcess
+ method: (ProcessTest>>#terminated)
+ arguments: {}.
+ newProcess suspendedContext: ([] asContextWithSender: bottomContext).
+ newProcess priority: Processor activePriority.
+
+ self deny: newProcess isTerminated.
+ terminator value: newProcess.
+ self assert: newProcess isTerminated.
+ !
Item was changed:
----- Method: ProcessTest>>testProcessStateTests (in category 'tests') -----
testProcessStateTests
self assert: Processor activeProcess isActiveProcess.
self deny: Processor activeProcess isBlocked.
self assert: Processor activeProcess isRunnable.
self deny: Processor activeProcess isSuspended.
self deny: Processor activeProcess isTerminated.
"These processes are runnable but haven't got to the wait yet because the active process is running."
self deny: ([semaphore wait] forkAt: Processor activePriority) isActiveProcess.
self deny: ([semaphore wait] forkAt: Processor activePriority) isBlocked.
self assert: ([semaphore wait] forkAt: Processor activePriority) isRunnable.
self deny: ([semaphore wait] forkAt: Processor activePriority) isSuspended.
self deny: ([semaphore wait] forkAt: Processor activePriority) isTerminated.
self deny: ([semaphore wait] forkAt: Processor activePriority) suspendingList == semaphore.
"These processes do get to run because, being higher priority they preempt the active process until they wait on the semaphore."
self deny: ([semaphore wait] forkAt: Processor activePriority + 1) isActiveProcess.
self assert: ([semaphore wait] forkAt: Processor activePriority + 1) isBlocked.
self deny: ([semaphore wait] forkAt: Processor activePriority + 1) isRunnable.
self deny: ([semaphore wait] forkAt: Processor activePriority + 1) isSuspended.
self deny: ([semaphore wait] forkAt: Processor activePriority + 1) isTerminated.
self assert: ([semaphore wait] forkAt: Processor activePriority + 1) suspendingList == semaphore.
"These processes should be suspended, not terminated."
self deny: ([Processor activeProcess suspend] forkAt: Processor activePriority + 1) isActiveProcess.
self deny: ([Processor activeProcess suspend] forkAt: Processor activePriority + 1) isBlocked.
self deny: ([Processor activeProcess suspend] forkAt: Processor activePriority + 1) isRunnable.
self assert: ([Processor activeProcess suspend] forkAt: Processor activePriority + 1) isSuspended.
self deny: ([Processor activeProcess suspend] forkAt: Processor activePriority + 1) isTerminated.
self assert: ([Processor activeProcess suspend] forkAt: Processor activePriority + 1) suspendingList isNil.
"These processes should be terminated, not suspended."
+ #(terminate terminateAggressively destroy) do: [:terminator |
+ self deny: ([terminator value: Processor activeProcess] forkAt: Processor activePriority + 1) isActiveProcess.
+ self deny: ([terminator value: Processor activeProcess] forkAt: Processor activePriority + 1) isBlocked.
+ self deny: ([terminator value: Processor activeProcess] forkAt: Processor activePriority + 1) isRunnable.
+ self deny: ([terminator value: Processor activeProcess] forkAt: Processor activePriority + 1) isSuspended.
+ self assert: ([terminator value: Processor activeProcess] forkAt: Processor activePriority + 1) isTerminated.
+ self assert: ([terminator value: Processor activeProcess] forkAt: Processor activePriority + 1) suspendingList isNil].
- self deny: ([Processor activeProcess terminate] forkAt: Processor activePriority + 1) isActiveProcess.
- self deny: ([Processor activeProcess terminate] forkAt: Processor activePriority + 1) isBlocked.
- self deny: ([Processor activeProcess terminate] forkAt: Processor activePriority + 1) isRunnable.
- self deny: ([Processor activeProcess terminate] forkAt: Processor activePriority + 1) isSuspended.
- self assert: ([Processor activeProcess terminate] forkAt: Processor activePriority + 1) isTerminated.
- self assert: ([Processor activeProcess terminate] forkAt: Processor activePriority + 1) suspendingList isNil.
"These processes should be suspended."
self deny: (([semaphore wait] forkAt: Processor activePriority) suspend; yourself) isActiveProcess.
self deny: (([semaphore wait] forkAt: Processor activePriority) suspend; yourself) isBlocked.
self deny: (([semaphore wait] forkAt: Processor activePriority) suspend; yourself) isRunnable.
self assert: (([semaphore wait] forkAt: Processor activePriority) suspend; yourself) isSuspended.
self deny: (([semaphore wait] forkAt: Processor activePriority) suspend; yourself) isTerminated.
"These processes should be terminated."
+ #(terminate terminateAggressively destroy) do: [:terminator |
+ self deny: (terminator value: ([semaphore wait] forkAt: Processor activePriority)) isActiveProcess.
+ self deny: (terminator value: ([semaphore wait] forkAt: Processor activePriority)) isBlocked.
+ self deny: (terminator value: ([semaphore wait] forkAt: Processor activePriority)) isRunnable.
+ self deny: (terminator value: ([semaphore wait] forkAt: Processor activePriority)) isSuspended.
+ self assert: (terminator value: ([semaphore wait] forkAt: Processor activePriority)) isTerminated].!
- self deny: ([semaphore wait] forkAt: Processor activePriority) terminate isActiveProcess.
- self deny: ([semaphore wait] forkAt: Processor activePriority) terminate isBlocked.
- self deny: ([semaphore wait] forkAt: Processor activePriority) terminate isRunnable.
- self deny: ([semaphore wait] forkAt: Processor activePriority) terminate isSuspended.
- self assert: ([semaphore wait] forkAt: Processor activePriority) terminate isTerminated.!
Item was added:
+ ----- Method: ProcessTest>>testTerminateNestedUnwind (in category 'tests') -----
+ testTerminateNestedUnwind
+ "Test all nested unwind blocks are correctly unwound; all unwind blocks halfway through their execution should be completed or at least attempted to complete, not only the innermost one"
+
+ | p x1 x2 x3 |
+ x1 := x2 := x3 := false.
+ p :=
+ [
+ [
+ [ ] ensure: [ "halfway through completion when suspended"
+ [ ] ensure: [ "halfway through completion when suspended"
+ Processor activeProcess suspend.
+ x1 := true].
+ x2 := true]
+ ] ensure: [ "not started yet when suspended"
+ x3 := true]
+ ] fork.
+ Processor yield.
+ p terminate.
+
+ self assert: x1.
+ self assert: x2.
+ self assert: x3.!
Item was added:
+ ----- Method: ProcessTest>>testTerminateNestedUnwindAggressively (in category 'tests') -----
+ testTerminateNestedUnwindAggressively
+ "Test nested unwind blocks are correctly unwound; all unwind blocks halfway through their execution should not be attempted to complete."
+
+ | p x1 x2 x3 |
+ x1 := x2 := x3 := false.
+ p :=
+ [
+ [
+ [ ] ensure: [ "halfway through completion when suspended"
+ [ ] ensure: [ "halfway through completion when suspended"
+ Processor activeProcess suspend.
+ x1 := true].
+ x2 := true]
+ ] ensure: [ "not started yet when suspended"
+ x3 := true]
+ ] fork.
+ Processor yield.
+ p terminateAggressively.
+
+ self deny: x1.
+ self deny: x2.
+ self assert: x3.!
More information about the Squeak-dev
mailing list
|