2 * @file Bug_3541_Regression_Test.cpp
4 * Reproduces the problems reported in bug 3541:
5 * http://bugzilla.dre.vanderbilt.edu/show_bug.cgi?id=3541
7 * @author Bill Rizzi <rizzi@softserv.com>
10 #include "ace/Event.h"
11 #include "ace/Mutex.h"
12 #include "ace/Semaphore.h"
13 #include "ace/OS_NS_errno.h"
14 #include "ace/SString.h"
15 #include "test_config.h"
18 run_main (int, ACE_TCHAR
*[])
20 ACE_START_TEST (ACE_TEXT ("Bug_3541_Regression_Test"));
24 #if defined(ACE_WIN32)
27 // ACE_OS::event_init()
29 const ACE_TCHAR
*eventName
= ACE_TEXT ("Bug3541_Event");
31 ACE_Event
event0(0, // int manual_reset = 0
32 0, // int initial_state = 0
33 USYNC_PROCESS
, // int type = USYNC_THREAD
34 eventName
); // const ACE_TCHAR *name = 0
36 lastError
= ACE_OS::last_error();
38 ACE_event_t eventHandle
= event0
.handle();
40 if ((eventHandle
== ACE_INVALID_HANDLE
) ||
46 ACE_TEXT ("ACE_Event(%s) failed - handle %d lastError %d\n"),
47 eventName
, eventHandle
, lastError
));
51 ACE_Event
event1(0, // int manual_reset = 0
52 0, // int initial_state = 0
53 USYNC_PROCESS
, // int type = USYNC_THREAD
54 eventName
); // const ACE_TCHAR *name = 0
56 lastError
= ACE_OS::last_error();
58 eventHandle
= event1
.handle();
60 if ((eventHandle
== ACE_INVALID_HANDLE
) ||
61 (lastError
!= ERROR_ALREADY_EXISTS
))
66 ACE_TEXT ("ACE_Event(%s) failed - handle %d lastError %d\n"),
67 eventName
, eventHandle
, lastError
));
73 const ACE_TCHAR
*semaphoreName
= ACE_TEXT ("Bug3541_Semaphore");
75 ACE_Semaphore
semaphore0(1, // int count = 1
76 USYNC_PROCESS
, // int type = USYNC_THREAD
77 semaphoreName
); // const ACE_TCHAR *name = 0
79 lastError
= ACE_OS::last_error();
81 const ACE_sema_t
&semaphoreLock
= semaphore0
.lock();
82 if ((semaphoreLock
== ACE_INVALID_HANDLE
) ||
88 ACE_TEXT ("ACE_Semaphore(%s) failed - lock %d lastError %d\n"),
89 semaphoreName
, semaphoreLock
, lastError
));
93 ACE_Semaphore
semaphore1(1, // int count = 1
94 USYNC_PROCESS
, // int type = USYNC_THREAD
95 semaphoreName
); // const ACE_TCHAR *name = 0
97 lastError
= ACE_OS::last_error();
99 const ACE_sema_t
&semaphoreLock
= semaphore1
.lock();
101 if ((semaphoreLock
== ACE_INVALID_HANDLE
) ||
102 (lastError
!= ERROR_ALREADY_EXISTS
))
106 ACE_ERROR ((LM_ERROR
,
107 ACE_TEXT ("ACE_Semaphore(%s) failed - lock %d lastError %d\n"),
108 semaphoreName
, semaphoreLock
, lastError
));
112 // ACE_OS::mutex_init()
114 const ACE_TCHAR
*mutexName
= ACE_TEXT ("Bug3541_Mutex");
116 ACE_Mutex
mutex0(USYNC_PROCESS
, // int type = USYNC_THREAD
117 mutexName
); // const ACE_TCHAR *name = 0
119 lastError
= ACE_OS::last_error();
121 const ACE_mutex_t
&mutexLock
= mutex0
.lock();
123 if ((mutexLock
.proc_mutex_
== ACE_INVALID_HANDLE
) ||
128 ACE_ERROR ((LM_ERROR
,
129 ACE_TEXT ("ACE_Mutex(%s) failed - lock %d lastError %d\n"),
130 mutexName
, mutexLock
, lastError
));
134 ACE_Mutex
mutex1(USYNC_PROCESS
, // int type = USYNC_THREAD
135 mutexName
); // const ACE_TCHAR *name = 0
137 lastError
= ACE_OS::last_error();
139 const ACE_mutex_t
&mutexLock
= mutex1
.lock();
141 if ((mutexLock
.proc_mutex_
== ACE_INVALID_HANDLE
) ||
142 (lastError
!= ERROR_ALREADY_EXISTS
))
146 ACE_ERROR ((LM_ERROR
,
147 ACE_TEXT ("ACE_Mutex(%s) failed - lock %d lastError %d\n"),
148 mutexName
, mutexLock
, lastError
));