2 //=============================================================================
4 * @file Object_Manager_Test.cpp
6 * Tests the basic functions of the ACE_Object_Manager.
8 * @author David L. Levine <levine@cs.wustl.edu>
10 //=============================================================================
13 #include "test_config.h"
14 #include "ace/Object_Manager.h"
15 #include "ace/OS_Memory.h"
16 #include "ace/Init_ACE.h"
31 hook2 (void * /* object */, void *param
)
33 u_int
*paramp
= reinterpret_cast<u_int
*> (param
);
35 // We can use ACE_Log_Msg in an ACE_Object_Manager cleanup hook.
36 // But NOT in an ACE_OS::atexit () hook! However, the ACE_END_TEST
37 // invocation in main () will prevent this from being output to the
40 ACE_TEXT ("hook2: %d\n"),
46 run_main (int, ACE_TCHAR
*[])
50 ACE_START_TEST (ACE_TEXT ("Object_Manager_Test"));
54 // If hook1 never gets called, this will show up as a memory leak.
59 const int starting_up
=
60 ACE_Object_Manager::instance ()->starting_up ();
61 const int shutting_down
=
62 ACE_Object_Manager::instance ()->shutting_down ();
65 ACE_TEXT ("starting_up: %d, shutting_down: %d\n"),
69 if (starting_up
|| shutting_down
)
74 ACE_TEXT ("starting_up and shutting_down are supposed to ")
75 ACE_TEXT (" be 0!!!!")));
78 if (ACE_OS::atexit (hook1
) != 0)
83 ACE_TEXT ("ACE_OS::atexit () returned non-zero!!!!")));
86 for (u_int i
= 0; i
< 10; ++i
)
89 ACE_NEW_RETURN (paramp
,
94 // The first paramp argument is only used to distinguish the
95 // at_exit entries. The ACE_Object_Manager only allows one
96 // at_exit per object. It's not used in the hook.
97 if (ACE_Object_Manager::instance ()->at_exit (paramp
,
102 ACE_ERROR ((LM_ERROR
,
104 ACE_TEXT ("ACE_Object_Manager::at_exit () ")
105 ACE_TEXT ("returned non-zero!!!!")));
111 return errors
== 0 ? 0 : 1;