1 #define ACE_DOESNT_DEFINE_MAIN
3 #include "test_config.h"
5 #include "ace/Init_ACE.h"
6 #include "ace/Singleton.h"
8 int restart_test_logging (const ACE_TCHAR
*program
)
10 if (ACE_LOG_MSG
->open (program
, ACE_Log_Msg::OSTREAM
|
11 ACE_Log_Msg::VERBOSE_LITE
) != 0)
12 ACE_ERROR_RETURN ((LM_ERROR
, ACE_TEXT ("%p\n"),
13 ACE_TEXT ("open log_msg failed")), -1);
14 if (ace_file_stream::instance()->set_output (program
, 1) != 0)
15 ACE_ERROR_RETURN ((LM_ERROR
, ACE_TEXT ("%p\n"),
16 ACE_TEXT ("set_output failed")), -1);
20 void report_error (const ACE_TCHAR
*lock
)
22 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("ACE_Singleton<int, %s> ")
23 ACE_TEXT ("failed to allocate\n"), lock
));
26 using Singleton1
= ACE_Singleton
<int, ACE_MT_SYNCH::MUTEX
>;
27 using Singleton2
= ACE_Singleton
<int, ACE_MT_SYNCH::RECURSIVE_MUTEX
>;
32 ACE_START_TEST (ACE_TEXT ("Singleton_Restart_Test"));
34 *Singleton1::instance () = 1;
35 *Singleton2::instance () = 2;
39 if (restart_test_logging (program
) != 0) // program defined in ACE_START_TEST
42 int *i1
= Singleton1::instance ();
44 report_error (ACE_TEXT ("ACE_SYNCH_MUTEX"));
46 int *i2
= Singleton2::instance ();
48 report_error (ACE_TEXT ("ACE_SYNCH_RECURSIVE_MUTEX"));
53 return (i1
&& i2
) ? 0 : 1;