344
|
1 |
"{ Package: 'exept:regression' }"
|
|
2 |
|
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
|
5 |
TestCase subclass:#Win32OperatingSystemTest
|
675
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
1161
|
9 |
category:'tests-Regression-RuntimeSystem'
|
344
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!Win32OperatingSystemTest methodsFor:'release'!
|
|
14 |
|
|
15 |
tearDown
|
|
16 |
! !
|
|
17 |
|
|
18 |
!Win32OperatingSystemTest methodsFor:'tests'!
|
|
19 |
|
|
20 |
testMutex
|
|
21 |
|handle alreadyExists lastErrorCode handleAndLastErrorCode|
|
|
22 |
|
675
|
23 |
OperatingSystem isMSWINDOWSlike ifFalse:[
|
|
24 |
^ self.
|
|
25 |
].
|
|
26 |
|
344
|
27 |
handleAndLastErrorCode := Win32OperatingSystem createMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0'.
|
|
28 |
handle := handleAndLastErrorCode first.
|
|
29 |
handle isNil ifTrue:[^ self].
|
|
30 |
lastErrorCode := handleAndLastErrorCode second.
|
|
31 |
self assert: lastErrorCode == 0.
|
|
32 |
alreadyExists := (lastErrorCode == 5 "ERROR_ACCESS_DENIED" or:[ lastErrorCode == 183 "ERROR_ALREADY_EXISTS"]).
|
|
33 |
alreadyExists ifTrue:[
|
355
|
34 |
Transcript showCR: 'Mutex already exists!!'.
|
|
35 |
^ self.
|
344
|
36 |
].
|
354
|
37 |
Transcript showCR: 'Mutex created!!'.
|
344
|
38 |
Win32OperatingSystem waitForSingleObject: handle.
|
355
|
39 |
Delay waitForSeconds:0.5. "/ self halt.
|
344
|
40 |
Win32OperatingSystem releaseMutex: handle.
|
|
41 |
Win32OperatingSystem primCloseHandle: handle.
|
354
|
42 |
Transcript showCR: 'Mutex closed!!'.
|
344
|
43 |
|
|
44 |
"
|
|
45 |
self new testMutex
|
|
46 |
"
|
|
47 |
! !
|
|
48 |
|
|
49 |
!Win32OperatingSystemTest class methodsFor:'documentation'!
|
|
50 |
|
|
51 |
version
|
|
52 |
^ '$Header$'
|
|
53 |
! !
|
1161
|
54 |
|