RegressionTests__Win32OperatingSystemTest.st
author Claus Gittinger <cg@exept.de>
Tue, 02 Dec 2008 12:47:39 +0100
changeset 354 310c6aca6525
parent 344 21c39da58029
child 355 d86e28afd549
permissions -rw-r--r--
oops

"{ Package: 'exept:regression' }"

"{ NameSpace: RegressionTests }"

TestCase subclass:#Win32OperatingSystemTest
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'tests-Regression'
!


!Win32OperatingSystemTest methodsFor:'release'!

tearDown
! !

!Win32OperatingSystemTest methodsFor:'tests'!

testMutex
    |handle alreadyExists lastErrorCode handleAndLastErrorCode|

    handleAndLastErrorCode := Win32OperatingSystem createMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0'.
    handle := handleAndLastErrorCode first.
    handle isNil ifTrue:[^ self].
    lastErrorCode := handleAndLastErrorCode second.
    self assert: lastErrorCode == 0.
    alreadyExists := (lastErrorCode == 5 "ERROR_ACCESS_DENIED" or:[ lastErrorCode == 183 "ERROR_ALREADY_EXISTS"]).
    alreadyExists ifTrue:[
	Transcript showCR: 'Mutex already exists!!'.
	^ self.
    ].
    Transcript showCR: 'Mutex created!!'.
    Win32OperatingSystem waitForSingleObject: handle.
    self halt.
    Win32OperatingSystem releaseMutex: handle.
    Win32OperatingSystem primCloseHandle: handle.
    Transcript showCR: 'Mutex closed!!'.

    "
     self new testMutex
    "
! !

!Win32OperatingSystemTest class methodsFor:'documentation'!

version
    ^ '$Header$'
! !