[squeak-dev] The Trunk: KernelTests-nice.399.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon Apr 12 20:34:17 UTC 2021
Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.399.mcz
==================== Summary ====================
Name: KernelTests-nice.399
Author: nice
Time: 12 April 2021, 10:34:15.635162 pm
UUID: 9d4c795e-d8db-465d-b5f9-f07e88072ee3
Ancestors: KernelTests-nice.398
Generalize the clean-up made in KernelTests-jar.397, and move it to tearDown.
This way, clean-up should also happen in case of failure.
=============== Diff against KernelTests-nice.398 ===============
Item was changed:
ClassTestCase subclass: #ProcessTest
+ instanceVariableNames: 'semaphore'
- instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'KernelTests-Processes'!
!ProcessTest commentStamp: 'ul 8/16/2011 11:35' prior: 0!
I hold test cases for generic Process-related behaviour.!
Item was added:
+ ----- Method: ProcessTest>>setUp (in category 'running') -----
+ setUp
+ semaphore := Semaphore new!
Item was changed:
----- Method: ProcessTest>>tearDown (in category 'running') -----
tearDown
+ Processor activeProcess environmentRemoveKey: #processTests ifAbsent: [].
+
+ "Release all processes still waiting at the semaphore or in the active priority queue."
+ Processor yield.
+ [semaphore isEmpty] whileFalse: [semaphore signal]!
- Processor activeProcess environmentRemoveKey: #processTests ifAbsent: []!
Item was changed:
----- Method: ProcessTest>>testAtomicSuspend (in category 'tests') -----
testAtomicSuspend
"Test atomic suspend of foreign processes"
+ | list p |
+ p := [semaphore wait] fork.
- | list p sema |
- sema := Semaphore new.
- p := [sema wait] fork.
Processor yield.
list := p suspendPrimitivelyOrFail.
+ self assert: list == semaphore.
- self assert: list == sema.
!
Item was changed:
----- Method: ProcessTest>>testProcessStateTests (in category 'tests') -----
testProcessStateTests
- | semaphore |
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.
- semaphore := Semaphore new.
-
"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."
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."
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.!
- self assert: ([semaphore wait] forkAt: Processor activePriority) terminate isTerminated.
-
- "Clean up: release all processes still waiting at the semaphore or in the active priority queue."
- Processor yield.
- [semaphore isEmpty] whileFalse: [semaphore signal]
- !
More information about the Squeak-dev
mailing list
|