[squeak-dev] The Trunk: KernelTests-eem.344.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Jul 27 03:44:25 UTC 2018


Eliot Miranda uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-eem.344.mcz

==================== Summary ====================

Name: KernelTests-eem.344
Author: eem
Time: 26 July 2018, 8:43:56.697782 pm
UUID: 59075a46-0387-4cec-a4a3-0f224c9e0f0d
Ancestors: KernelTests-ul.343

Tests for Mutex that parallel SemaphoreTest

=============== Diff against KernelTests-ul.343 ===============

Item was added:
+ ClassTestCase subclass: #MutexTest
+ 	instanceVariableNames: ''
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'KernelTests-Processes'!
+ 
+ !MutexTest commentStamp: 'eem 7/26/2018 20:42' prior: 0!
+ MutexTest provides SUnit tests for Mutex locks. c.f. SemaphoreTest.!

Item was added:
+ ----- Method: MutexTest>>criticalError (in category 'private') -----
+ criticalError
+ 	Processor activeProcess terminate!

Item was added:
+ ----- Method: MutexTest>>testCritical (in category 'testing') -----
+ testCritical
+ 	| lock |
+ 	lock := Mutex new.
+ 	[lock critical: [self criticalError]] forkAt: Processor userInterruptPriority.
+ 	self deny: lock isOwned!

Item was added:
+ ----- Method: MutexTest>>testCriticalIfError (in category 'testing') -----
+ testCriticalIfError
+ 	| lock |
+ 	lock := Mutex new.
+ 	[lock critical: [self criticalError ifError: []]] forkAt: Processor userInterruptPriority.
+ 	self deny: lock isOwned!

Item was added:
+ ----- Method: MutexTest>>testMutexAfterCriticalWait (in category 'testing') -----
+ testMutexAfterCriticalWait	"self run: #testMutexAfterCriticalWait"
+ 	"This tests whether a process that has just left the primitiveEnterCriticalSection in Mutex>>critical:
+ 	leaves it with the mutex correctly released."
+ 	| lock p |
+ 	lock := Mutex new.
+ 	p := [lock critical: []] newProcess.
+ 	p priority: Processor activePriority - 1.
+ 	lock critical: "We now own it; p can't enter properly"
+ 		[p resume.
+ 		 "wait until p enters the critical section; it doesn't own the Mutex so is blocked..."
+ 		 [p suspendingList == lock] whileFalse: [(Delay forMilliseconds: 10) wait].
+ 		 self deny: lock isEmpty].
+ 	"p is waiting on lock; on our exiting critical: p is now the notional owner. Terminate before it has a chance to run".
+ 	p terminate.
+ 	self deny: lock isOwned.
+ 	self assert: lock isEmpty!

Item was added:
+ ----- Method: MutexTest>>testMutexInCriticalWait (in category 'testing') -----
+ testMutexInCriticalWait	"self run: #testMutexInCriticalWait"
+ 	"This tests whether a mutex that has got past the primitiveEnterCriticalSection in Mutex>>critical:
+ 	leaves it unowned."
+ 	| lock sock proc |
+ 	lock := Mutex new.
+ 	sock := Semaphore new.
+ 	proc := [lock critical: [sock wait]] fork.
+ 	Processor yield.
+ 	self assert: proc suspendingList == sock.
+ 	proc terminate.
+ 	self deny: lock isOwned.
+ 	self assert: lock isEmpty!



More information about the Squeak-dev mailing list